var quickReScheduleArray = [];
$(document).ready(function () {
$.each(['txtDate', 'txtFrmDate', 'txtToDate', 'txtFromDateForTutoringSession', 'txtToDateForTutoringSession', 'txtSingleDate', 'revolvingStartDate', 'revolvingEndDate'],
function (i, val) {
$('#' + val).datepicker({ changeMonth: true, changeYear: true });
});
setDatepicker($("#rescheduleSessionModal").find("#txtRescheduleToDate"));
setStartEndTimePicker($("#rescheduleSessionModal").find('#txtRescheduleToStartTime'), $("#rescheduleSessionModal").find('#txtRescheduleToEndTime'));
setStartEndTimePicker($("#divModalCreateSessions").find('#startTime'), $("#divModalCreateSessions").find('#endTime'));
setStartEndTimePicker($("#divModalBatchScheduleRequest").find('#txtBatchScheduleRequestStartTime'), $("#divModalBatchScheduleRequest").find('#txtBatchScheduleRequestEndTime'));
$('#selectGroup').multiselect({
selectAllText: 'All Group',
includeSelectAllOption: true,
allSelectedText: 'All Group',
numberDisplayed: 2,
enableCaseInsensitiveFiltering: 1,
maxHeight: 200,
onChange: function (option, checked) {
var selectedOptions = $('#selectGroup option:selected');
groupDDL = '';
selectedOptions.each(function () {
if ($("#hdnSelectGroup option[value='" + $(this).val() + "']").length == 0) {
groupDDL += '';
}
});
$('#hdnSelectGroup').append(groupDDL);
}
});
});
function toogleSelection(ele) {
if (ele.checked) {
$(ele).closest('table').find('input[name=selectorForAction]').each(function () { this.checked = true; });
}
else {
$(ele).closest('table').find('input[name=selectorForAction]').each(function () { this.checked = false; });
}
}
//Batch Students
function ParticipantPlanAddDialog(studentId) {
$('#divModalParticipantPlan').modal('show');
$('#divModalParticipantPlan form').find('select').val('').trigger('blur');
$('#divModalParticipantPlan form').find(':checkbox:checked').trigger('click');
//$('#divModalParticipantPlan form').find('span').html('');
$('#divModalParticipantPlan').find("#HStudentId").val(studentId);
$.validator.unobtrusive.parse('#AddStudentDiv');
};
function pagingStudentList(Id) {
//document.getElementById('pagenumber').value = Id.toString();
//var pageMoreHidden = document.getElementById('pageNoSearchStudentHidden');
//pageMoreHidden.value = Id;
//var pageMoreSubmit = document.getElementById('BatchParticipantSubmit');
//pageMoreSubmit.click();
$('#TutoringsessionPageIndex').val(Id);
$('#TutoringSessionsSubmit').click();
}
function addExistingStudent(unsignedStudentCount) {
if (Number(unsignedStudentCount) > 0) {
$('#divModalExistingStudent').modal('show');
}
else {
bootbox.alert('No Students are Available to Add', null);
}
}
function addCleverStudent(unsignedStudentCount) {
if (Number(unsignedStudentCount) > 0) {
$('#divModalImportCleverStudent').modal('show');
}
else {
bootbox.alert('No Students are Available to Add', null);
}
}
function setSaveExstingStudentField(ele) {
var formTag = $(ele).closest('form');
var flag = false;
$(formTag).find('input[type="checkbox"]').each(function () {
if (this.checked) {
flag = true;
return false;
}
});
if (flag) {
$('#saveExistingStudentField').val('1');
document.getElementById('hdnExistingSubmit').click();
}
else {
bootbox.alert('select atleast one record', null);
}
}
function addNewStudent() {
$('#addStudentTable input[type="text"]').each(function () {
$(this).val("");
});
$('#divModalNewStudent').find('input, select').each(function () { $(this).rules('remove', 'required'); $(this).trigger('blur'); });
$('#divModalNewStudent').find('span[data-valmsg-for]').html('');
$('#divModalNewStudent').modal('show');
}
function batchSchedulRequest(batchId, productType) {
$('#selectGroup').parent().show();
$('#selectGroup').html('').multiselect('rebuild');
$('#hdnSelectGroup').html('');
$('#groupTag').css("display", "none");
if (productType === 3 || productType === -999) {
$('#divModalBatchScheduleRequest').find('input, select').each(function () { $(this).rules('remove', 'required'); $(this).trigger('blur'); });
$('#divModalBatchScheduleRequest').find('span[data-valmsg-for]').html('');
$('#divModalBatchScheduleRequest').modal('show');
}
else {
bindGroup(batchId, productType);
}
}
function bindGroup(batchId, productType) {
$.get('/Batchset/GetBatchGroups', { BatchId: batchId, ProductType: productType }, function (data) {
var groupDDL = '';
if (data.GroupList.length > 0) {
for (var i in data.GroupList) {
var group = data.GroupList[i];
if ($("#selectGroup option[value='" + group.Code + "']").length == 0) { groupDDL += ''; }
}
$('#selectGroup').append(groupDDL);
$('#selectGroup').multiselect('rebuild');
$('#hdnSelectGroup option').each(function () {
$('option[value="' + $(this).val() + '"]', $('#selectGroup')).prop('selected', true);
$("#selectGroup").multiselect("refresh");
});
if (productType !== 3) {
$('#divModalBatchScheduleRequest').find('input, select').each(function () { $(this).rules('remove', 'required'); $(this).trigger('blur'); });
$('#divModalBatchScheduleRequest').find('span[data-valmsg-for]').html('');
$('#divModalBatchScheduleRequest').modal('show');
}
} else {
alert("No groups with students found for this batch!");
}
});
}
function batchSchedulRequestEdit(e) {
$('#selectGroup').html('').multiselect('rebuild');
$('#hdnSelectGroup').html('');
var currentRow = $(e).closest("tr");
var mdiv = $(e).closest('div');
var col0 = currentRow.find("td:eq(0)").text();
var col1 = currentRow.find("td:eq(1)").text();
var requestType = currentRow.find('input[id=hdnRequestType]').val();
if (requestType === '1') {
$(".batch-schedule-request-start-time").hide();
$(".batch-schedule-request-end-time").hide();
} else if (requestType === '2') {
$(".batch-schedule-request-start-time").show();
$(".batch-schedule-request-end-time").show();
}
var col2 = currentRow.find("td:eq(2)").text();
var col3 = currentRow.find("td:eq(3)").text();
var col4 = currentRow.find("td:eq(4)").text();
var col5 = currentRow.find("td:eq(5)").text();
$('#divModalBatchScheduleRequest').find('input, select').each(function () {
$(this).rules('remove', 'required');
$(this).trigger('blur');
});
$('#divModalBatchScheduleRequest').find('span[data-valmsg-for]').html('');
$('#divModalBatchScheduleRequest').modal('show');
$('#hdnBatchScheduleRqequestId').val(currentRow.find('input[id=hdnRequestId]').val());
$("input[name=selectRequestType][value=" + requestType + "]").prop('checked', true);
$('#txtBatchScheduleRequestFromDate').val(col3);
var utcToday = mdiv.find('input[id=hdnUTCTodayDate]').val().split(' ')[0];
if (new Date(col3) < new Date(utcToday)) {
$('#txtBatchScheduleRequestFromDate').attr('disabled', 'disabled');
}
$('#txtBatchScheduleRequestToDate').val(col4);
$('#txtBatchScheduleRequestStartTime').val(col5.split('-')[0]);
$('#txtBatchScheduleRequestEndTime').val(col5.split('-')[1]);
var groupId = currentRow.find('input[id=hdnGroupId]').val();
$("#groupTag").css("display", "block").text(col0);
$('#selectGroup').val(null).trigger("change")
$('#hdnSelectGroup').val(null).trigger("change")
var groupDDL = '';
$('#selectGroup').append(groupDDL);
$("#selectGroup").val([groupId]);
$('#selectGroup').multiselect('rebuild');
$('#selectGroup').parent().hide();
var hdnGroupDDL = '';
$('#hdnSelectGroup').append(hdnGroupDDL);
}
function batchSchedulRequestDelete(e) {
var currentRow = $(e).closest("tr");
var requestId = currentRow.find('input[id=hdnRequestId]').val();
$.post("/Batchset/DeleteBatchScheduleRequest/", { requestId: requestId }, function (result) {
if (result.status == "Succeeded") {
window.location.reload();
}
else {
bootbox.alert("Some Error Occurred while Deleting this Request", null);
}
});
}
function changeOTUSStatus(batchId, otusConnectionStatus) {
bootbox.confirm('Are you sure you want to change OTUS Connection status?', function (data) {
if (data) {
$.post("/Batch/SetOTUSConnectionStatus/", { batchId: batchId, otusConnectionStatus: otusConnectionStatus }, function (result) {
if (result == "Succeeded") {
window.location.reload();
}
else {
bootbox.alert("Some Error Occurred while Deleting this Student", null);
}
});
}
});
}
function deleteStudent(studentId) {
bootbox.confirm('Are you sure you want to delete?', function (data) {
if (data) {
$.post("/Batch/RemoveParticipant/", { studentId: studentId }, function (result) {
if (result == "Succeeded") {
window.location.reload();
}
else {
bootbox.alert("Some Error Occurred while Deleting this Student", null);
}
});
}
});
}
function AddParticipantPlan(programId, studentId) {
window.location = "/Batch/AddParticipantPlan/" + programId + "&studentId=" + studentId;
};
function updatePlan(syncOption) {
$("#hdnSyncPlan").val(syncOption);
var syncOptionValue = $("#hdnSyncPlan").val();
$("#divModalUpdatePlan").modal('show');
}
function toogleSelectAll(isChecked) {
$('input[class=selectStudents]').each(function () {
this.checked = isChecked;
});
}
function toggleCCVideoSelectAll(isChecked) {
$('input[class=ccVideoStudents]').each(function () {
this.checked = isChecked;
});
}
function updatePlanForstudents(batchId, programId) {
var studentIds = '';
$('input[class=selectStudents]:checked').each(function () {
studentIds += this.id + ',';
});
if (studentIds.length > 0) {
$("#divModalUpdatePlan").modal("hide");
var syncOption = $("#hdnSyncPlan").val();
$.post("/Program/UpdateStudentPlan/", { studentIds: studentIds, batchId: batchId, programId: programId, syncOption: syncOption }, function (data1) {
});
}
else {
bootbox.alert('Select atleast one plan', null);
}
}
function refreshParticipantsDiv(batchId) {
$('#updateplanForStudents').remove();
window.location = "/Batch/Details/" + batchId;
}
function saveStudentPlan(ele) {
var formTag = $(ele).closest('form');
if ($(formTag).validate().form()) {
$(formTag).submit();
}
}
$(document).on('click', ':checkbox[name="removeAllStudent"]', function () {
if (this.checked) {
$(':checkbox[name="removeSelectStudent"]').each(function () {
this.checked = true;
$('#removeStudent').show();
});
}
else {
$(':checkbox[name="removeSelectStudent"]').each(function () {
this.checked = false;
$('#removeStudent').hide();
});
}
});
$(document).on('click', ':checkbox[name="removeSelectStudent"]', function () {
if ($(':checkbox[name="removeSelectStudent"]:checked').length == $(':checkbox[name="removeSelectStudent"]').length) {
$(':checkbox[name="removeAllStudent"]').attr('checked', 'checked');
}
else {
$(':checkbox[name="removeAllStudent"]').removeAttr('checked');
}
if ($(':checkbox[name="removeSelectStudent"]:checked').length) {
$('#removeStudent').show();
}
else {
$('#removeStudent').hide();
}
});
function removeStudent() {
var studentList = [];
$(':checkbox[name="removeSelectStudent"]:checked').each(function () {
studentList.push({ BatchParticipantId: this.value });
});
if (studentList.length > 0) {
bootbox.confirm('Do you want to remove student ?', function (r) {
if ('true' == r.toString()) {
$.post("/Batch/RemoveParticipants", JSON.stringify(studentList), function (response) {
if (response == "Succeeded") {
bootbox.alert("Selected Students Removed");
window.location.reload();
}
else {
var msg = response.message ? response.message : "Some error occured.";
bootbox.alert(msg, null);
}
}).error(function () {
bootbox.alert("Some error occured.", null);
});
}
});
}
else {
jAlert("Please select student to remove.");
}
}
//End OF Batch Student Script
function ApplyRequiredRule(className, element) {
var flag = false;
$('.' + className).each(function () {
if (this.value != "") {
flag = true;
}
});
if (flag) {
$('.' + className).each(function () {
$(this).rules('add', 'required');
});
}
else {
$('.' + className).each(function () {
$(this).rules("remove", "required");
$(this).removeClass("input-validation-error");
});
}
}
function saveStudents(ele) {
var formTag = $(ele).closest('form');
$(formTag).find('input, select').each(function () { $(this).rules('remove', 'required'); });
$.validator.unobtrusive.parse('#AddNewStudent');
var flag = !isEmptyForm(formTag);
if (!flag) {
bootbox.alert('At least one record is required.', null);
}
else {
$(formTag).find('input[type="text"],select').each(function () {
if ($.trim(this.value) != '') {
var closestTr = $(this).closest('tr');
$(closestTr).find('input[type="text"],select[id*="Grade"]').each(function () {
$(this).rules('add', { required: true, messages: { required: 'Required.' } });
});
var id = $(this).attr('id');
var PasswordField = id.includes("Password");
//if (!PasswordField) {
// flag = checkUserName(this);
// if (!flag) {
// return false;
// }
//}
if (PasswordField) {
var regex = new RegExp(/^(?=.*[a-z])(?=.*[A-Z])(?=(?:[^0-9]*[0-9]))(?=.*[!"'()*+-/:;<=>?@@{\}^_{|}~.#$%&]).{8,}$/);
flag = regex.test($(this).val());
if (!flag) { return false; }
}
}
});
//$(formTag).find('.txtUserNames').each(function () {
// if ($.trim(this.value) != '') {
// var closestTr = $(this).closest('tr');
// $(closestTr).find('input[type="text"],select').each(function () {
// $(this).rules('add', { required: true, messages: { required: 'Required.' } });
// });
// flag = checkUserName(this.value);
// if (!flag) {
// return false;
// }
// }
//});
if ($(formTag).validate().form() && flag) {
$(formTag).find('#hdnAddNewSubmit').click();
}
}
}
function isEmptyForm(formTag) {
var flag = true;
$(formTag).find('input[type="text"],select').each(function () {
if ($.trim(this.value) != '') {
flag = false;
return false;
}
});
return flag;
}
function checkUserName(ele) {
var val = $.trim($(ele).val());
$(ele).closest('td').find('label.errorMsg').hide();
$(ele).closest('td').find('input').css('border', '1px solid #ccc');
$(ele).closest('td').find('input').css('background-color', '#fff');
if (val != '' && $(ele).valid()) {
$.post('/User/CheckUserNameAvailabilitySync', { id: val }, function (data) {
if (data != "Available") {
$(ele).closest('td').find('label.errorMsg').show();
$(ele).closest('td').find('input').css('border', '1px solid rgba(255, 0, 224, 0.3)');
$(ele).closest('td').find('input').css('background-color', '#ffeeee');
return false;
}
});
}
return true;
}
/*** *** *** BATCH GROUP SCRIPT *** *** ***/
function addNewGroup() {
$("#divModalAddGroup").modal('show');
};
function saveGroup(batchId) {
var formTag = $("#divModalAddGroup").find('form');
$(formTag).attr('action', '/Group/CreateGroup');
if ($(formTag).validate().form()) {
var containingBatch = {
BatchId: batchId
};
var apm = {
UserId_Settable: $("#divModalAddGroup").find('#ddlAPM').val()
};
var schoolManager = {
UserId_Settable: $("#ddlSchoolManager").val()
};
var groupData = {
GroupName: $("#divModalAddGroup").find('#GroupName').val(),
ContainingBatch: containingBatch,
ProductType: $("#divModalAddGroup").find('#GroupProductType').val(),
Description: $("#divModalAddGroup").find('#Description').val(),
CurrentAPM: apm,
OriginalAPM: apm,
SchoolManager: schoolManager
};
$("#divModalAddGroup").modal('hide');
$.ajax({
url: "/Group/CreateGroup",
type: 'post',
contentType: "json",
data: JSON.stringify(groupData),
success: function (data) {
if (data.status == "Succeeded") {
bootbox.alert("Succeeded", function () {
document.getElementById('GroupsSubmit').click();
//$("table tr#trToClone").clone().attr("id", "Group" + data.groupId).show().appendTo("table#GroupTable");
//$("table tr#Group" + data.groupId + " td:first").html(name);
//var addfunc = "javascript:AddStudentToGroup(" + data.groupId + ")";
//$("table tr#Group" + data.groupId + " td:first").append('
');
});
}
else {
bootbox.alert('Some error occurred.', null);
}
},
error: function () {
bootbox.alert('Some error occurred.', null);
}
});
}
}
function editGroup(groupId, groupName, groupDescription, apmId, productType, studentCount, schoolManagerId) {
$("#divModalEditGroup").modal('show');
$("#divModalEditGroup").find('#GroupNameEdit').val(groupName);
$("#divModalEditGroup").find('#DescriptionEdit').val(groupDescription);
var typeSelect = $("#divModalEditGroup").find('#GroupProductTypeEdit');
typeSelect.val(productType);
if (studentCount > 0) {
typeSelect.attr('disabled', 'disabled');
}
else {
typeSelect.removeAttr('disabled');
}
$("#divModalEditGroup").find('#hdnGroupIdForGroupEdit').val(groupId);
$("#divModalEditGroup").find('#ddlAPMEdit').val(apmId);
$("#divModalEditGroup").find('#ddlSchoolManagerEdit').val(schoolManagerId);
};
function updateGroup() {
var formTag = $("#divModalEditGroup").find('#frmEditGroup');
$(formTag).attr('action', '/Group/UpdateGroup');
if ($(formTag).validate().form()) {
var apm = {
UserId_Settable: $("#divModalEditGroup").find('#ddlAPMEdit').val()
};
var schoolManager = {
UserId_Settable: $("#ddlSchoolManagerEdit").val()
};
var groupData = {
GroupId: $("#divModalEditGroup").find('#hdnGroupIdForGroupEdit').val(),
GroupName: $("#divModalEditGroup").find('#GroupNameEdit').val(),
ProductType: $("#divModalEditGroup").find('#GroupProductTypeEdit').val(),
Description: $("#divModalEditGroup").find('#DescriptionEdit').val(),
CurrentAPM: apm,
OriginalAPM: apm,
SchoolManager: schoolManager
};
$("#divModalEditGroup").modal("hide");
$.ajax({
url: "/Group/UpdateGroup",
type: 'post',
contentType: "json",
data: JSON.stringify(groupData),
success: function (data) {
if (data === "Succeeded") {
bootbox.alert("Succeeded", function () {
document.getElementById('GroupsSubmit').click();
});
}
else {
bootbox.alert('Some error occurred.', null);
}
},
error: function () {
bootbox.alert('Some error occurred.', null);
}
});
}
}
function AddStudentToGroup(groupid, pType) {
$(".editFormContent").hide();
$('#hdnGroupIdForMoving').val(groupid);
var batchStudentIds = "";
$('table#ProgramBatchStudentList input:checked:not(.batchDays)').each(function () {
batchStudentIds += this.value + ',';
});
if (batchStudentIds == '')
alert('Select student(s) to move.');
else {
//var div = ("#SelectDaysOfWeekForGroup");
//$('tr#Group' + groupid + ' td:first').append($(div).show());
addStudentToGroup(batchStudentIds, groupid, pType);
}
}
function AddStudentForDays(ele) {
var groupid = $('#hdnGroupIdForMoving').val();
var batchStudentIds = "";
$('table#ProgramBatchStudentList input:checked:not(.batchDays)').each(function () {
batchStudentIds += this.value + ',';
});
var isValid = true;
if (batchdays == "") {
AddStudentToGroup(groupid)
}
returnDays = new Array();
addStudentToGroup(batchStudentIds, groupid);
//addStudentToNewGroup(batchStudentIds, batchdays, groupid, dayArray, uniqueDays);
}
function addStudentToNewGroup(batchStudentIds, batchdays, groupid, dayArray, uniqueDays) {
returnDays = new Array();
if (uniqueDays == undefined) {
addStudentToGroup(batchStudentIds, batchdays, groupid);
}
else if (uniqueDays != undefined && isValidDay(batchdays, dayArray, returnDays)) {
addStudentToGroup(batchStudentIds, batchdays, groupid);
}
else {
alert("You are not allowed to add student on these days: " + returnDays.join(', ') + ". \n Please deallocate tutor and try to add the student.", null);
}
}
function isValidDay(batchDays, dayArray, returnDays) {
for (var j = 0; j < batchDays.length; j++) {
if ($.inArray(batchDays[j], dayArray) < 0) {
returnDays.push(Object.keys(dayOfWeek)[batchDays[j]]);
}
}
if (returnDays.length > 0)
return false;
return true;
}
function addStudentToGroup(batchStudentIds, groupid, pType) {
if (batchStudentIds != '') {
batchStudentIds = batchStudentIds.substring(0, batchStudentIds.length - 1);
if (canStudentBeAdded(batchStudentIds, pType)) {
$.post("/Group/AddStudentToGroup", { id: groupid, batchParticipantIds: batchStudentIds }, function (data) {
if (data == "Succeeded") {
document.getElementById('GroupsSubmit').click();
}
});
}
}
}
function canStudentBeAdded(batchStudentIds, pType) {
participantIds = batchStudentIds.split(',');
var flag = true;
var textToDisplay = "";
for (var i = 0; i < participantIds.length; i++) {
if (+participantIds[i]) {
var div = $('.BatchParticipant' + participantIds[i] + '_' + pType);
if (div && div.length) {
var name = $("#ParticipantName" + participantIds[i]).html();
var groupName = $("#ParticipantGroupName" + participantIds[i] + '_' + pType).val();
textToDisplay = textToDisplay + "
";
flag = false;
}
}
}
if (!flag) {
bootbox.alert(textToDisplay, null);
}
return flag
}
function deleteGroupStudent(divId) {
$(".editFormContent").hide();
$("#" + divId).show();
}
function deleteStudentForDays(ele, batchParticipantId, groupId) {
$.post("/Group/RemoveStudentFromGroup", { id: batchParticipantId, groupId: groupId }, function (data) {
$('#BatchParticipant' + batchParticipantId).remove();
bootbox.alert("Record will be deleted in a few moments from database also.", null);
});
}
function removeGroup(groupId, ele) {
bootbox.confirm('Do you want to remove group?', function (a) {
if (a) {
$.post("/Group/RemoveGroup", { groupId: groupId }, function (status) {
if (status == "Succeeded") {
bootbox.alert("Group removed successfully.", function () {
$(ele).closest('.tab-pane').find('input[name="tabSubmit"]').click();
});
}
});
}
});
}
/*** *** *** End OF BATCH GROUP SCRIPT*** *** ***/
/*** *** *** QUIZ SESSIONS *** *** ***/
function checkDateType(id) {
if (id == "singleDate") {
$('#singleDateContainer').show();
$('#dateRangeContainer').hide();
$('#singleDate').val(true); $('#dtRange').val(false);
$('#hiddenSingleDate').val('1'); $('#hiddenRangeDate').val('0');
}
else if (id == "dtRange") {
$('#singleDateContainer').hide();
$('#dateRangeContainer').show();
$('#singleDate').val(false); $('#dtRange').val(true);
$('#hiddenRangeDate').val('1'); $('#hiddenSingleDate').val('0');
}
}
function searchQuizSessions() {
//if ($('#singleDate:checked').length > 0) {
// $('#singleDate').val(true); $('#dtRange').val(false);
// $('#hiddenSingleDate').val('1'); $('#hiddenRangeDate').val('0');
//}
//if ($('#dtRange:checked').length > 0) {
// $('#singleDate').val(false); $('#dtRange').val(true);
// $('#hiddenRangeDate').val('1'); $('#hiddenSingleDate').val('0');
//}
//$('#hiddenSearchValue').val('1');
$('#pageNumberSessions').val('1');
document.getElementById('btnSubmit').click();
}
function addMultipleSessions() {
if (isProgramOver()) {
bootbox.confirm('This Program Is Over.Do you still want to continue?', function (r) {
if (r) {
MultipleSessionCreateDialog();
}
});
}
else {
MultipleSessionCreateDialog();
}
}
function addUnitTestSessions(batchId, programId) {
$.get('/Batch/GetUnitTestSessionData', { batchId: batchId, programId: programId }, function (data) {
if (null != data) {
//$('#divModalCreateUnitTestSessions, #divModalCreateUnitTestSessions').remove();
//$('body').append(data);
$('#divModalCreateUnitTestSessions').html(data);
$.validator.unobtrusive.parse("#frmUnitTestSessionCreate");
$('#divModalCreateUnitTestSessions').modal('show');
}
});
}
function setUnitTestDate(ele) {
var form = $('#frmUnitTestSessionCreate');
var unitId = $(ele).val();
var programId = $('#programId').val();
var batchId = $('#batchId').val();
$.post('/Batch/GetTestDate', { unitId: unitId, batchId: batchId, programId: programId }, function (data) {
if (null != data.unitTestDate) {
if (data.unitTestDate == "") {
$(form).find('#testDate').val("");
}
else {
$(form).find('#testDate').val($.datepicker.formatDate('mm/dd/yy', new Date(data.unitTestDate)));
GetBatchSlots(batchId);
}
}
});
}
function GetBatchSlots(batchId) {
var form = $('#frmUnitTestSessionCreate');
var testDate = $('#testDate').val();
var productType = $('#productTypeA').val();
if (testDate != undefined && testDate != "" && productType != undefined && productType != "") {
$.post('/Batch/GetBatchSlots', { unitTestDate: testDate, productType: productType, batchId: batchId }, function (data) {
if (null != data.unitStartSLot && null != data.unitEndSlot) {
$(form).find('#startTime').val(data.unitStartSLot);
$(form).find('#endTime').val(data.unitEndSlot);
}
});
}
}
function SaveUnitTestSession() {
var formTag = $('#frmUnitTestSessionCreate');
var validator = $(formTag).validate();
var isValid = validator.form();
if (isValid) {
if ($(formTag).find('input[name=participantId]:checked').length > 0) {
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText.status == 'Succeeded') {
bootbox.alert("Succeeded", function () {
$('#divModalCreateUnitTestSessions').modal('hide');
});
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
else {
bootbox.alert("Select atleast one participant.", null);
}
}
}
function MultipleSessionCreateDialog() {
$("#divModalCreateSessions").modal('show');
$("#divModalCreateSessions").find('input[type="text"], select').each(function () { $(this).val(''); });
$("#divModalCreateSessions :checkbox:checked").trigger('click');
$(':radio[name="selectScheduling"]:first').click();
}
function AddQuzzesToSessions() {
var sessions = [];
var programid = document.getElementById("hdnProgramId").value;
$('input[name=selectorForAction]:checked').each(function () {
sessions.push(this.id);
});
if (sessions.length > 0) {
$("#divModalAddSessionForQuiz").modal('show');
$("#divModalAddSessionForQuiz").find('#hiddenSessionToAdd').val(sessions);
}
else
bootbox.alert('Select at least one student', null);
}
function assignQuizToSession(batchId, programId) {
var batchId = batchId;
var quizList = [];
$("#divModalAddSessionForQuiz").find('input[class=checkdQuiz]:checked').each(function () { quizList.push(this.id); });
var isCalAllowed = [];
$("#divModalAddSessionForQuiz").find('input[class=allowCalculator]:checked').each(function () { isCalAllowed.push(this.id); });
var gradedQuiz = [];
$("#divModalAddSessionForQuiz").find('input[class=IsGraded]:checked').each(function () { gradedQuiz.push(this.id); });
var programId = programId;
var listOfSessions = $("#divModalAddSessionForQuiz").find('#hiddenSessionToAdd').val();
if (quizList.length > 0) {
$("#divModalAddSessionForQuiz").modal('hide');
var postData = { id: listOfSessions, programId: programId, quizList: quizList.join(','), allowCal: isCalAllowed.join(','), isGraded: gradedQuiz.join(','), batchId: batchId };
$.post('/Session/AddQuizToSession', postData, function (result) {
if (parseInt(result) == 1) {
refreshQuizSessionView();
}
else {
bootbox.alert('Some Error Occured While Assigning the Quiz', null);
}
});
}
else
bootbox.alert('Select at least one Quiz', null);
}
function cancelSession(ele, sessionStatus) {
var sessionsToCancel = [];
$(ele).closest('table').find('input[name=selectorForAction]:checked').each(function () {
sessionsToCancel.push(this.id);
});
if (sessionsToCancel.length > 0) {
bootbox.confirm('Are you sure you want to Cancel?', function (data) {
if (data) {
$.post("/Session/CancelQuizSession/", { sessionsToCancel: sessionsToCancel.join(','), sessionStatus: sessionStatus }, function (data1) {
bootbox.alert(data1, function () { refreshQuizSessionView(); });
});
}
});
}
else {
bootbox.alert('Select Atleast one session to Cancel', null);
}
}
function undoCancel(ele, activeSessionStatusId, cancelledSessionStatusId) {
var sessionsToCancel = [];
$(ele).closest('table').find('input[name=selectorForAction]:checked').each(function () {
if ($(this).attr('sessionStatus') == cancelledSessionStatusId)
sessionsToCancel.push(this.id);
});
if (sessionsToCancel.length > 0) {
bootbox.confirm('Are you sure you want to re-activate?', function (data) {
if (data) {
$.post("/Session/CancelQuizSession/", { sessionsToCancel: sessionsToCancel.join(','), sessionStatus: activeSessionStatusId }, function (data1) {
bootbox.alert(data1, function () { refreshQuizSessionView(); });
});
}
});
}
else {
bootbox.alert('Select Atleast one session to Cancel', null);
}
}
function setPracticeNumber() {
var type = document.getElementById("sessionType").value;
if (type == '2' || type == '3' || type == '4') {
document.getElementById("numDrillSession").value = '1';
document.getElementById("numDrillSession").disabled = true;
}
else {
document.getElementById("numDrillSession").disabled = false;
document.getElementById("numDrillSession").value = '';
}
}
function editQuizSession(ele, seesionId) {
$(ele).closest('tr').find('.noEdit' + seesionId).each(function (data) {
$(this).hide();
});
$(ele).closest('tr').find('.edit' + seesionId).each(function (data) {
$(this).show();
});
}
function cancelEdit(ele, sessionId) {
$(ele).closest('tr').find('.noEdit' + sessionId).each(function (data) {
$(this).show();
});
$(ele).closest('tr').find('.edit' + sessionId).each(function (data) {
$(this).hide();
});
}
function saveFields(ele, sessionId, sessionStatus, studentId) {
var sessionType = $(ele).closest('tr').find('#editSessionType' + sessionId).val();
var productType = $(ele).closest('tbody').find('#productType').val();
if (productType == 1) { //ContentDeliveryType : legacy = 2,Genesis = 1 | ProduuctType : Tier 1 = 2,Tier 2 = 1
var unitId = $(ele).closest('tr').find('#editSessionUnit' + sessionId).val();
}
else {
var unitId = $(ele).closest('tr').find('#courseUnit' + sessionId).val();
}
$.post("/Session/EditQuizSession/", { sessionId: sessionId, sessionType: sessionType, unitId: unitId, productType: productType }, function (data) {
if (data == 'Succeeded') {
bootbox.alert(data, function () { refreshQuizSessionView(); });
}
else {
bootbox.alert(data, function () { cancelEdit(sessionId); });
}
});
}
function refreshQuizSessionView() {
$('#ReScheduleSession').remove();
$('#AddSessionForQuiz').remove();
$('#createMultipleSession').remove();
document.getElementById('QuizSessionsSubmit').click();
}
function RemoveQuiz(quizId, sessionId) {
bootbox.confirm('Are you sure you want to delete?', function (data) {
if (data) {
$.post("/Session/RemoveQuiz/", { quizId: quizId, sessionId: sessionId }, function (data) {
if (parseInt(data) == 1) {
refreshQuizSessionView();
}
else {
bootbox.alert('Some Error Occurred while Deleting this Student', null);
}
});
}
});
}
function removeSessions() {
var studentSessionString = [];
$('input[name=selectorForAction]:checked').each(function () {
studentSessionString.push(this.id);
});
if (studentSessionString.length < 1) {
bootbox.alert('Select atleast one Quiz session', function () { return; });
}
else {
var postData = { studentSessionString: studentSessionString };
bootbox.confirm('Are you sure you want to remove these sessions?', function (r) {
if (r) {
$.ajax({
type: "POST",
url: '/Session/DeleteQuizSessions',
data: postData,
success: function (result) {
if (result == 1) {
bootbox.alert('Sessions is Removed', function () {
refreshQuizSessionView();
});
}
else {
bootbox.alert('Sessions Cannot be removed as It is Already taken', function () {
refreshQuizSessionView();
});
}
},
traditional: true
});
}
});
}
}
function unsubmitQuiz(quizId, quizSessionId, studentId) {
bootbox.confirm('Are you sure you want to unsubmit this quiz?', function (data) {
if (data) {
$.post('/Session/UnSubmitQuiz', { quizId: quizId, quizSessionId: quizSessionId, studentId: studentId }, function (data1) {
if (data1 == 1) {
refreshQuizSessionView();
}
else {
bootbox.alert('Some error occured', null);
}
});
}
});
}
function submitQuiz(quizId, quizSessionId, studentId) {
bootbox.confirm('Are you sure you want to submit this quiz?', function (data) {
if (data) {
$.post('/Session/SubmitQuiz', { quizId: quizId, quizSessionId: quizSessionId, studentId: studentId }, function (data1) {
if (data1 == 1) {
refreshQuizSessionView();
}
else {
bootbox.alert('Some error occured', null);
}
});
}
});
}
function pagingSessionList(Id) {
document.getElementById('pageNumberSessions').value = Id.toString();
//document.getElementById('hiddenSearchValue').value = 0;
document.getElementById('btnSubmit').click();
};
function toggleSelectingQuizParticipants(ele, isChecked) {
$(ele).closest('table').find('input[class=selectParticipants]').each(function () {
this.checked = isChecked;
});
}
function submitCreateQuizSessionForm(formTag) {
if ($(formTag).find('input[name*="participantName_"]:checked').length > 0) {
if ($(formTag).validate().form()) {
$(formTag).closest('.modal').modal('hide');
$(formTag).ajaxSubmit({
success: function (data) {
refreshQuizSessionView();
},
error: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
}
else {
bootbox.alert('Select participant', null);
}
}
function checkSession(ele) {
$(ele).closest('.modal').find('#quizCreateTable').find('tr.showHide').show();
if (ele.checked && ele.value == "0") {
var dateInput = $(ele).closest('.modal').find('input[name="effectiveDate"]');
dateInput.closest('tr').hide();
dateInput.val('');
var countInput = $(ele).closest('.modal').find('input[name="numDrillSession"]');
countInput.closest('tr').hide();
countInput.val(1);
}
else if (ele.checked && ele.value == "1") {
var startTimeInput = $(ele).closest('.modal').find('input[name="startTime"]');
startTimeInput.closest('tr').hide();
startTimeInput.val('');
var endTimeInput = $(ele).closest('.modal').find('input[name="endTime"]');
endTimeInput.closest('tr').hide();
endTimeInput.val('');
var productTypeInput = $(ele).closest('.modal').find('select[name="productType"]');
productTypeInput.closest('tr').hide();
productTypeInput.val('');
}
}
/*** *** *** End OF QUIZ SESSION SCRIPT *** *** ***/
/*** *** *** Allocate and deallocate related*** *** ***/
function getAllocationPopup(batchId, allocate, classPeriodId) {
$.get('/Group/AllocationPopup', { batchId: batchId, popupFor: allocate, classPeriodId: classPeriodId }, function (data) {
if (null != data) {
$('#divAllocationModal').remove();
$('body').append(data);
$('#divAllocationModal').modal('show');
$.validator.unobtrusive.parse('#divAllocationModal');
}
});
}
function setAllocations(element, batchId, popupFor) {
$form = $(element).closest('form');
var action = popupFor == 0 ? "/Group/SetGroupTutorAllocation?batchId=" + batchId : "/Group/RemoveGroupTutorAllocation?batchId=" + batchId;
if ($form.validate().form()) {
$.post(action, $form.serialize(), function (data) {
var groupId = $('#allocationGroup').val();
$('#divAllocationModal').modal('hide');
$('#groupCalLink_' + groupId).click();
});
}
}
function addDateRange(ele, withDefault) {
var addCount = Number($('#hdnDateRangeCount').val()); addCount = addCount + 1; $('#hdnDateRangeCount').val(addCount);
var trToClone = $('#rangeCloneDiv').clone();
$(trToClone).removeAttr('id').show(); $('#rangeContainer').append(trToClone);
$.validator.unobtrusive.parse('#frmTutoAllocation');
$(trToClone).find(':input').each(function () {
if (this.id != undefined && this.id != '') {
var newId = this.id + addCount;
$(this).attr('id', newId).attr('name', newId);
}
});
$(trToClone).find('span[data-valmsg-for]').each(function () {
var msgfor = $(this).attr('data-valmsg-for');
msgfor = msgfor + addCount;
$(this).attr('data-valmsg-for', msgfor);
});
$(trToClone).find('input[id*="txtFromDate_"],input[id*="txtToDate_"]').each(function () {
$(this).rules("add", {
required: true,
messages: {
required: "Required"
}
});
});
$(trToClone).find(':checkbox[id*="w1txtDay_"],:checkbox[id*="w2txtDay_"]').each(function () {
$(this).rules("add", {
required: function (element) {
if ($(element).attr('id').indexOf('w1txtDay_') > -1) {
return $(trToClone).find(':checkbox[id*="w2txtDay_"]:checked').length == 0;
}
else {
return $(trToClone).find(':checkbox[id*="w1txtDay_"]:checked').length == 0;
}
},
messages: {
required: "Required"
}
});
});
if (withDefault) {
var startDate = $(trToClone).find('input[data-date-start-date]').attr('data-date-start-date');
var endDate = $(trToClone).find('input[data-date-end-date]').attr('data-date-end-date');
setStartEndDate($(trToClone).find('input[id*="txtFromDate_"]'), $(trToClone).find('input[id*="txtToDate_"]'));
//$(trToClone).find('.input-daterange').datepicker({startDate: startDate, endDate: endDate, orientation: 'bottom auto'});
}
else {
var startDate = moment(new Date()).format('MM/DD/YYYY');
var endDate = moment(new Date()).format('MM/DD/YYYY');
endDate = moment(endDate).add(6, 'months');
endDate = moment(endDate).format('MM/DD/YYYY');
setStartEndDateSixMonth($(trToClone).find('input[id*="txtFromDate_"]'), $(trToClone).find('input[id*="txtToDate_"]'), startDate, endDate);
}
$(trToClone).find(':checkbox').each(function () {
var $this = $(this);
$this.click(function () {
if ($this.hasClass('allChk')) {
$this.closest('ul').find('.chk').each(function () {
this.checked = $this.attr('checked');
});
}
else {
var allChecked = this.checked;
if (allChecked) {
$this.closest('ul').find('.chk').each(function () {
if (allChecked) {
allChecked = this.checked;
}
});
}
$this.closest('ul').find('.allChk').attr('checked', allChecked);
}
});
});
showHideRemoveLink()
}
function removeDateRange(ele) {
$(ele).closest('.rangeRow').remove();
showHideRemoveLink()
}
function showHideRemoveLink() {
var rangeCount = $('.rangeRow').length;
if (rangeCount == 2) {
$('.removeRange').hide();
}
else {
$('.removeRange').show();
}
}
function showSchedulePopUp(programId) {
$.post('/Session/CanScheduleVCR', { programId: programId }, function (data) {
if (data == "False") {
bootbox.alert('Please create LSP before creating the session.', null);
}
else {
$('#scheduleVcsModal').modal('show');
}
});
}
/*** *** ***End of Allocate and deallocate related*** *** ***/
/****************Allocations overall calendar**********************************/
function getNextMonth() {
var month = $('#allocationMonth').val();
var year = $('#allocationYear').val();
month++;
if (month > 12) {
month = 1;
year++;
}
$('#allocationMonth').val(month);
$('#allocationYear').val(year);
$('#AllocationsSubmit')[0].click();
}
function getPrevMonth() {
var month = $('#allocationMonth').val();
var year = $('#allocationYear').val();
month--;
if (month < 1) {
month = 12;
year--;
}
$('#allocationMonth').val(month);
$('#allocationYear').val(year);
$('#AllocationsSubmit')[0].click();
}
function getMonth(month, year) {
$('#allocationMonth').val(month);
$('#allocationYear').val(year);
$('#AllocationsSubmit')[0].click();
}
/**********************Allocations overall calendar end***********************************/
/************Individual group calendar****************/
function getGroupCalendar(element, groupId, batchId) {
$(element).closest('table').find('tr').removeClass("yellowBackground");
$(element).closest('tr').addClass("yellowBackground");
$.post("/Group/GetAllocationCalendar", { id: groupId, batchId: batchId }, function (data) {
$('#divGroupCalendarModal').html(data);
});
}
/************End of Individual group calendar****************/
/*** *** *** RESCHEDULE TIME *** *** ***/
function RescheduleQuizSession(batchId) {
var sessionIds = [];
$('input[name=selectorForAction]:checked').each(function () {
sessionIds.push(this.id);
});
if (sessionIds.length > 0) {
setDatepicker($("#divModalRescheduleSession").find("#dateText"));
$("#divModalRescheduleSession").modal('show');
$(".time-picker").css({ 'z-index': '9999' });
setStartEndTimePicker($("#divModalRescheduleSession").find('#satrttimeText'), $("#divModalRescheduleSession").find('#endtimeText'));
$("#divModalRescheduleSession").find('input[name="hdnBatchId"]').val(batchId);
$("#divModalRescheduleSession").find('#hdnSessionIds').val(sessionIds);
}
else
bootbox.alert('Select at least one student', null);
}
function FormSubmitReSchedule() {
var batchId = $("#divModalRescheduleSession").find('input[name="hdnBatchId"]').val();
var sessionIds = $("#divModalRescheduleSession").find('#hdnSessionIds').val();
var newDate = $("#divModalRescheduleSession").find('#dateText').val();
var newStartTime = $("#divModalRescheduleSession").find('#satrttimeText').val();
var newEndTime = $("#divModalRescheduleSession").find('#endtimeText').val();
var formTag = $("#divModalRescheduleSession").find('form');
if ($(formTag).validate().form()) {
$('#divModalRescheduleSession').modal('hide');
var postData = { lstSessionIds: sessionIds, newDate: newDate, newStartTime: newStartTime, newEndTime: newEndTime, batchId: batchId };
$.ajax({
type: "POST",
url: '/Session/ReScheduleQuizSession',
data: postData,
success: function (result) {
refreshQuizSessionView();
},
traditional: true
});
}
};
function rescheduleChangeTime() {
var startTime = document.getElementById("satrttimeText").value;
var date = document.getElementById("dateText").value;
var oldTime = new Date(date + " " + startTime);
var newTime = new Date(date + " " + (oldTime.getHours() + 1) + ":" + oldTime.getMinutes());
var prefix = "AM";
if (newTime.getMinutes() == 0)
var Minutes = "00";
else
var Minutes = newTime.getMinutes();
if ((newTime.getHours() >= 13) && (newTime.getHours() <= 24)) {
prefix = "PM";
var requiredTime = (newTime.getHours() - 12) + ":" + Minutes + " " + prefix;
document.getElementById("endtimeText").value = requiredTime;
}
else if ((newTime.getHours() >= 1) && (newTime.getHours() <= 12)) {
var requiredTime = newTime.getHours() + ":" + Minutes + " " + prefix;
document.getElementById("endtimeText").value = requiredTime;
}
};
/*** *** *** END OF RESCHEDULE TIME *** *** ***/
/*** *** *** TUTORING SESSIONS SCRIPT *** *** ***/
function addMultipleTutoringSessions(batchId) {
if (isProgramOver()) {//Function in main view
bootbox.confirm('This Program Is Over.Do you still want to continue?', function (r) {
if ('true' == r.toString())
MultipleTutoringSessionCreateDialog(false, batchId);
});
}
else
MultipleTutoringSessionCreateDialog(false, batchId);
}
function addMultipleSessionScheduling(programId, batchId) {
$.post('/Session/CanScheduleVCR', { programId: programId }, function (data) {
if (data == "False") {
bootbox.alert('Please create LSP before creating the session.', null);
}
else {
if (isProgramOver()) {//Function in main view
bootbox.confirm('This Program Is Over.Do you still want to continue?', function (r) {
if ('true' == r.toString())
MultipleTutoringSessionCreateDialog(true, batchId);
});
}
else
MultipleTutoringSessionCreateDialog(true, batchId);
}
});
}
function MultipleTutoringSessionCreateDialog(scheduleVCR, batchId) {
if (scheduleVCR)
$('#frmTutoringSession').attr('action', '/Session/QuickTutoringSessionCreate/' + batchId);
else
$('#frmTutoringSession').attr('action', '/Session/TutoringSessionCreate/' + batchId);
$("#createMultipleTutoringSession").modal('show');
setDatepicker($("#createMultipleTutoringSession").find("#effectiveDateTutoring"));
}
function submitCreateSessions(ele) {
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1;
var yyyy = today.getFullYear();
if (dd < 10) {
dd = '0' + dd;
}
if (mm < 10) {
mm = '0' + mm;
}
today = mm + '/' + dd + '/' + yyyy;
var check = false;
$('input[name=selectedStudentForTutoring]:checked').each(function () {
check = true;
});
if (check && $("#schoolManager").val() !== "") {
var formTag = $(ele).closest('form');
if ($(formTag).validate().form()) {
if ($("#effectiveDateTutoring").val() >= today) {
$("#createMultipleTutoringSession").modal('hide');
$(formTag).ajaxSubmit({
success: function (data) {
bootbox.alert('Submitted for creating sessions.', function () { refreshTutoringSessionView(); });
},
error: function (data) {
bootbox.alert('Some error occurred', null);
}
});
}
else {
bootbox.alert("Selected date is passed, please select valid session date!", null);
}
}
}
else {
if (!check)
bootbox.alert("Please select atleast one participant!", null);
else
bootbox.alert("Please select school manager!", null);
}
}
function submitCreateSessionsNew(ele) {
var formTag = $(ele).closest('form');
if ($(formTag).validate().form()) {
$("#createMultipleTutoringSessionNew").modal('hide');
$(formTag).ajaxSubmit({
success: function (data) {
bootbox.alert('Submitted for creating sessions.', function () { refreshTutoringSessionView(); });
},
error: function (data) {
bootbox.alert('Some error occurred', null);
}
});
}
}
function toggleSelectionTutoringParticipants(isChecked) {
$('input[name=selectedStudentForTutoring]').each(function () {
this.checked = isChecked;
});
}
function assignClassroom(ele) {
var batchId = $('#assignTutorModal').find('#hdnBatchIdForAssigningTutor').val();
$('#sortable').sortable({
tolerance: 'pointer',
revert: 'invalid',
placeholder: 'well-sm',
forceHelperSize: true
});
var sortedListIds = new Array();
var sessionIds = new Array();
$('#tblTutoringSession').find('input[name=selectorForAction]:checked').each(function () {
if ($(this).attr('sessionId') != '')
sessionIds.push($(this).attr('sessionId'));
});
if (sessionIds.length < 1) {
bootbox.alert('Select atleast one session', null);
return;
}
$('#sortable li').each(function () {
sortedListIds.push(this.id.split('_')[1]);
});
$('#assignTutorModal').modal('hide');
$.post('/Session/AssignClassRoomToBatch/', { batchId: batchId, priorityCSV: sortedListIds.join(','), sessionCSV: sessionIds.join(',') }, function (data) {
bootbox.alert('Submitted for assigning', function () { refreshTutoringSessionView(); });
});
}
function scheduleVCRForSelected(ele) {
var VCrIds = [];
var $modal = $(ele).closest('.modal');
$('#tblTutoringSession').find('input[name=selectorForAction]:checked').each(function () {
if (this.value != errorValue)
VCrIds.push(this.value);
});
if (VCrIds.length < 1) {
bootbox.alert('Select atleast one session for which classroom is assigned', null);
return;
}
else {
var recordSession = $modal.find('#chkRecordVCR:checked').length > 0 ? true : false;
$(ele).closest('.modal').modal('hide');
var postData = { vcrIDs: VCrIds, recordSession: recordSession };
$.ajax({
type: "POST",
url: '/Session/ScheduleVCRS',
data: postData,
success: function (result) {
bootbox.alert('VCR will be scheduled for sessions for which classroom is assigned', function () {
refreshTutoringSessionView();
});
},
traditional: true
});
}
}
function removeTSessionForSelected() {
let sessionTimelogs = [];
var studentSessionString = [];
$('input[name=selectorForAction]:checked').each(function () {
VCRstatus = $(this).attr('status');
studentSessionString.push(this.id);
var startDateTime = $(this).attr('startDateTime');
sessionTimelogs.push(startDateTime);
});
if (studentSessionString.length < 1) {
bootbox.alert('Select atleast one session', null);
return;
}
$.post('/Session/ValidateSessionCancellationTime', JSON.stringify(sessionTimelogs), function (data) {
if (data != "False") {
bootbox.confirm('Please confirm that the Instructor will be paid for the session.?', function (r) {
if ('true' == r.toString())
deleteStudentTutoringSessions(studentSessionString, true);
else
deleteStudentTutoringSessions(studentSessionString, false);
});
}
else {
deleteStudentTutoringSessions(studentSessionString, false);
}
});
}
function deleteStudentTutoringSessions(studentSessionString, isInstructorPayable) {
bootbox.confirm('Are you sure you want to remove these sessions?', function (r) {
if (r) {
$.ajax({
type: "POST",
url: '/Session/DeleteStudentTutoringSessions',
data: postData,
data: { studentSessionString: studentSessionString, isInstructorPayable: isInstructorPayable },
success: function (result) {
alert('Sessions will be removed');
refreshTutoringSessionView();
},
traditional: true
});
}
});
}
function cancelVCRForSelected() {
var VCrIds = [];
let sessionTimelogs = [];
$('input[name=selectorForAction]:checked').each(function () {
var startDateTime = $(this).attr('startDateTime');
if (this.value != errorValue) {
VCrIds.push(this.value);
sessionTimelogs.push(startDateTime);
}
});
if (VCrIds.length < 1) {
bootbox.alert('Select atleast one session for which classroom is assigned', null);
return;
}
$.post('/Session/ValidateSessionCancellationTime', JSON.stringify(sessionTimelogs), function (data) {
if (data != "False") {
bootbox.confirm('Please confirm that the Instructor will be paid for the session.?', function (r) {
if ('true' == r.toString())
cancelVCRs(VCrIds, true);
else
cancelVCRs(VCrIds, false);
});
}
else {
cancelVCRs(VCrIds, false);
}
});
}
function cancelVCRs(VCrIds, isInstructorPayable) {
bootbox.confirm('Are you sure you want to cancel VCR for these sessions?', function (r) {
if (r) {
$.ajax({
type: "POST",
url: '/Session/CancelVCRs',
data: postData,
data: { vcrIDs: VCrIds, isInstructorPayable: isInstructorPayable },
success: function (result) {
bootbox.alert('VCR will be cancelled for sessions for which classroom is assigned', function () { refreshTutoringSessionView(); });
},
traditional: true
});
}
});
}
function openReschedulePop(ele, batchId) {
var studentSessionString = [];
var uniqueSessionString = [];
$('#tblTutoringSession').find('input[name=selectorForAction]:checked').each(function () { studentSessionString.push(this.id); if (uniqueSessionString.indexOf(this.id.split('_')[1]) == -1) { uniqueSessionString.push(this.id.split('_')[1]); } });
if (studentSessionString.length < 1) {
bootbox.alert('Select atleast one session', null);
return;
}
else {
$('#rescheduleSessionModal').modal('show');
$('#rescheduleSessionModal').find('#hdnBatchIdForReschdulingSession').val(batchId);
document.getElementById('hdnStudentSessionString').value = studentSessionString.join(',');
document.getElementById('hdnUniqueSessionIds').value = uniqueSessionString.join(',');
}
}
function openQuickReschedule(batchId, utcOffset) {
$.get('/Session/GetQuickReScheduleTutoringSessions', { batchId: batchId, utcOffset: utcOffset }, function (data) {
if (data !== '') {
$('#RunningSessionDiv').html(data);
$.validator.unobtrusive.parse("#frmQuickRescheduleTutoringSession");
$('#quickRescheduleSessionModal').modal('show');
$("#selectSession option:selected").prop("selected", false);
$("#selectSession").multiselect('refresh');
$("#quickRescheduleTbl > tbody").html(""); quickReScheduleArray = []; $('#quickRescheduleRecords').val(quickReScheduleArray.length);
}
});
}
function removeSelectedQuickReSchedule(ele) {
var rowId = $(ele).attr('id').split('_')[1];
var sessionId = $('#trId_' + rowId).attr('sessionId');
quickReScheduleArray.splice(quickReScheduleArray.indexOf(sessionId), 1);
$('#trId_' + rowId).remove();
$('#quickRescheduleRecords').val(quickReScheduleArray.length);
}
function addSelectedSessions() {
var sessionsArray = $('#selectSession').val();
var tr = $('#quickRescheduleTbl thead').find('#trId_0');
for (let i = 0; i < sessionsArray.length; i++) {
var sessionId = sessionsArray[i].split('_')[0];
var sessionText = sessionsArray[i].split('_')[1];
if (quickReScheduleArray.length === 0 || quickReScheduleArray.indexOf(sessionId) < 0) {
quickReScheduleArray.push(sessionId); var addCount = i + 1;
var trToClone = $(tr).clone(); $(trToClone).attr('id', 'trId_' + addCount);
$(trToClone).attr('sessionId', sessionId); $(trToClone).find('input[id*="hdnSessionIdForQR_"]').val(sessionId);
$(trToClone).find('span[id*="sessionTd_"]').text(sessionId);
$(trToClone).find('span[id*="currentScheduleTd_"]').text(sessionText);
$(trToClone).show();
$('#selectedSessionTbody').append(trToClone);
$(trToClone).find(':input,a,span').each(function () {
if (this.id != undefined && this.id != '') {
var newId = this.id.split('_')[0] + "_" + addCount;
$(this).attr('id', newId).attr('name', newId);
}
});
setDatepicker($(trToClone).find('input[id*="rescheduleDate_"]'));
if (sessionText != "") {
var dateString = sessionText.split(",")[0].length > 0 ? sessionText.split
(",")[0] : "";
var dateParts = dateString.split("/");
// var dateParts = dateString.split("-"); -- FOR LOCAL
// month is 0-based, that's why we need dataParts[1] - 1
var dateFormat = new Date(+dateParts[2], dateParts[0] - 1, +dateParts[1]);
//var dateFormat = new Date(+dateParts[2], dateParts[1] - 1, +dateParts[0]); -- FOR LOCAL
var day = dateFormat.getDate(); var month = dateFormat.getMonth(); var year = dateFormat.getFullYear();
$(trToClone).find('input[id*="rescheduleDate_"]').val((month + 1) + "/" + day + "/" + year);
}
setStartEndTimePicker($(trToClone).find('input[id*="txtFromTime_"]'), $(trToClone).find('input[id*="txtToTime_"]'));
$(trToClone).find('span[data-valmsg-for]').each(function () {
var msgfor = $(this).attr('data-valmsg-for');
msgfor = msgfor + addCount;
$(this).attr('data-valmsg-for', msgfor);
});
$(trToClone).find('input[id*="txtFromTime_"],input[id*="txtToTime_"]').each(function () {
$(this).rules("add", {
required: true,
messages: {
required: "Required"
}
});
});
}
}
$('#quickRescheduleRecords').val(quickReScheduleArray.length);
}
function copyToAll() {
if ($('#trId_' + 1) != undefined) {
// var date = $('#trId_' + 1).find('input[id*="rescheduleDate_"]').val();
var fromTime = $('#trId_' + 1).find('input[id*="txtFromTime_"]').val();
var toTime = $('#trId_' + 1).find('input[id*="txtToTime_"]').val();
for (var i = 2; i <= $('#selectedSessionTbody tr').length; i++) {
if ($('#trId_' + i) != undefined) {
// $('#trId_' + i).find('input[id*="rescheduleDate_"]').val(date);
$('#trId_' + i).find('input[id*="txtFromTime_"]').val(fromTime);
$('#trId_' + i).find('input[id*="txtToTime_"]').val(toTime);
}
}
}
}
function submitQuickRescheduleSessions(ele) {
var $modal = $(ele).closest('.modal');
var formTag = $modal.find('form');
if ($(formTag).validate().form()) {
$.post("/Session/QuickReScheduleTutoringSessions", $(formTag).serialize(), function (data) {
$('#quickRescheduleSessionModal').modal('hide');
bootbox.alert('Sessions submitted for re-scheduling', function () {
refreshTutoringSessionView();
});
});
}
}
function submitRescheduleSessions(ele) {
var $modal = $(ele).closest('.modal');
var formTag = $modal.find('form');
if ($(formTag).validate().form()) {
$.post($(formTag).attr('action'), $(formTag).serialize(), function (data) {
$('#rescheduleSessionModal').modal('hide');
bootbox.alert('Sessions submitted for scheduling', function () {
refreshTutoringSessionView();
});
});
}
}
function changeLockStatus(isToBeLocked) {
var VCRIds = new Array();
$('input[name=selectorForAction]:checked').each(function () {
VCRIds.push(this.value);
});
if (VCRIds.length < 1) {
bootbox.alert('Select atleast one session', null);
return;
}
$.post('/Session/ChangeRoomLockStatus/', { VCRCSV: VCRIds.join(','), isToBeLocked: isToBeLocked }, function (data) {
bootbox.alert(data, function () { refreshTutoringSessionView(); });
});
}
function changeTutoringSearchCriteria(ddlValue) {
$('.searchByDateContainer').hide();
if (ddlValue == 'SingleDate') {
$('#singleDateForsearchTutoringSessions').css('display', 'inline');
$('#dateRangeforsearchTutoringSessions').css('display', 'none');
}
else if (ddlValue == 'DateRange') {
$('#dateRangeforsearchTutoringSessions').css('display', 'inline');
$('#singleDateForsearchTutoringSessions').css('display', 'none');
}
}
function refreshTutoringSessionView() {
document.getElementById('TutoringSessionsSubmit').click();
}
/*** *** *** END OF TUTORING SESSION SCRIPT *** *** ***/
function updateConfiguredReports(batchId) {
bootbox.confirm('Are you sure you want to update configuration?', function (r) {
if (r) {
var reportsToDisplay = new Array();
$('#divConfiguratipnChkBoxes input[type="checkbox"]:checked').each(function () {
reportsToDisplay.push(this.value);
});
var consolidatedTitle = $('#divConfiguratipnChkBoxes input[type="text"]:first').val();
$.post('/Batch/UpdateBatchReportConfiguration', { id: batchId, strReportTypes: reportsToDisplay.join(','), consolidatedTitle: consolidatedTitle },
function (data) {
bootbox.alert(data, function () { refreshReportView(); });
});
}
else {
refreshReportView();
}
});
}
function refreshReportView() {
document.getElementById('ReportsSubmit').click();
}
function updateTeachingPlanSchedule(tabName) {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
$.post('/Program/UpdateTeachingPlanBatchSchedule?id=' + batchId + '&programId=' + programId + '&tabName=' + tabName, function (data) {
if (data == 'Succeeded') {
if (tabName == 'Topic') {
$.post('/Program/TopicSchedule?id=' + batchId + '&programId=' + programId, function (res) {
if (res != '') {
$('#TopicScheduleDiv').html(res);
}
});
}
else {
$.post('/Program/AssessmentSchedule?id=' + batchId + '&programId=' + programId, function (res) {
if (res != '') {
$('#AssessmentScheduleDiv').html(res);
}
});
}
}
});
}
function saveTopicScheduleRow(ele, teachingPlanId, UnitId, dispSeq) {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
var formTag = ('#' + $(ele).closest('form').attr('id'));
$(formTag).attr('action', '/Program/SaveTopicSchedule?teachingPlanId=' + teachingPlanId + '&batchId=' + batchId + '&programId=' + programId + '&UnitId=' + UnitId + '&dispSeq=' + dispSeq);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText == 'Succeeded') {
bootbox.alert("Succeeded", function () {
$.post('/Program/TopicSchedule?id=' + batchId + '&programId=' + programId, function (res) {
if (res != '') {
$('#TopicScheduleDiv').html(res);
}
});
});
}
else {
bootbox.alert("Some error occurred.", null);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function editTopicScheduleRow(rowId, teachingPlanId, UnitId) {
$('#' + rowId + ' .editClass').hide();
$('#etcDate_' + teachingPlanId).hide();
$('#' + rowId + ' .saveClass').show();
$('#topicSchd #txtETCDate_' + teachingPlanId).show();
}
function cancelTopicScheduleRow(rowId, teachingPlanId, UnitId) {
$('#' + rowId + ' .editClass').show();
$('#etcDate_' + teachingPlanId).show();
$('#' + rowId + ' .saveClass').hide();
$('#topicSchd #txtETCDate_' + teachingPlanId).hide();
}
function EditAllTopicSchedule() {
$('.etcDate').hide();
$('#btnEditAllTopicSchedule').hide();
$('.txtdate').show();
$('#btnSaveAllTopicSchedule').show();
$('#btnCancelAllTopicSchedule').show();
}
function SaveAllTopicSchedule(ele) {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
var formTag = ('#' + $(ele).closest('form').attr('id'));
$(formTag).attr('action', '/Program/SaveTopicSchedule?teachingPlanId=' + -999 + '&batchId=' + batchId + '&programId=' + programId + '&UnitId=' + -999 + '&dispSeq=' + -999);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText == 'Succeeded') {
bootbox.alert("Succeeded", function () {
$(formTag).attr('action', '/Program/TopicSchedule?id=' + batchId + '&programId=' + programId);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (data) {
if (data != '') {
$('#TopicScheduleDiv').html(data);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
//$.post('/Program/TopicSchedule?id=' + batchId + '&programId=' + programId, function (res) {
// if (res != '') {
// $('#TopicScheduleDiv').html(res);
// }
//});
});
}
else {
bootbox.alert("Some error occurred.", null);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function resetTopicSchedule(ele) {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
var formTag = ('#' + $(ele).closest('form').attr('id'));
$(formTag).attr('action', '/Program/TopicSchedule?id=' + batchId + '&programId=' + programId);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText != '') {
$('#TopicScheduleDiv').html(responseText);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function updateAssessmentSchedule() {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
$.post('/Program/UpdateQuizSchedule?id=' + batchId + '&programId=' + programId, function (data) {
if (data == 'Succeeded') {
$.post('/Program/AssessmentSchedule?id=' + batchId + '&programId=' + programId, function (res) {
if (res != '') {
$('#AssessmentScheduleDiv').html(res);
}
});
}
});
}
function saveAssessmentScheduleRow(ele, QuizScheduleId, UnitId) {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
var formTag = ('#' + $(ele).closest('form').attr('id'));
$(formTag).attr('action', '/Program/SaveAssessmentSchedule?QuizScheduleId=' + QuizScheduleId + '&batchId=' + batchId + '&programId=' + programId + '&UnitId=' + UnitId);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText == 'Succeeded') {
bootbox.alert("Succeeded", function () {
$.post('/Program/AssessmentSchedule?id=' + batchId + '&programId=' + programId, function (res) {
if (res != '') {
$('#AssessmentScheduleDiv').html(res);
}
});
});
}
else {
bootbox.alert("Some error occurred.", null);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function editAssessmentScheduleRow(rowId, QuizScheduleId, UnitId) {
$('#' + rowId + ' .editClass').hide();
$('#etcDate_' + QuizScheduleId).hide();
$('#' + rowId + ' .saveClass').show();
$('#assessmentSchd #txtETCDate_' + QuizScheduleId).show();
}
function cancelAssessmentScheduleRow(rowId, QuizScheduleId, UnitId) {
$('#' + rowId + ' .editClass').show();
$('#etcDate_' + QuizScheduleId).show();
$('#' + rowId + ' .saveClass').hide();
$('#assessmentSchd #txtETCDate_' + QuizScheduleId).hide();
}
function EditAllAssessmentSchedule() {
$('.etcDate').hide();
$('#btnEditAllAssessmentSchedule').hide();
$('.txtdate').show();
$('#btnSaveAllAssessmentSchedule').show();
$('#btnCancelAllAssessmentSchedule').show();
}
function SaveAllAssessmentSchedule(ele) {
var batchId = $('#hdnBatchId').val();
var programId = $('#hiddenProgramId').val();
var formTag = ('#' + $(ele).closest('form').attr('id'));
$(formTag).attr('action', '/Program/SaveAssessmentSchedule?QuizScheduleId=' + -999 + '&batchId=' + batchId + '&programId=' + programId + '&UnitId=' + -999);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText == 'Succeeded') {
bootbox.alert("Succeeded", function () {
$(formTag).attr('action', '/Program/AssessmentSchedule?id=' + batchId + '&programId=' + programId);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (data) {
if (data != '') {
$('#AssessmentScheduleDiv').html(data);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
//$.post('/Program/AssessmentSchedule?id=' + batchId + '&programId=' + programId, function (res) {
// if (res != '') {
// $('#AssessmentScheduleDiv').html(res);
// }
//});
});
}
else {
bootbox.alert("Some error occurred.", null);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function resetAssessmentSchedule(ele) {
var batchId = $('#hdnAssessmentBatchId').val();
var programId = $('#hiddenAssessmentProgramId').val();
var formTag = ('#' + $(ele).closest('form').attr('id'));
$(formTag).attr('action', '/Program/AssessmentSchedule?id=' + batchId + '&programId=' + programId);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$(formTag).ajaxSubmit({
success: function (responseText) {
if (responseText != '') {
$('#AssessmentScheduleDiv').html(responseText);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function InitDate(startDateEle, endDateEle) {
var nowTemp = new Date();
var now = new Date(nowTemp.getFullYear(), nowTemp.getMonth(), nowTemp.getDate(), 0, 0, 0, 0);
var checkin = $('#' + startDateEle).datepicker({
format: 'mm/dd/yyyy',
endDate: new Date(),
onRender: function (date) {
return date.valueOf() < now.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
var endDateVal = checkout.date ? checkout.date.valueOf : new Date();
if (ev.date.valueOf() > endDateVal) {
var newDate = new Date(ev.date)
newDate.setDate(newDate.getDate() + 1);
checkout.setValue(newDate);
}
checkout.setStartDate(ev.date);
checkin.hide();
$('#' + endDateEle)[0].focus();
}).data('datepicker');
var checkout = $('#' + endDateEle).datepicker({
format: 'mm/dd/yyyy',
onRender: function (date) {
return date.valueOf() <= checkin.date.valueOf() ? 'disabled' : '';
}
}).on('changeDate', function (ev) {
checkout.hide();
}).data('datepicker');
var startDateVal = $.trim($('#' + startDateEle).val());
if (startDateVal != "") {
var parts = startDateVal.split("/");
var dt = new Date(parseInt(parts[2], 10),
parseInt(parts[1], 10) - 1,
parseInt(parts[0], 10));
checkout.setStartDate(dt);
}
}
function openVCRSettingPopUp(batchId) {
$.get('/Batch/VCRSettingCreateOrUpdate', { batchId: batchId }, function (data) {
if (data !== '') {
$('#VCRSettingPopup').html(data);
$.validator.unobtrusive.parse("#frmVCRSetting");
$('#VCRSettingPopup').modal('show');
}
});
}
function saveVCRSetting(batchId) {
var formTag = $("#frmVCRSetting");
$(formTag).attr('action', '/Batch/VCRSettingCreateOrUpdate?batchId=' + batchId);
$(formTag).attr('encytype', 'multipart/form-data');
$(formTag).attr('method', 'post');
$('#VCRSettingPopup').modal('hide');
$(formTag).ajaxSubmit({
success: function (responseText) {
bootbox.alert("Succeeded", function () {
window.location.href = "/Batch/Details?id=" + batchId;
});
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function openBatchReportExportSettingPopUp(batchId) {
$.get('/Batch/GetBatchReportExportSetting', { batchId: batchId }, function (data) {
if (data !== '') {
$('#VCRBatchReportSettingPopup').html(data);
$.validator.unobtrusive.parse("#frmBatchReportExportSetting");
$('#VCRBatchReportSettingPopup').modal('show');
}
});
}
function saveBatchReportExportSetting(batchId) {
$('#VCRBatchReportSettingPopup').modal('hide');
$("#frmBatchReportExportSetting").ajaxSubmit({
success: function (response) {
if (response.result)
bootbox.alert("Succeeded", function () {
window.location.href = "/Batch/Details?id=" + batchId;
});
else
bootbox.alert('Some error occurred.', null);
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function showVideoSetting() {
$('#VideoSettingPopup').modal('show');
}
function closeVideoPopup() {
$('#VideoSettingPopup').modal('hide');
}
function setVideoSetting(batchId) {
$("#updateVideoSetting").ajaxSubmit({
success: function (response) {
if (response) {
$('#VideoSettingPopup').modal('hide');
bootbox.alert("Succeeded", function () {
window.location.href = "/Batch/Details?id=" + batchId;
});
}
else {
$('#VideoSettingPopup').modal('hide');
bootbox.alert('Some error occurred.', null);
}
},
failure: function (data) {
bootbox.alert('Some error occurred.', null);
}
});
}
function setSplitRatio(ele) {
var side1Ratio = $(ele).val();
var side2Ratio = 0;
if (!isNaN(side1Ratio)) {
if (side1Ratio > 100) {
side1Ratio = 0;
$(ele).val(0);
}
side2Ratio = (100 - Number(side1Ratio));
}
if (!isNaN(side2Ratio)) {
$(ele).closest('div.row').find('input.splitRatio').each(function () {
if ($(this).attr('id') != $(ele).attr('id')) { $(this).val(Number(side2Ratio)); }
});
}
}
function submitBatchScheduleRequest(element) {
var requestType = document.getElementById("hdnRequestType").value;
var $modal = $(element).closest('.modal');
var formTag = $modal.find('form');
$('input.input-sm').each(function () {
$(this).rules("add",
{
required: true
})
});
var count = $('#selectGroup').find('option:selected').length;
if (count > 0) {
if ($('#formBatchScheduleRequest').validate().form()) {
var sessionTimelogs = [];
$('#batchDetails').find(':input[name*="todaySchedule-"]').each(function () {
var startTime = this.value.split(" ")[1];
sessionTimelogs.push($("#txtBatchScheduleRequestFromDate").val() + " " + startTime);
});
$.post('/Session/ValidateSessionCancellationTime', JSON.stringify(sessionTimelogs), function (data) {
if (requestType == 2) {
$("#hdfIsInstructorPayable").val("false");
batchRescheduleRequest(formTag, requestType);
return;
}
if (data != "False") {
bootbox.confirm({
message: "Please confirm that the Instructor will be paid for the session.?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function (r) {
if ('true' == r.toString())
$("#hdfIsInstructorPayable").val("true");
else
$("#hdfIsInstructorPayable").val("false");
bootbox.confirm({
message: "Are you sure you want to proceed with cancellation?",
buttons: {
confirm: {
label: 'Yes',
className: 'btn-success'
},
cancel: {
label: 'No',
className: 'btn-danger'
}
},
callback: function (s) {
if ('true' == s.toString()) {
batchRescheduleRequest(formTag, requestType);
}
}
});
}
});
}
else {
$("#hdfIsInstructorPayable").val("false");
batchRescheduleRequest(formTag, requestType);
}
});
}
}
else {
alert("Select Group");
}
}
function batchRescheduleRequest(formTag, requestType) {
$.post($(formTag).attr('action'), $(formTag).serialize(), function (data) {
$('#divModalBatchScheduleRequest').modal('hide');
let statusMessage = "";
if (requestType == 1) {
statusMessage = "Batch request submitted for canceling";
}
else {
statusMessage = "Batch request submitted for scheduling";
}
bootbox.alert(statusMessage, function () {
$('#batchScheduleRequestResult').empty();
$('#formBatchScheduleRequest').trigger("reset");
$('#selectGroup').val(null).trigger("change")
$('#hdnSelectGroup').val(null).trigger("change")
$(".batch-schedule-request-start-time").show();
$(".batch-schedule-request-end-time").show();
$('#batchSchedulePanel').click();
refreshTutoringSessionView();
});
});
}
function closeRequestSchedulePopup(ele) {
try {
$(ele).closest('.modal').modal('hide');
$(ele).closest('.modal').find('input[type="text"], select, textarea').each(function () { $(this).val('').trigger('blur'); });
$(ele).closest('.modal').find('.batch-schedule-request-start-time').show();
$(ele).closest('.modal').find('.batch-schedule-request-end-time').show();
$(ele).closest('.modal').find('form').validate().resetForm();
$(ele).closest('.modal').find('span[data-valmsg-for]').html('');
} catch (e) {
}
}