File: /var/www/html/shootinschool/wp-content/plugins/shootin-school-plugin/includes/js/custom.js
jQuery(document).ready(function () {
jQuery("#email_template").jqte();
jQuery('.timepicker_demo').clockface();
// Check if booking page
// if( jQuery("#createAppointment").length){
// if(! jQuery("#sel_customer").length){
// // var user_id = jQuery("#user_id").attr("value");
// // cloneAppointment(user_id);
// }
// }
});
function openDeleteWarning(id) {
// jQuery("#WarningModal").modal('show');
jQuery("#WarningModal").appendTo("body").modal("show");
jQuery('#ConfirmBtn').on('click', function () {
jQuery('#ConfirmBtn').attr('disabled', true);
window.location.href = '?page=siab-locations&action=delete&id=' + id;
});
}
function openDeletegradeWarning(id) {
// jQuery("#WarningModal").modal('show');
jQuery("#WarningModal").appendTo("body").modal("show");
jQuery('#ConfirmBtn').on('click', function () {
jQuery('#ConfirmBtn').attr('disabled', true);
window.location.href = '?page=siab-grades&action=delete&id=' + id;
});
jQuery('#WarningModal').on('hidden.bs.modal', function () {
// Reload the current page
});
}
function openStatusChange(id) {
// jQuery("#WarningModal").modal('show');
jQuery("#statusModal").appendTo("body").modal("show");
jQuery('#ConfirmstatusBtn').on('click', function () {
jQuery('#ConfirmstatusBtn').attr('disabled', true);
window.location.href = '?page=siab-grades&action=status&id=' + id;
});
jQuery('#statusModal').on('hidden.bs.modal', function () {
});
}
function ApplySubFilter(e) {
var url = window.location.href + "&status=" + e.value;
window.location.replace(url);
}
function SendCustomMail() {
jQuery('.send_schedule').prop("disabled", true);
var startDate = jQuery('#startDate').val()
var txtDate = jQuery('#txtDate').val()
var schedulerTime = jQuery('#schedulerTime').val()
if(startDate == "" || txtDate == "" || schedulerTime ==""){
jQuery('.errvalidation').show();
jQuery('.send_schedule').prop("disabled", false);
return false;
}
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
startdate:startDate,
txtDate:txtDate,
schedulerTime:schedulerTime,
action: "send_mailto_customer_week",
},
success: function (response) {
if (response.status) {
toastr.success(response.message);
jQuery('.send_schedule').prop("disabled", false);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
jQuery('.send_schedule').prop("disabled", false);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function SendaprovalNotifications() {
jQuery('.send_approval_nootifications').prop("disabled", true);
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "SendaprovalNotifications",
},
success: function (response) {
if (response.status) {
toastr.success(response.message);
jQuery('.send_approval_nootifications').prop("disabled", false);
} else {
toastr.error(response.message);
jQuery('.send_approval_nootifications').prop("disabled", false);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function markPurchase(customer_purchase_id) {
jQuery(".css_loader").show();
var customer_purchase_id = customer_purchase_id;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "mark_as_paid",
"customer_purchase_id": customer_purchase_id
},
success: function (response) {
if (response.status) {
// jQuery("#SubscriptionCancelModal").hide();
jQuery(".css_loader").hide();
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function noWeekendsOrHolidays(date) {
// console.log(hide_days);
var day = date.getDay();
var monday = new Date();
//Set the time of today's date to 00:00:00
monday.setHours(0, 0, 0, 0);
/*
Below Line sets the Date to monday (Start of that Week)
(monday.getDay() || 0) returns the value of getDay()
ie., [ 1 - Mon, 2 - Tue, 3 - Wed, 4 - Thu, 5 - Fri, 6 - Sat ]
except for monday where it returns 0.
The return value is used to calculate the Date of that Week's monday
*/
monday.setDate(monday.getDate() - (monday.getDay() || 0));
//Set the Date to monday
var sunday = new Date(monday);
//Now add 6 to monday to get the Date of Saturday (End of that Week)
sunday.setDate(monday.getDate() + 7);
//Now return the enabled and disabled dates to datepicker
// return [(date >= monday && date <= sunday && jQuery.inArray(day, hide_days) != -1), ''];
return [(date >= monday && date <= sunday), ''];
}
var hide_days = "";
function getDatePicker(data) {
// hide_days = data;
jQuery(".date_sel").datepicker({
changeMonth: true,
changeYear: true,
minDate: new Date(),
dateFormat: "DD, MM dd, yy",
firstDay: 1,
beforeShowDay: noWeekendsOrHolidays
});
}
function SaveGrade() {
if (jQuery("#creategrade").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#creategrade").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data.status == true) {
if (data.type == 0) {
// jQuery("#createlocation")[0].reset();
location.reload();
}
jQuery(".Saveress").show();
jQuery(".Saveress").addClass("alert alert-success");
jQuery(".Saveress").html(data.message);
jQuery(".Saveress").attr("tabindex", -1).focus();
// jQuery('html, body').animate({ scrollTop: jQuery("#createlocation").offset().top }, 'fast');
setTimeout(function () {
jQuery(".Saveress").hide();
jQuery(".Saveress").html(" ");
location.reload();
}, 1000);
} else {
toastr.error(data.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function SaveLocation() {
if (jQuery("#createlocation").parsley().validate()) {
if(document.getElementById('mon_open').value!=''){
var monOpenValue = document.getElementById('mon_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
console.log('monOpenValue---'+monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
var monCloseValue = document.getElementById('mon_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
console.log('time12HourFormat1---'+time12HourFormat1);
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
// console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Monday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Monday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var monsempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var moneempty=1;
}
}
// if(monsempty==1){
// toastr.error('Monday split start time not empty');
// }
// if(moneempty==1){
// toastr.error('Monday split end time not empty');
// }
var dropdowns1 = document.querySelectorAll(".grade_select1");
var monallSelected = true;
var timeGradeContainer1 = document.getElementById('timeGradeContainer1');
for (var i = 0; i < dropdowns1.length; i++) {
if (dropdowns1[i].selectedIndex ==0) {
monallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(monsempty!=1 && moneempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var mondatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
console.log('Monday_stime[] is within the range');
} else {
console.log('Monday_stime[] is not within the range');
var smonday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
console.log('Monday_etime[] is within the range');
} else {
console.log('Monday_etime[] is not within the range');
var emonday=2;
//toastr.error('Monday is not within the range');
}
}
}
if (monsempty === 1 || moneempty === 1 || monallSelected === false) {
let errorMessage = "Warning: For Monday,";
if (monsempty === 1) {
errorMessage += "start time field is empty. ";
}
if (moneempty === 1) {
errorMessage += "end time field is empty. ";
}
if (monallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
// if(smonday===1)
// { toastr.error('Monday split Start is not within the time range'); }
// if(emonday===2)
// { toastr.error('Monday split End is not within the time range'); }
// if (monallSelected==false) {
// toastr.error('Warning: For Monday, please select a grade range to proceed'); }
// if (mondatecheck === 3) {
// toastr.error('Start time should be less than End time'); }
}
//-------------------------------------Tuesday------------------------------
if(document.getElementById('tue_open').value!=''){
var monOpenValue = document.getElementById('tue_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log(time24HourFormat);
var monCloseValue = document.getElementById('tue_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Tuesday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Tuesday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var tuesempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var tueeempty=1;
}
}
var dropdowns2 = document.querySelectorAll(".grade_select2");
var tueallSelected = true;
for (var i = 0; i < dropdowns2.length; i++) {
if (dropdowns2[i].selectedIndex == 0) {
tueallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
// var dayStimeValue = dayStimeInputs[i].value;
// var timeComponents1 = dayStimeValue.split(' ');
// var time1 = timeComponents1[0]; // '06'
// var period1 = timeComponents1[1]; // 'PM'
// var hours1 = parseInt(time1, 10);
// if (period1 === 'PM' && hours1 < 12) {
// hours1 += 12;
// }
// var time24HourFormat1 = (hours1 < 10 ? '0' : '') + hours1 + ':00';
// console.log(time24HourFormat1);
// var dayEtimeValue = dayEtimeInputs[i].value;
// var timeComponents2 = dayEtimeValue.split(' ');
// var time2 = timeComponents2[0]; // '06'
// var period2 = timeComponents2[1]; // 'PM'
// var hours2 = parseInt(time2, 10);
// if (period2 === 'PM' && hours2 < 12) {
// hours2 += 12;
// }
// var time24HourFormat2 = (hours2 < 10 ? '0' : '') + hours2 + ':00';
// console.log(time24HourFormat2);
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(tuesempty!=1 && tueeempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var tuedatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
console.log('Tuesday_stime[] is within the range');
} else {
console.log('Tuesday_stime[] is not within the range');
var tumonday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
console.log('Tuesday_etime[] is within the range');
} else {
console.log('Tuesday_etime[] is not within the range');
var tumonday=2;
//toastr.error('Monday is not within the range');
}
}
}
// if(tumonday===1)
// { toastr.error('Tuesday split Start is not within the time range'); }
// if(tumonday===2)
// { toastr.error('Tuesday split End is not within the time range'); }
// if (tueallSelected==false) {
// toastr.error('Warning: For Tuesday, please select a grade range to proceed'); }
// if (tuedatecheck === 3) {
// toastr.error('Start time should be less than End time'); }
if (tuesempty === 1 || tueeempty === 1 || tueallSelected === false) {
let errorMessage = "Warning: For Tuesday,";
if (tuesempty === 1) {
errorMessage += "start time field is empty. ";
}
if (tueeempty === 1) {
errorMessage += "end time field is empty. ";
}
if (tueallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
}
//------------------------------wednesday---------------------------------
if(document.getElementById('wed_open').value!=''){
var monOpenValue = document.getElementById('wed_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log(time24HourFormat);
var monCloseValue = document.getElementById('wed_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Wednesday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Wednesday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var wedsempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var wedeempty=1;
}
}
var dropdowns3 = document.querySelectorAll(".grade_select3");
var wedallSelected = true;
for (var i = 0; i < dropdowns3.length; i++) {
if (dropdowns3[i].selectedIndex == 0) {
wedallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
// var dayStimeValue = dayStimeInputs[i].value;
// var timeComponents1 = dayStimeValue.split(' ');
// var time1 = timeComponents1[0]; // '06'
// var period1 = timeComponents1[1]; // 'PM'
// var hours1 = parseInt(time1, 10);
// if (period1 === 'PM' && hours1 < 12) {
// hours1 += 12;
// }
// var time24HourFormat1 = (hours1 < 10 ? '0' : '') + hours1 + ':00';
// console.log(time24HourFormat1);
// var dayEtimeValue = dayEtimeInputs[i].value;
// var timeComponents2 = dayEtimeValue.split(' ');
// var time2 = timeComponents2[0]; // '06'
// var period2 = timeComponents2[1]; // 'PM'
// var hours2 = parseInt(time2, 10);
// if (period2 === 'PM' && hours2 < 12) {
// hours2 += 12;
// }
// var time24HourFormat2 = (hours2 < 10 ? '0' : '') + hours2 + ':00';
// console.log(time24HourFormat2);
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(wedsempty!=1 && wedeempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var weddatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
console.log('Wednesday_stime[] is within the range');
} else {
console.log('Wednesday_stime[] is not within the range');
var wednesday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
console.log('Wednesday_etime[] is within the range');
} else {
console.log('Wednesday_etime[] is not within the range');
var wednesday=2;
//toastr.error('Monday is not within the range');
}
}
}
// if(wednesday===1)
// { toastr.error('Wednesday split Start is not within the time range'); }
// if(wednesday===2)
// { toastr.error('Wednesday split End is not within the time range'); }
// if (wedallSelected==false) {
// toastr.error('Warning: For Wednesday, please select a grade range to proceed'); }
// if (weddatecheck === 3) {
// toastr.error('Start time should be less than End time'); }
if (wedsempty === 1 || wedeempty === 1 || wedallSelected === false) {
let errorMessage = "Warning: For Wednesday,";
if (wedsempty === 1) {
errorMessage += "start time field is empty. ";
}
if (wedeempty === 1) {
errorMessage += "end time field is empty. ";
}
if (wedallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
}
//------------------------------Thursday------------------------------------------
if(document.getElementById('thu_open').value!=''){
var monOpenValue = document.getElementById('thu_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log(time24HourFormat);
var monCloseValue = document.getElementById('thu_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Thursday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Thursday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var thusempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var thueempty=1;
}
}
var dropdowns4 = document.querySelectorAll(".grade_select4");
var thuallSelected = true;
var timeGradeContainer1 = document.getElementById('timeGradeContainer1');
for (var i = 0; i < dropdowns4.length; i++) {
if (dropdowns4[i].selectedIndex ==0) {
thuallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
// var dayStimeValue = dayStimeInputs[i].value;
// var timeComponents1 = dayStimeValue.split(' ');
// var time1 = timeComponents1[0]; // '06'
// var period1 = timeComponents1[1]; // 'PM'
// var hours1 = parseInt(time1, 10);
// if (period1 === 'PM' && hours1 < 12) {
// hours1 += 12;
// }
// var time24HourFormat1 = (hours1 < 10 ? '0' : '') + hours1 + ':00';
// console.log(time24HourFormat1);
// var dayEtimeValue = dayEtimeInputs[i].value;
// var timeComponents2 = dayEtimeValue.split(' ');
// var time2 = timeComponents2[0]; // '06'
// var period2 = timeComponents2[1]; // 'PM'
// var hours2 = parseInt(time2, 10);
// if (period2 === 'PM' && hours2 < 12) {
// hours2 += 12;
// }
// var time24HourFormat2 = (hours2 < 10 ? '0' : '') + hours2 + ':00';
// console.log(time24HourFormat2);
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(thusempty!=1 && thueempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var thudatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
} else {
var tuesday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
} else {
var tuesday=2;
//toastr.error('Monday is not within the range');
}
}
}
// if(tuesday===1)
// { toastr.error('Thursday split Start is not within the time range'); }
// if(tuesday===2)
// { toastr.error('Thursday split End is not within the time range'); }
// if (thuallSelected==false) {
// toastr.error('Warning: For Thursday, please select a grade range to proceed'); }
// if (thudatecheck === 3) {
// toastr.error('Start time should be less than End time'); }
if (thusempty === 1 || thueempty === 1 || thuallSelected === false) {
let errorMessage = "Warning: For Thursday,";
if (thusempty === 1) {
errorMessage += "start time field is empty. ";
}
if (thueempty === 1) {
errorMessage += "end time field is empty. ";
}
if (thuallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
}
//-------------------------------Friday-------------------------------
if(document.getElementById('fri_open').value!=''){
var monOpenValue = document.getElementById('fri_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log(time24HourFormat);
var monCloseValue = document.getElementById('fri_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Friday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Friday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var frisempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var frieempty=1;
}
}
var dropdowns5 = document.querySelectorAll(".grade_select5");
var friallSelected = true;
var timeGradeContainer1 = document.getElementById('timeGradeContainer1');
for (var i = 0; i < dropdowns5.length; i++) {
if (dropdowns5[i].selectedIndex ==0) {
friallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
// var dayStimeValue = dayStimeInputs[i].value;
// var timeComponents1 = dayStimeValue.split(' ');
// var time1 = timeComponents1[0]; // '06'
// var period1 = timeComponents1[1]; // 'PM'
// var hours1 = parseInt(time1, 10);
// if (period1 === 'PM' && hours1 < 12) {
// hours1 += 12;
// }
// var time24HourFormat1 = (hours1 < 10 ? '0' : '') + hours1 + ':00';
// console.log(time24HourFormat1);
// var dayEtimeValue = dayEtimeInputs[i].value;
// var timeComponents2 = dayEtimeValue.split(' ');
// var time2 = timeComponents2[0]; // '06'
// var period2 = timeComponents2[1]; // 'PM'
// var hours2 = parseInt(time2, 10);
// if (period2 === 'PM' && hours2 < 12) {
// hours2 += 12;
// }
// var time24HourFormat2 = (hours2 < 10 ? '0' : '') + hours2 + ':00';
// console.log(time24HourFormat2);
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(frisempty!=1 && frieempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var fridatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
} else {
var friday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
} else {
var friday=2;
//toastr.error('Monday is not within the range');
}
}
}
// if(friday===1)
// { toastr.error('Friday split Start is not within the time range'); }
// if(friday===2)
// { toastr.error('Friday split End is not within the time range'); }
// if (friallSelected==false) {
// toastr.error('Warning: For Friday, please select a grade range to proceed'); }
// if (fridatecheck === 3) {
// toastr.error(' Friday Start time should be less than End time'); }
if (frisempty === 1 || frieempty === 1 || friallSelected === false) {
let errorMessage = "Warning: For Friday,";
if (frisempty === 1) {
errorMessage += "start time field is empty. ";
}
if (frieempty === 1) {
errorMessage += "end time field is empty. ";
}
if (friallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
}
//------------------------Saturday-----------------------------
if(document.getElementById('sat_open').value!=''){
var monOpenValue = document.getElementById('sat_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log(time24HourFormat);
var monCloseValue = document.getElementById('sat_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Saturday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Saturday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var satsempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var sateempty=1;
}
}
var dropdowns6 = document.querySelectorAll(".grade_select6");
var satallSelected = true;
var timeGradeContainer1 = document.getElementById('timeGradeContainer1');
for (var i = 0; i < dropdowns6.length; i++) {
if (dropdowns6[i].selectedIndex ==0) {
satallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
// var dayStimeValue = dayStimeInputs[i].value;
// var timeComponents1 = dayStimeValue.split(' ');
// var time1 = timeComponents1[0]; // '06'
// var period1 = timeComponents1[1]; // 'PM'
// var hours1 = parseInt(time1, 10);
// if (period1 === 'PM' && hours1 < 12) {
// hours1 += 12;
// }
// var time24HourFormat1 = (hours1 < 10 ? '0' : '') + hours1 + ':00';
// console.log(time24HourFormat1);
// var dayEtimeValue = dayEtimeInputs[i].value;
// var timeComponents2 = dayEtimeValue.split(' ');
// var time2 = timeComponents2[0]; // '06'
// var period2 = timeComponents2[1]; // 'PM'
// var hours2 = parseInt(time2, 10);
// if (period2 === 'PM' && hours2 < 12) {
// hours2 += 12;
// }
// var time24HourFormat2 = (hours2 < 10 ? '0' : '') + hours2 + ':00';
// console.log(time24HourFormat2);
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(satsempty!=1 && sateempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var satdatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
} else {
var saturday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
} else {
var saturday=2;
//toastr.error('Monday is not within the range');
}
}
}
// if(saturday===1)
// { toastr.error('Saturday split Start is not within the time range'); }
// if(saturday===2)
// { toastr.error('Saturday split End is not within the time range'); }
// if (satallSelected==false) {
// toastr.error('Warning: For Saturday, please select a grade range to proceed'); }
// if (satdatecheck === 3) {
// toastr.error(' Saturday Start time should be less than End time'); }
if (satsempty === 1 || sateempty === 1 || satallSelected === false) {
let errorMessage = "Warning: For Saturday,";
if (satsempty === 1) {
errorMessage += "start time field is empty. ";
}
if (sateempty === 1) {
errorMessage += "end time field is empty. ";
}
if (satallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
}
//---------------------------SUnday--------------------------------------------
if(document.getElementById('sun_open').value!=''){
var monOpenValue = document.getElementById('sun_open').value;
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
//---------------------------
if (isNaN(time12HourFormat)) {
var parts = monOpenValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monOpenValue = hours + ':' + minutes + ' ' + ampm;
}
//---------------------------------
var time12HourFormat = new Date('1970-01-01 ' + monOpenValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log(time24HourFormat);
var monCloseValue = document.getElementById('sun_close').value;
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
//---------------------------
if (isNaN(time12HourFormat1)) {
var parts = monCloseValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var monCloseValue = hours + ':' + minutes + ' ' + ampm;
}// Output: '9:00 AM'
//---------------------------------
var time12HourFormat1 = new Date('1970-01-01 ' + monCloseValue);
var hours1 = time12HourFormat1.getHours();
var minutes1 = time12HourFormat1.getMinutes();
var time24HourFormat3 = (hours1 < 10 ? '0' : '') + hours1 + ':' + (minutes1 < 10 ? '0' : '') + minutes1;
console.log(time24HourFormat3);
// var dayStimeValue = document.getElementById('Monday_stime[]').value;
// var dayEtimeValue = document.getElementById('Monday_etime[]').value;
var dayStimeInputs = document.querySelectorAll('[id^="Sunday_stime[]"]');
var dayEtimeInputs = document.querySelectorAll('[id^="Sunday_etime[]"]');
for (var i = 0; i < dayStimeInputs.length; i++) {
if (dayStimeInputs[i].value.trim() === "") {
var sunsempty=1;
}
}
for (var i = 0; i < dayEtimeInputs.length; i++) {
if (dayEtimeInputs[i].value.trim() === "") {
var suneempty=1;
}
}
var dropdowns7 = document.querySelectorAll(".grade_select7");
var sunallSelected = true;
var timeGradeContainer1 = document.getElementById('timeGradeContainer1');
for (var i = 0; i < dropdowns7.length; i++) {
if (dropdowns7[i].selectedIndex ==0) {
sunallSelected = false;
break; // If one dropdown is not selected, exit the loop.
}
}
for (var i = 0; i < dayStimeInputs.length; i++) {
// var dayStimeValue = dayStimeInputs[i].value;
// var timeComponents1 = dayStimeValue.split(' ');
// var time1 = timeComponents1[0]; // '06'
// var period1 = timeComponents1[1]; // 'PM'
// var hours1 = parseInt(time1, 10);
// if (period1 === 'PM' && hours1 < 12) {
// hours1 += 12;
// }
// var time24HourFormat1 = (hours1 < 10 ? '0' : '') + hours1 + ':00';
// console.log(time24HourFormat1);
// var dayEtimeValue = dayEtimeInputs[i].value;
// var timeComponents2 = dayEtimeValue.split(' ');
// var time2 = timeComponents2[0]; // '06'
// var period2 = timeComponents2[1]; // 'PM'
// var hours2 = parseInt(time2, 10);
// if (period2 === 'PM' && hours2 < 12) {
// hours2 += 12;
// }
// var time24HourFormat2 = (hours2 < 10 ? '0' : '') + hours2 + ':00';
// console.log(time24HourFormat2);
var dayStimeValue = dayStimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayStimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayStimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayStimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat1 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
//--------------------------------------------------------------------------------------------------------
var dayEtimeValue = dayEtimeInputs[i].value;
var time12HourFormat = new Date('1970-01-01' + dayEtimeValue);
if (isNaN(time12HourFormat)) {
var parts = dayEtimeValue.split(' ');
var time = parts[0];
var ampm = parts[1];
var timeParts = time.split(':');
var hours = timeParts[0];
var minutes = timeParts[1] || '00';
hours = parseInt(hours, 10);
var dayEtimeValue = hours + ':' + minutes + ' ' + ampm;
}
var time12HourFormat = new Date('1970-01-01 ' + dayEtimeValue);
var hours = time12HourFormat.getHours();
var minutes = time12HourFormat.getMinutes();
var time24HourFormat2 = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
console.log('ann-'+time24HourFormat1);
if(sunsempty!=1 && suneempty!=1){
if(time24HourFormat2<=time24HourFormat1)
{
var sundatecheck=3;
}
if (time24HourFormat1 >= time24HourFormat && time24HourFormat1 <= time24HourFormat3) {
} else {
var sunday=1;
//toastr.error('Monday is not within the range');
}
if (time24HourFormat2 >= time24HourFormat && time24HourFormat2 <= time24HourFormat3) {
} else {
var sunday=2;
//toastr.error('Monday is not within the range');
}
}
}
// if(sunday===1)
// { toastr.error('Sunday split Start is not within the time range'); }
// if(sunday===2)
// { toastr.error('Sunday split End is not within the time range'); }
// if (sunallSelected==false) {
// toastr.error('Warning: For Sunday, please select a grade range to proceed'); }
// if (sundatecheck === 3) {
// toastr.error(' Sunday Start time should be less than End time'); }
if (sunsempty === 1 || suneempty === 1 || sunallSelected === false) {
let errorMessage = "Warning: For Sunday,";
if (sunsempty === 1) {
errorMessage += "start time field is empty. ";
}
if (suneempty === 1) {
errorMessage += "end time field is empty. ";
}
if (sunallSelected === false) {
errorMessage += " please select a grade range to proceed.";
}
toastr.error(errorMessage);
}
}
const daysOfWeek = [
{ name: 'Sunday', flag: sunday, allSelected: sunallSelected, dateCheck: sundatecheck },
{ name: 'Saturday', flag: saturday, allSelected: satallSelected, dateCheck: satdatecheck },
{ name: 'Friday', flag: friday, allSelected: friallSelected, dateCheck: fridatecheck },
{ name: 'Thursday', flag: tuesday, allSelected: thuallSelected, dateCheck: thudatecheck },
{ name: 'Wednesday', flag: wednesday, allSelected: wedallSelected, dateCheck: weddatecheck },
{ name: 'Tuesday', flag: tuesday, allSelected: tueallSelected, dateCheck: tuedatecheck },
{ name: 'Monday', flag: smonday, allSelected: monallSelected, dateCheck: mondatecheck },
];
const errorMessages = {
1: 'the split time added is not with in the actual time range',
2: 'the split time added is not with in the actual time range',
3: 'Start time should be less than End time',
};
const combineMessages = {};
for (const day of daysOfWeek) {
for (const type in errorMessages) {
if ((day.flag === +type) || (type === '3' && day.dateCheck === 3)) {
if (!combineMessages[type]) {
combineMessages[type] = [];
}
combineMessages[type].unshift(day.name); // Add day.name to the beginning
//combineMessages[type].push(errorMessages[type]);
}
}
}
for (const type in combineMessages) {
if (combineMessages[type].length > 0) {
toastr.error(`Warning: ${errorMessages[type]} for ${combineMessages[type].join(', ')}`);
}
}
//-------------------------------------------------------------------
if(smonday===1 || emonday===2 || tumonday===1 || tumonday===2 || monallSelected==false || mondatecheck === 3 || tuedatecheck==3 || tueallSelected==false || wednesday===1 || wednesday===2 || wedallSelected==false || weddatecheck === 3 || tuesday===1 || tuesday===2 || thuallSelected==false || thudatecheck === 3 || friday===1 || friday===2 || friallSelected==false || fridatecheck === 3 || saturday===1 || saturday===2 || satallSelected==false || satdatecheck === 3 || sunday===1 || sunday===2 || sunallSelected==false || sundatecheck === 3 || monsempty ==1 || moneempty ==1 || tuesempty ==1 || tueeempty ==1 || wedsempty ==1 || wedeempty ==1 || thusempty ==1 || thueempty ==1 || frisempty ==1 || frieempty ==1 || satsempty ==1 || sateempty ==1 || sunsempty ==1 || suneempty ==1){}else{
var mon_open=document.getElementById('mon_open').value;
var mon_close=document.getElementById('mon_close').value;
var mon_package=document.getElementById('select1').value;
if(mon_open!='' && mon_close!='' && mon_package==0)
{
var val=1;
//alert("Please choose Instruction Type");
document.getElementById('label1').innerText = "Please choose Instruction Type";
}
else{document.getElementById('label1').innerText ="";}
var tue_open=document.getElementById('tue_open').value;
var tue_close=document.getElementById('tue_close').value;
var tue_package=document.getElementById('select2').value;
if(tue_open!='' && tue_close!='' && tue_package==0)
{
//alert("Please choose Instruction Type");
var val=1;
document.getElementById('label2').innerText = "Please choose Instruction Type";
}else{document.getElementById('label2').innerText ="";}
var wed_open=document.getElementById('wed_open').value;
var wed_close=document.getElementById('wed_close').value;
var wed_package=document.getElementById('select3').value;
if(wed_open!='' && wed_close!='' && wed_package==0)
{
//alert("Please choose Instruction Type");
var val=1;
document.getElementById('label3').innerText = "Please choose Instruction Type";
}else{document.getElementById('label3').innerText ="";}
var thu_open=document.getElementById('thu_open').value;
var thu_close=document.getElementById('thu_close').value;
var thu_package=document.getElementById('select4').value;
if(thu_open!='' && thu_close!='' && thu_package==0)
{
//alert("Please choose Instruction Type");
var val=1;
document.getElementById('label4').innerText = "Please choose Instruction Type";
}else{document.getElementById('label4').innerText ="";}
var fri_open=document.getElementById('fri_open').value;
var fri_close=document.getElementById('fri_close').value;
var fri_package=document.getElementById('select5').value;
if(fri_open!='' && fri_close!='' && fri_package==0)
{
//alert("Please choose Instruction Type");
var val=1;
document.getElementById('label5').innerText = "Please choose Instruction Type";
}else{document.getElementById('label5').innerText ="";}
var sat_open=document.getElementById('sat_open').value;
var sat_close=document.getElementById('sat_close').value;
var sat_package=document.getElementById('select6').value;
if(sat_open!='' && sat_close!='' && sat_package==0)
{
//alert("Please choose Instruction Type");
var val=1;
document.getElementById('label6').innerText = "Please choose Instruction Type";
}else{document.getElementById('label6').innerText ="";}
var sun_open=document.getElementById('sun_open').value;
var sun_close=document.getElementById('sun_close').value;
var sun_package=document.getElementById('select7').value;
if(sun_open!='' && sun_close!='' && sun_package==0)
{
//alert("Please choose Instruction Type");
var val=1;
document.getElementById('label7').innerText = "Please choose Instruction Type";
}else{document.getElementById('label7').innerText ="";}
if(val==1)
{
}
else{
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#createlocation").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data.status == true) {
if (data.type == 0) {
// jQuery("#createlocation")[0].reset();
}
jQuery(".Saveress").show();
jQuery(".Saveress").addClass("alert alert-success");
jQuery(".Saveress").html(data.message);
jQuery(".Saveress").attr("tabindex", -1).focus();
// jQuery('html, body').animate({ scrollTop: jQuery("#createlocation").offset().top }, 'fast');
setTimeout(function () {
jQuery(".Saveress").hide();
jQuery(".Saveress").html(" ");
location.reload();
}, 1000);
} else {
toastr.error(data.message);
// jQuery(".Saveress").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
}
}
function Timedata(elm) {
// alert()
if (jQuery(elm).hasClass("open")) {
if (jQuery(elm).val() != "") {
jQuery(elm)
.closest("tr")
.find(".close_time")
.attr("required", "required");
} else {
jQuery(elm)
.closest("tr")
.find(".close_time")
.removeAttr("required");
}
}
if (jQuery(elm).hasClass("close_time")) {
if (jQuery(elm).val() != "") {
jQuery(elm)
.closest("tr")
.find(".open")
.attr("required", "required");
} else {
jQuery(elm)
.closest("tr")
.find(".open")
.removeAttr("required");
}
}
// jQuery('.sndschlebtn').prop('disabled', true);
}
function AddNew() {
// jQuery(".new_list").append('<div class="group"><input type="text" required value="" name="group[]"> <input type="button" onclick="RemoveData(this)" value="-" ><br></div>');
jQuery(".new_list").append(
'<div class="form-group"><div class="input-group group"><input type="text" required value="" name="group[]" class="form-control" ><div class="input-group-btn"><button class="btn btn-default" onclick="RemoveData(this)" type="button"><i class="glyphicon glyphicon-minus"></i></button></div></div></div>'
);
}
function RemoveData(elm) {
jQuery(elm)
.closest(".group")
.remove();
}
function SaveGroupData() {
if (jQuery("#AddGroups").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#AddGroups").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data) {
if (data.type == 0) {
jQuery("#AddGroups")[0].reset();
}
jQuery(".Saveress").show();
jQuery(".Saveress").addClass("alert alert-success");
jQuery(".Saveress").html(data.message);
setTimeout(function () {
jQuery(".Saveress").hide();
location.reload();
jQuery(".Saveress").html(" ");
}, 3000);
} else {
jQuery(".Saveress").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function CreditType(elm) {
var type = jQuery(elm).val();
if (type == 0) {
jQuery("#credit_no").show();
jQuery("#credit_no").prop("required", true);
} else {
jQuery("#credit_no").hide();
jQuery("#credit_no").removeAttr("required");
}
}
function SaveSession() {
if (jQuery("#createSession").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#createSession").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data) {
if (data.type == 0) {
jQuery("#createSession")[0].reset();
}
jQuery(".Saveress").show();
jQuery(".Saveress").addClass("alert alert-success");
jQuery(".Saveress").html(data.message);
// setTimeout(function(){ jQuery(".Saveress").hide(); location.reload(); jQuery(".Saveress").html(' '); }, 3000);
} else {
jQuery(".Saveress").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function EditGroupData() {
if (jQuery("#EditGroups").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#EditGroups").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data) {
if (data.type == 0) {
jQuery("#AddGroups")[0].reset();
}
jQuery(".EditGroups").show();
jQuery(".EditGroups").addClass("alert alert-success");
jQuery(".EditGroups").html(data.message);
setTimeout(function () {
jQuery(".EditGroups").hide();
}, 3000);
} else {
jQuery(".EditGroups").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function EditGroup(elm) {
var id = jQuery(elm).data("id");
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: {
action: "get_group_modal",
id
},
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
jQuery("#edit_modal").html(data.html);
jQuery("#edit_modal").modal("show");
},
error: function (data) {
console.log("inside error");
}
});
}
// END TIME ONCHANGE LOCATION SELECT BOX FOR INSTRUCTORS
function getStartTime(ele, day) {
var start_time = jQuery(ele).val();
if (start_time == "") {
jQuery(ele)
.closest("div.row")
.find(".loc_end")
.empty()
.append('<option value=""> -- Choose Availability End time -- </option>');
return false;
}
var location_id = jQuery(ele)
.closest("div.row")
.find(".loc_sel")
.val();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "POST",
data: {
action: "get_timings",
type: "end",
location_id,
start_time,
day
},
success: function (response) {
if (response.status) {
jQuery(ele)
.closest("div.row")
.find(".loc_end")
.empty()
.append(response.renderedHtml);
}
}
});
}
// ADD MORE LOCATION FOR INSTRUCTORS
function addMorelocation(day) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "GET",
data: {
action: "get_locations",
pass_day: day
},
success: function (response) {
if (response.status) {
jQuery("#" + day + "_container").append(response.renderedHtml);
}
},
error: function () {
console.log("inside error");
}
});
}
function addOffDay() {
// alert();
var tomorrow = moment()
.add(1, "days")
.format("DD-MM-YYYY");
jQuery(".offday_Div").append(
'<div class="row">'+
'<div class="col-md-2">' +
'<div class="form-group">' +
'<input class="form-control" type="date" name="off_day[]">' +
'</div>' +
'</div>'+
'<div class="col-md-1">' +
'<div class="form-group">' +
'<button type="button" class="btn btn-danger btn-xs" onClick="this.parentNode.parentNode.parentNode.remove();">X</button>' +
'</div>'+
'</div>'+
'</div>'
);
}
// function editModal(data, id) {
// var credit = data.value;
// jQuery("#updateCredit").attr("value", id);
// // jQuery("#creditNumber").attr("value", credit);
// }
// function updateCredit(data) {
// var id = data.value;
// var credit = jQuery("#creditNumber").val();
// jQuery.ajax({
// url: ajaxurl,
// method: "post",
// dataType: "json",
// data: {
// action: "update_credits",
// credit,
// id
// },
// success: function(response) {
// if (response.status) {
// location.reload();
// }
// },
// error: function(data) {
// console.log("inside error");
// }
// });
// }
function AddNew() {
jQuery(".new_list").append(
'<div class="form-group"><div class="input-group group"><input type="text" required value="" name="group[]" class="form-control" ><div class="input-group-btn"><button class="btn btn-default" onclick="RemoveData(this)" type="button"><i class="glyphicon glyphicon-minus"></i></button></div></div></div>'
);
}
function RemoveData(elm) {
jQuery(elm)
.closest(".group")
.remove();
}
function SaveGroupData() {
if (jQuery("#AddGroups").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#AddGroups").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data) {
if (data.type == 0) {
jQuery("#AddGroups")[0].reset();
}
jQuery(".Saveress").show();
jQuery(".Saveress").addClass("alert alert-success");
jQuery(".Saveress").html(data.message);
setTimeout(function () {
jQuery(".Saveress").hide();
location.reload();
jQuery(".Saveress").html(" ");
}, 3000);
} else {
jQuery(".Saveress").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function CreditType(elm) {
var type = jQuery(elm).val();
if (type == 0) {
jQuery("#credit_no").show();
jQuery("#credit_no").prop("required", true);
} else {
jQuery("#credit_no").hide();
jQuery("#credit_no").removeAttr("required");
}
}
function SaveSession() {
if (jQuery("#createSession").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#createSession").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data) {
if (data.type == 0) {
jQuery("#createSession")[0].reset();
}
jQuery(".Saveress").show();
jQuery(".Saveress").addClass("alert alert-success");
jQuery(".Saveress").html(data.message);
// setTimeout(function(){ jQuery(".Saveress").hide(); location.reload(); jQuery(".Saveress").html(' '); }, 3000);
} else {
jQuery(".Saveress").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function EditGroupData() {
if (jQuery("#EditGroups").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: jQuery("#EditGroups").serialize(),
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
if (data) {
if (data.type == 0) {
jQuery("#AddGroups")[0].reset();
}
jQuery(".EditGroups").show();
jQuery(".EditGroups").addClass("alert alert-success");
jQuery(".EditGroups").html(data.message);
setTimeout(function () {
jQuery(".EditGroups").hide();
}, 3000);
} else {
jQuery(".EditGroups").show();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function EditGroup(elm) {
var id = jQuery(elm).data("id");
jQuery.ajax({
url: ajaxurl,
dataType: "json",
cache: false,
method: "post",
data: {
action: "get_group_modal",
id,
},
success: function (json) {
var data = JSON.parse(JSON.stringify(json));
jQuery("#edit_modal").html(data.html);
jQuery("#edit_modal").modal("show");
},
error: function (data) {
console.log("inside error");
}
});
}
// START TIME ONCHANGE LOCATION SELECT BOX FOR INSTRUCTORS
function getAvailability(ele, day) {
var outerArray = [];
jQuery(".new_data").removeClass("god");
jQuery(".existing_data").removeClass("god");
jQuery(ele).closest("#" + day + "_container").addClass("god");
jQuery("#" + day + "_container .row:not(.god)").each(function (i, obj) {
var innerArr = {};
var start = jQuery(this)
.find(".loc_start")
.val();
var end = jQuery(this)
.find(".loc_end")
.val();
if (start != "" && end != "") {
innerArr.start = start;
innerArr.end = end;
outerArray.push(innerArr);
}
});
var location_id = jQuery(ele).val();
if (location_id == "") {
jQuery(ele)
.closest("div.row")
.find(".loc_start")
.empty()
.append(
'<option value=""> -- Choose Availability Start Time -- </option>'
);
return false;
}
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "POST",
data: {
action: "get_timings",
type: "start",
location_id,
day,
ignoreTimes: outerArray
},
success: function (response) {
if (response.status) {
jQuery(".css_loader").hide();
jQuery(ele)
.closest("div.row")
.find(".loc_start")
.empty()
.append(response.renderedHtml);
}
}
});
}
// END TIME ONCHANGE LOCATION SELECT BOX FOR INSTRUCTORS
function getEndTime(ele, day) {
var start_time = jQuery(ele).val();
jQuery(".new_data").removeClass("god");
jQuery(".existing_data").removeClass("god");
jQuery(ele).closest("#" + day + "_container .row").addClass("god");
jQuery(ele).closest(".god").nextAll(".row").each(function (i, obj) {
jQuery(this).find(".loc_start").prop('selectedIndex', 0);
var locid = jQuery(this).find(".loc_sel").val();
jQuery(this).find(".loc_sel").val(locid).change();
jQuery(this).find(".loc_end").prop('selectedIndex', 0);
});
}
function getStartTime(ele, day) {
var start_time = jQuery(ele).val();
jQuery(".new_data").removeClass("god");
jQuery(".existing_data").removeClass("god");
jQuery(ele).closest("#" + day + "_container .row").addClass("god");
jQuery(ele).closest(".god").nextAll(".row").each(function (i, obj) {
jQuery(this).find(".loc_start").prop('selectedIndex', 0);
jQuery(this).find(".loc_end").prop('selectedIndex', 0);
});
var outerArray = [];
jQuery("#" + day + "_container .row:not(.god)").each(function (i, obj) {
var innerArr = {};
var start = jQuery(this)
.find(".loc_start")
.val();
var end = jQuery(this)
.find(".loc_end")
.val();
if (start != "" && end != "") {
innerArr.start = start;
innerArr.end = end;
outerArray.push(innerArr);
}
});
if (start_time == "") {
jQuery(ele)
.closest("div.row")
.find(".loc_end")
.empty()
.append('<option value=""> -- Choose Availability End Time -- </option>');
return false;
}
var location_id = jQuery(ele)
.closest("div.row")
.find(".loc_sel")
.val();
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "POST",
data: {
action: "get_timings",
type: "end",
location_id,
start_time,
day,
ignoreTimes: outerArray
},
success: function (response) {
if (response.status) {
jQuery(".css_loader").hide();
jQuery(ele)
.closest("div.row")
.find(".loc_end")
.empty()
.append(response.renderedHtml);
}
}
});
}
// ADD MORE LOCATION FOR INSTRUCTORS
function addMorelocation(day) {
// alert("1");
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "GET",
data: {
action: "get_locations",
pass_day: day
},
success: function (response) {
// alert("reached");
if (response.status) {
jQuery("#" + day + "_container").append(response.renderedHtml);
}
},
error: function () {
console.log("inside error");
}
});
}
function addMorelocationadmin(day) {
// alert("1");
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "GET",
data: {
action: "get_locations_admin",
pass_day: day
},
success: function (response) {
// alert("reached");
if (response.status) {
jQuery("#" + day + "_container").append(response.renderedHtml);
}
},
error: function () {
console.log("inside error");
}
});
}
function addOffDay(e) {
var tomorrow = moment()
.add(1, "days")
.format("DD-MM-YYYY");
jQuery("#offday_Div").append(
'<div class="row">' +
'<div class="col-md-2">' +
'<div class="form-group">' +
'<input type="date" name="off_day[]">' +
'</div>' +
'</div>' +
'<div class="col-md-1">' +
'<div class="form-group">' +
'<button type="button" class="btn btn-danger btn-xs" onClick="this.parentNode.parentNode.parentNode.remove();">X</button>' +
'</div>' +
'</div>' +
'</div>'
);
// alert();
}
function saveInstructor(type, update_ins_id = "") {
if (jQuery("#createinstructor").parsley().validate()) {
jQuery(".css_loader").show();
var new_items = {};
var days = [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
];
jQuery.each(days, function (i, day) {
var outerArray = [];
jQuery("#" + day + "_container .new_data").each(function (i, obj) {
var innerArr = {};
// var session = jQuery(this)
// .find(".session_sel")
// .val();
var loc = jQuery(this)
.find(".loc_sel")
.val();
var start = jQuery(this)
.find(".loc_start")
.val();
var end = jQuery(this)
.find(".loc_end")
.val();
if (loc != "" && start != "" && end != "") {
// innerArr.session = session;
innerArr.location = loc;
innerArr.start = start;
innerArr.end = end;
outerArray.push(innerArr);
}
});
new_items[day] = outerArray;
});
var existing_items = {};
if (type == "update") {
jQuery.each(days, function (i, day) {
var outerArray = [];
jQuery("#" + day + "_container .existing_data").each(function (i, obj) {
var innerArr = {};
var id = jQuery(this)
.find(".existing_data_id")
.val();
// var session = jQuery(this)
// .find(".session_sel")
// .val();
var loc = jQuery(this)
.find(".loc_sel")
.val();
var start = jQuery(this)
.find(".loc_start")
.val();
var end = jQuery(this)
.find(".loc_end")
.val();
if (loc != "" && start != "" && end != "" ) {
innerArr.id = id;
// innerArr.session = session;
innerArr.location = loc;
innerArr.start = start;
innerArr.end = end;
outerArray.push(innerArr);
}
});
existing_items[day] = outerArray;
});
}
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "save_instructor",
type,
update_ins_id,
form_data: jQuery("#createinstructor").serialize(),
appointment_days_new: new_items,
appointment_days_existing: existing_items
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
if (type == "save") {
setTimeout(function () {
location.reload();
}, 2000);
// jQuery("#createinstructor")[0].reset();
// var templateUrl = "<?= admin_url(); ?>";
} else {
setTimeout(function () {
location.reload();
}, 2000);
}
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function saveSupervisor(type, update_ins_id = "") {
if (jQuery("#createinstructor").parsley().validate()) {
jQuery(".css_loader").show();
var new_items = {};
var days = [
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
];
jQuery.each(days, function (i, day) {
var outerArray = [];
jQuery("#" + day + "_container .new_data").each(function (i, obj) {
var innerArr = {};
// var session = jQuery(this)
// .find(".session_sel")
// .val();
var loc = jQuery(this)
.find(".loc_sel")
.val();
var start = jQuery(this)
.find(".loc_start")
.val();
var end = jQuery(this)
.find(".loc_end")
.val();
if (loc != "" && start != "" && end != "") {
// innerArr.session = session;
innerArr.location = loc;
innerArr.start = start;
innerArr.end = end;
outerArray.push(innerArr);
}
});
new_items[day] = outerArray;
});
var existing_items = {};
if (type == "update") {
jQuery.each(days, function (i, day) {
var outerArray = [];
jQuery("#" + day + "_container .existing_data").each(function (i, obj) {
var innerArr = {};
var id = jQuery(this)
.find(".existing_data_id")
.val();
// var session = jQuery(this)
// .find(".session_sel")
// .val();
var loc = jQuery(this)
.find(".loc_sel")
.val();
var start = jQuery(this)
.find(".loc_start")
.val();
var end = jQuery(this)
.find(".loc_end")
.val();
if (loc != "" && start != "" && end != "" ) {
innerArr.id = id;
// innerArr.session = session;
innerArr.location = loc;
innerArr.start = start;
innerArr.end = end;
outerArray.push(innerArr);
}
});
existing_items[day] = outerArray;
});
}
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "save_instructor1",
type,
update_ins_id,
form_data: jQuery("#createinstructor").serialize(),
appointment_days_new: new_items,
appointment_days_existing: existing_items
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
if (type == "save") {
setTimeout(function () {
location.reload();
}, 2000);
// jQuery("#createinstructor")[0].reset();
// var templateUrl = "<?= admin_url(); ?>";
} else {
setTimeout(function () {
location.reload();
}, 2000);
}
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function editModal(data, id) {
var credit = data.value;
jQuery("#updateCredit").attr("value", id);
jQuery("#creditNumber").attr("value", credit);
}
function updateCredit(data) {
var id = data.value;
var credit = jQuery("#creditNumber").val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "update_credits",
credit,
id
},
success: function (response) {
if (response.status) {
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function editChildModal(id) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_child_info",
'id': id
},
success: function (response) {
if (response.status) {
jQuery("#ChildBody").empty().append(response.renderedHtml);
jQuery("#editChildModal").modal('show');
jQuery(".css_loader").hide();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function deleteChildModal(id) {
jQuery("#deleteChildModal").modal('show');
jQuery('#deleteChildBtn').val(id);
}
function deleteChild() {
jQuery(".css_loader").show();
jQuery("#deleteChildBtn").attr('disabled', true);
child_id = jQuery('#deleteChildBtn').val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "delete_child_info",
child_id
},
success: function (response) {
if (response.status) {
jQuery('#deleteChildModal').modal('hide');
toastr.success(response.message);
location.reload();
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function updateChild() {
jQuery(".css_loader").show();
jQuery("#updateChildBtn").attr('disabled', true);
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "update_child_info",
data: jQuery('#ChildForm').serialize()
},
success: function (response) {
if (response.status) {
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
// start of Appointment Booking Form
function enableLocations(elm) {
invokeResetFollowingfn(elm, 'date');
invokeResetFollowingfn(elm, 'package');
if (elm.value == "") {
return false;
}
var target_parent = jQuery(elm).parents('div.outerGroup');
var package = jQuery(target_parent).find(".session_sel").val();
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_locations_based_on_day",
date: elm.value,
package: package,
customerID: 0,
},
success: function (response) {
var appendHtml = "";
if (response.status) {
appendHtml += '<option value="">-- All Locations --</option>';
response.locations.forEach(element => {
appendHtml += '<option value="' + element.id + '">' + element.name + '</option>';
});
} else {
jQuery(target_parent).find(".location_sel").prop("disabled", true);
appendHtml = '<option value="">' + response.message + '</option>';
// toastr.error(response.message);
if (response.message2 != '') {
jQuery('#booking_error_modalBody').html('<p><strong>' + response.message2 + '</strong></p>');
jQuery('#booking_error_modal').modal('show');
}
}
jQuery(target_parent).find(".location_sel").empty().append(appendHtml).val('').trigger('change');
jQuery(".css_loader").hide();
},
error: function (data) {
console.log("inside error");
}
});
}
function enableLocations_admin(elm) {
// alert(jQuery("#sel_customer").val());
invokeResetFollowingfn(elm, 'date');
invokeResetFollowingfn(elm, 'package');
if (elm.value == "") {
return false;
}
var target_parent = jQuery(elm).parents('div.outerGroup');
var package = jQuery(target_parent).find(".session_sel").val();
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_locations_based_on_day",
date: elm.value,
package: package,
customerID: jQuery("#sel_customer").val(),
},
success: function (response) {
var appendHtml = "";
if (response.status) {
appendHtml += '<option value="">-- All Locations --</option>';
response.locations.forEach(element => {
appendHtml += '<option value="' + element.id + '">' + element.name + '</option>';
});
} else {
jQuery(target_parent).find(".location_sel").prop("disabled", true);
appendHtml = '<option value="">' + response.message + '</option>';
// toastr.error(response.message);
if (response.message2 != '') {
jQuery('#booking_error_modalBody').html('<p><strong>' + response.message2 + '</strong></p>');
jQuery('#booking_error_modal').modal('show');
}
}
jQuery(target_parent).find(".location_sel").empty().append(appendHtml).val('').trigger('change');
jQuery(".css_loader").hide();
},
error: function (data) {
console.log("inside error");
}
});
}
function getTimeSlots(elm) {
invokeResetFollowingfn(elm, 'location');
if (elm.value == "") {
return false;
}
console.log();
var target_parent = jQuery(elm).parents('div.outerGroup');
var date = jQuery(target_parent).find(".date_sel ").val();
var location_id = jQuery(target_parent).find(".location_sel").val();
var user_id = jQuery(target_parent).find(".user_sel").val();
var session_sel = jQuery(target_parent).find(".session_sel").val();
var form_data = jQuery("#createAppointment").serialize();
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_time_slots",
date,
session_sel,
location_id,
user_id,
form_data
},
success: function (response) {
if (response.status) {
if(response.validation==0)
{
toastr.error(response.message);
}
jQuery(target_parent).find('.slot_sel_start').empty();
jQuery(target_parent).find('.slot_sel_end').empty();
//jQuery(target_parent).find('.session_sel').empty();
jQuery(target_parent).find(".slot_sel_start").prop("disabled", false);
// jQuery(target_parent).find(".slot_sel_end").prop("disabled", false);
jQuery(target_parent).find(".slot_sel_start").append('<option value="">--Choose--</option>' + response.start_timings).val('').trigger('change');
jQuery(target_parent).find(".slot_sel_end").append('<option value="">--Choose--</option>' + response.end_timings).val('').trigger('change');
//jQuery(target_parent).find(".session_sel").append('<option value="">--Choose--</option>' + response.package).val('').trigger('change');
} else {
if(response.validation==0)
{
toastr.error(response.message);
}
jQuery(".slot_sel_start").empty();
jQuery(".slot_sel_end").empty();
var appendStart = '<option value="">' + response.message + '</option>';
// var appendEnd = '<option value="">'+ response.message +'</option>';
jQuery(target_parent).find(".slot_sel_start").append(appendStart).val('').trigger('change');
}
jQuery(".css_loader").hide();
},
error: function (data) {
console.log("inside error");
}
});
}
function getEndTimeSlots(elm) {
var target_parent = jQuery(elm).parents('div.outerGroup');
if (elm.value) {
jQuery(target_parent).find(".slot_sel_end").prop("disabled", false);
} else {
jQuery(target_parent).find(".slot_sel_end").prop("disabled", true);
}
}
function enablePurchaseOrders(elm) {
if (elm.value == "") {
return false;
}
invokeResetFollowingfn(elm, 'time');
}
function getChildren(elm) {
invokeResetFollowingfn(elm, 'purchase_order');
if (elm.value == "") {
var target_parent = jQuery(elm).parents('div.outerGroup');
jQuery(".date_sel").prop('disabled',true);
jQuery(target_parent).find(".date_sel").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".location_sel").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".slot_sel_start").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".slot_sel_end").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".purchase_order_sel").val('').trigger('change').prop("disabled", true);
}
var target_parent = jQuery(elm).parents('div.outerGroup');
jQuery(target_parent).find(".date_sel").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".location_sel").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".slot_sel_start").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".slot_sel_end").val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".purchase_order_sel").val('').trigger('change').prop("disabled", true);
var pur_sess_id = jQuery(elm).val();
// For managing bookings from admin panel
var user_id = null;
if (jQuery("#sel_customer").length) {
user_id = jQuery("#sel_customer").val();
}
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_child",
pur_sess_id,
user_id
},
success: function (response) {
jQuery(target_parent).find(".purchase_order_sel").empty().append(response.renderedHtml).val('').trigger('change').prop("disabled", false);
jQuery(".css_loader").hide();
jQuery(".date_sel").prop('disabled',false);
},
error: function (data) {
jQuery(".css_loader").hide();
console.log("inside error");
jQuery(".date_sel").prop('disabled',true);
}
});
}
function setPurchaseData(elm) {
if (elm.value == "") {
return false;
}
var target_parent = jQuery(elm).parents('div.outerGroup');
var id = jQuery('option:selected', elm).attr('data-id');
jQuery(target_parent).find(".order_session").val(id);
}
// end of Appointment Booking Form
function saveAppointment() {
var encrypted_user_id = jQuery(".u_id").val();
if (jQuery("#createAppointment").parsley().validate()) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "save_appointment",
'form_data': jQuery("#createAppointment").serialize(),
encrypted_user_id
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
// jQuery("#createAppointment")[0].reset();
// getDatePicker([]);
// jQuery(".date_sel").prop('disabled',true);
// jQuery(".slot_sel").prop('disabled',true);
} else {
// toastr.error(response.message);
if (response.infofailure) {
var appendinfo = '<p style="text-align: justify;"><strong>' + response.infofailure + '</strong></p>';
} else {
var appendinfo = '';
}
jQuery('#booking_error_modalBody').html('<p><strong>' + response.message + '</strong></p>' + appendinfo);
jQuery('#booking_error_modal').modal('show');
}
},
error: function (data) {
toastr.error(data.message);
}
});
}
}
function openCancelWarningModal(appt, pur) {
var appt_pur_ids = appt + '|' + pur;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_cancel_warning_modal",
"appointment_id": appt
},
success: function (response) {
if (response.status) {
jQuery("#cancelWarningModal #proceedBtn").attr("appt_pur_ids", appt_pur_ids);
jQuery("#cancelWarningModal #appendSavedCardsDiv").empty().append(response.renderedHtml);
jQuery("#cancelWarningModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function cancelMyAppointment() {
var appt_pur_ids = jQuery("#cancelWarningModal #proceedBtn").attr("appt_pur_ids");
// Checking if the appointment cancellation requires cancellation fee or not
if (jQuery('#is_chargable').length && jQuery('#is_chargable').val() == '9zayp') {
var form_data = {
action: "cancel_my_appointment",
appt_pur_ids
}
} else {
if (!jQuery("#cancelWarningModal #savedCard_id").val()) {
toastr.error('Please choose a Card.');
return;
}
var savedCard_id = jQuery("#cancelWarningModal #savedCard_id").val();
var form_data = {
action: "cancel_my_appointment",
appt_pur_ids,
savedCard_id
}
}
jQuery("#cancelWarningModal").modal('hide');
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: form_data,
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openAddChildDetailsModal(appt) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_add_child_details_modal",
"appointment_id": appt
},
success: function (response) {
if (response.status) {
jQuery("#addChildDetailsModal #appendChildDetailsDiv").empty().append(response.renderedHtml);
jQuery("#addChildDetailsModal").modal('show');
// Hide update button
if (response.target == 'update') {
jQuery("#addChildDetailsModal .btn-primary").remove();
}
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function addChildDetails() {
if (jQuery("#team_child_detailsForm").parsley().validate()) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "save_team_child_details",
'form_data': jQuery("#team_child_detailsForm").serialize()
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
jQuery("#addChildDetailsModal").modal('hide');
toastr.success(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function openCapacityModal(session_id) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_capacity_modal",
session_id
},
success: function (response) {
if (response.status) {
jQuery("#editCapacityModal #appendCapacityDiv").empty().append(response.renderedHtml);
jQuery("#editCapacityModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openGradeModal(id) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_grade_modal",
id
},
success: function (response) {
if (response.status) {
jQuery("#editCapacityModal #appendCapacityDiv").empty().append(response.renderedHtml);
jQuery("#editCapacityModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openeditGradeModal(id) {
jQuery("#level").removeAttr("required");
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_grade_modal",
id
},
success: function (response) {
if (response.status) {
jQuery("#level").removeAttr("required");
jQuery("#editCapacityModal #appendCapacityDiv").empty().append(response.renderedHtml);
jQuery("#editCapacityModal").modal('show');
if (response.type == 1) {
jQuery("#level").removeAttr("required");
jQuery('#lower').show();
jQuery('#higher').hide();
jQuery('#grade_level').hide();
} else {
jQuery("#level").removeAttr("required");
jQuery('#higher').show();
jQuery('#lower').hide();
jQuery('#grade_level').hide();
}
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function appendValue() {
document.getElementById("higher_grade").value = document.getElementById("lower_grade").value;
}
function updateCapacity() {
var pass_session_id = jQuery("#editCapacityModal #pass_session_id").val();
var min_capacity = jQuery("#editCapacityModal #min_capacity").val();
var max_capacity = jQuery("#editCapacityModal #max_capacity").val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "update_session_capacity",
pass_session_id,
min_capacity,
max_capacity
},
success: function (response) {
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
jQuery("#editCapacityModal").modal('hide');
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function appendid(elm) {
jQuery("#cancelbtn").attr("data-appointment_id", elm.value);
}
function openCancelModal(appointments_id, cancelled_by = 0) {
if (appointments_id.toString().split(',').length > 1) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_cancel_modal",
appointments_id
},
success: function (response) {
if (response.status) {
jQuery('#cancelmsg').html(response.renderedHtml);
jQuery("#appointmentModal").modal("show");
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
} else {
jQuery('#cancelmsg').empty();
jQuery("#cancelbtn").attr("data-appointment_id", appointments_id);
jQuery('#cancelbtn').val(cancelled_by);
jQuery("#appointmentModal").modal("show");
}
// alert();
}
function CancelapproveModal(appointments_id, cancelled_by = 0) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "render_approve_modal",
'appointment_id': appointments_id
},
success: function (response) {
if (response.status) {
jQuery('#charge_info').html(response.html);
}
jQuery("#cancelapprovebtn").attr("data-appointment_id", appointments_id);
jQuery('#cancelapprovebtn').val(cancelled_by);
jQuery("#CancelapproveModal").modal("show");
},
error: function (data) {
console.log("inside error");
}
});
}
function approveModalCopy(appointments_id, cancelled_by = 0) {
jQuery("#approvebtn").attr("data-appointment_id", appointments_id);
jQuery('#approvebtn').val(cancelled_by);
jQuery("#approveModal").modal("show");
}
function approveModal(appointments_id, cancelled_by = 0) {
//var id = appointments_id;
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "GET",
data: {
action: "get_appointments",
appointments_id: appointments_id
},
success: function (response) {
if (response.is_cancelled == 0) {
jQuery("#approvebtn").attr("data-appointment_id", appointments_id);
jQuery('#approvebtn').val(cancelled_by);
jQuery("#approveModal").modal("show");
} else {
jQuery("#cancelMsgModal").modal("show");
}
},
error: function () {
console.log("inside error");
}
});
}
function cancelAppoint(ele) {
if (jQuery('#del_appointment_id').val() == 0) {
toastr.error('Please choose an Appointment');
return;
}
jQuery(ele).prop('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "cancel_appointments",
'appointment_id': jQuery(ele).attr("data-appointment_id"),
'cancelled_by': jQuery(ele).attr("value")
},
success: function (response) {
jQuery(".css_loader").hide();
toastr.success(response.message);
setTimeout(function () {
jQuery("#appointmentModal").hide();
location.reload();
}, 1000);
},
error: function (data) {
console.log("inside error");
}
});
}
function openappointmentApproveModal(appointments_id) {
jQuery("#aprveTime").attr("data-appointment_id", appointments_id);
jQuery("#appointmentApproveModal").modal("show");
}
function openappointmentRejectModal(appointments_id) {
jQuery("#rejectTime").attr("data-appointment_id", appointments_id);
jQuery("#appointmentRejectModal").modal("show");
}
function approveTimeAppoint(ele) {
// alert();
jQuery(ele).prop('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "appointmentModifyUpdateAdmin",
'appointment_id': jQuery(ele).attr("data-appointment_id"),
'status': 1
},
success: function (response) {
jQuery(".css_loader").hide();
toastr.success(response.message);
setTimeout(function () {
jQuery("#appointmentModal").hide();
location.reload();
}, 1000);
},
error: function (data) {
console.log("inside error");
}
});
}
function rejectTimeAppoint(ele) {
if (jQuery('#del_appointment_id').val() == 0) {
toastr.error('Please choose an Appointment');
return;
}
jQuery(ele).prop('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "appointmentModifyUpdateAdmin",
'appointment_id': jQuery(ele).attr("data-appointment_id"),
'status': 2
},
success: function (response) {
jQuery(".css_loader").hide();
toastr.success(response.message);
setTimeout(function () {
jQuery("#appointmentModal").hide();
location.reload();
}, 1000);
},
error: function (data) {
console.log("inside error");
}
});
}
function openAddChildModal(user_id) {
jQuery.ajax({
url: ajaxurl,
method: "get",
dataType: "json",
data: {
action: "render_or_append_new_child_admin",
user_id
},
success: function (response) {
if (response.status) {
jQuery("#ChildBodyAdmin").empty().append(response.renderedHtml);
jQuery("#addNewChildAdminModal").modal('show');
}
},
error: function (data) {
console.log("inside error");
}
});
}
function addChildAdmin() {
if (jQuery("#ChildFormAdmin").parsley().validate()) {
jQuery(".css_loader").show();
jQuery("#addChildSubmitBtn").attr('disabled', true);
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "add_child_info_admin",
data: jQuery('#ChildFormAdmin').serialize()
},
success: function (response) {
if (response.status) {
toastr.success(response.message);
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function cancelapproveAppoint(ele) {
jQuery(ele).prop('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "cancelapproveAppoint",
'appointment_id': jQuery(ele).attr("data-appointment_id"),
'cancelled_by': jQuery(ele).attr("value"),
'savedCard_id2': jQuery('#savedCard_id2').val()
},
success: function (response) {
jQuery(".css_loader").hide();
toastr.success(response.message);
setTimeout(function () {
jQuery("#appointmentModal").hide();
location.reload();
}, 1000);
},
error: function (data) {
console.log("inside error");
}
});
}
function approveAppoint(ele) {
jQuery(ele).prop('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "approveAppoint",
'appointment_id': jQuery(ele).attr("data-appointment_id"),
'cancelled_by': jQuery(ele).attr("value")
},
success: function (response) {
jQuery(".css_loader").hide();
toastr.success(response.message);
setTimeout(function () {
jQuery("#appointmentModal").hide();
location.reload();
}, 1000);
},
error: function (data) {
console.log("inside error");
}
});
}
function appendAssignInfo(elm) {
var appointment_id = elm.value;
if (elm.value != "0") {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_ins_assign_modal",
appointment_id
},
success: function (response) {
if (response.status) {
jQuery("#assignModal #appendAssignDiv").append(response.renderedHtml);
jQuery("#pass_appointment_id").val(appointment_id);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
} else {
jQuery('.timingRow').remove();
}
}
function openAssignModal(appointment_id) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_ins_assign_modal",
appointment_id
},
success: function (response) {
if (response.status) {
jQuery("#assignModal #appendAssignDiv").empty().append(response.renderedHtml);
jQuery("#assignModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openAssignModalNew(appointment_id) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_ins_assign_modal_new",
appointment_id
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
jQuery("#assignModal #appendAssignDiv").empty().append(response.renderedHtml);
jQuery("#assignModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openAssignModalNewIndividual(appointment_id) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_ins_assign_modal_newIndividual",
appointment_id
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
jQuery("#assignModal #appendAssignDiv").empty().append(response.renderedHtml);
jQuery("#assignModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function markasbwc(cid){
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "markasbwc",
cid
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function unmarkasbwc(cid){
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "unmarkasbwc",
cid
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function markasselfregister(cid){
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "markasselfregister",
cid
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function unmarkasselfregister(cid){
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "unmarkasselfregister",
cid
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function getInstructorListing(elm) {
var appointment_id = jQuery('#pass_appointment_id').val();
var location_id = jQuery('#location_id').val();
jQuery(".css_loader").show();
jQuery('.insblock').hide();
if (elm.value) {
var timing = elm.value;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_instructor_list",
appointment_id,
location_id,
timing
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
// toastr.success(response.message);
jQuery('#assign_instructor').html(response.renderedHtml);
jQuery('.insblock').show();
jQuery('#assign_instructor').multiselect({
buttonWidth: '250px',
widthSynchronizationMode: 'ifPopupIsWider',
nonSelectedText: 'Choose an Instrutor'
});
jQuery('#assign_instructor').multiselect('rebuild');
var valArr = response.instructors;
if (valArr.length > 0) {
jQuery('#assign_instructor').trigger('click');
var i = 0, size = valArr.length;
for (i; i < size; i++) {
jQuery('#assign_instructor').multiselect('select', valArr[i]);
}
}
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}else{
jQuery(".css_loader").hide();
}
}
function getInstructorTimings(elm) {
var appointment_id = jQuery('#pass_appointment_id').val();
if (elm.value) {
var instructor_id = elm.value;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_ins_assign_modal_timings",
appointment_id,
instructor_id
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
// toastr.success(response.message);
jQuery('#assign_instructor_time').html(response.renderedHtml);
jQuery('#assign_instructor_time').removeAttr('disabled');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function checkInstructorAvailability(elm) {
var appointment_time = elm.value;
var inst_id = jQuery('#assign_instructor').val();
var appointment_id = jQuery('#pass_appointment_id').val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_availability_message",
inst_id,
appointment_id,
appointment_time
},
success: function (response) {
jQuery("#AssignMessage").html(response.message);
},
error: function (data) {
console.log("inside error");
}
});
}
function assignInstructor() {
if (jQuery("#assignModal #cust_appointment_id").val() == 0) {
toastr.error('Please choose an Appointment');
return;
}
if (!jQuery("#assignModal #assign_instructor").val()) {
toastr.error('Please choose an Instructor.');
return;
}
if (!jQuery("#assignModal #assign_instructor_time").val()) {
toastr.error('Please choose a time slot.');
return;
}
jQuery("#assignModal").modal('hide');
jQuery(".css_loader").show();
var pass_appointment_id = jQuery("#assignModal #pass_appointment_id").val();
var instructor_id = jQuery("#assignModal #assign_instructor").val();
var appointment_time = jQuery("#assignModal #assign_instructor_time").val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "instructor_assign",
pass_appointment_id,
instructor_id,
appointment_time
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function assignInstructor_new() {
if (jQuery("#assignModal #cust_appointment_id").val() == 0) {
toastr.error('Please choose an Appointment');
return;
}
if (!jQuery("#assignModal #assign_instructor").val()) {
toastr.error('Please choose an Instructor.');
return;
}
if (!jQuery("#assignModal #assign_instructor_time").val()) {
toastr.error('Please choose a time slot.');
return;
}
var pass_appointment_id = jQuery("#assignModal #pass_appointment_id").val();
var instructor_id = jQuery("#assignModal #assign_instructor").val();
var appointment_time = jQuery("#assignModal #assign_instructor_time").val();
if(instructor_id != ""){
jQuery("#assignModal").modal('hide');
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "instructor_assign_new",
pass_appointment_id,
instructor_id,
appointment_time
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}else{
toastr.error("Please choose an instructor");
jQuery(".css_loader").hide();
return false;
}
}
function openModifyAppointmentTimeModal(appointment_id) {
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "POST",
data: {
action: "render_available_timings",
appointment_id
},
success: function (response) {
jQuery("#modifyAppointmentTimeModal .appendDiv").empty().append(response.renderedHtml);
jQuery("#modifyAppointmentTimeModal #saveBtn").attr("data-appointment_id", appointment_id);
jQuery("#modifyAppointmentTimeModal").modal("show");
},
error: function (data) {
console.log("inside error");
}
});
}
function saveNewTimings(elm) {
if (!jQuery("#modifyAppointmentTimeModal #new_slot1").val()) {
toastr.error('Please choose a start time.');
return;
}
if (!jQuery("#modifyAppointmentTimeModal #new_slot2").val()) {
toastr.error('Please choose an end time.');
return;
}
var new_slot1 = jQuery("#modifyAppointmentTimeModal #new_slot1").val();
var new_slot2 = jQuery("#modifyAppointmentTimeModal #new_slot2").val();
var start = new Date("01/01/2007 " + new_slot1);
var end = new Date("01/01/2007 " + new_slot2);
if (start > end) {
toastr.error('Start time must be less than End time.');
return;
}
if (new_slot1 == new_slot2) {
toastr.error('Start time and End time cannot be Same.');
return;
}
jQuery("#modifyAppointmentTimeModal").hide();
jQuery(".css_loader").show();
var appt_id = jQuery(elm).attr('data-appointment_id');
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "post",
data: {
action: "request_timing_change",
appt_id,
'new_slot1': jQuery("#modifyAppointmentTimeModal #new_slot1").val(),
'new_slot2': jQuery("#modifyAppointmentTimeModal #new_slot2").val()
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
setTimeout(function () {
location.reload();
}, 1000);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function updateEmail(data) {
var id = data.value;
var form_data = jQuery('#updateEmail').serialize();
if (jQuery("#updateEmail").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "update_email",
'form_data': jQuery('#updateEmail').serialize(),
id
},
success: function (response) {
if (response.status) {
toastr.success(response.message);
// setTimeout(function() {
// jQuery("#assignModal").modal('hide');
// location.reload();
// }, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
})
}
}
function ApplyFilter() {
var status = jQuery("#appt_status").val();
var start_date = jQuery("#start_date").val();
var end_date = jQuery("#end_date").val();
var location = jQuery("#appt_location").val();
var type = jQuery("#appt_type").val();
// alert(type);
var url = window.location.href + "&status=" + status + "&start_date=" + start_date + "&end_date=" + end_date + "&location=" + location + "&type=" + type;
window.location.replace(url);
}
// Booking Clone
function cloneAppointment(user_id) {
// alert();
if (!jQuery("#createAppointment").parsley().validate()) {
jQuery('#booking_error_modalBody').html('<p><strong>Please fill all existing fields before initiating multiple booking.</strong></p>');
jQuery('#booking_error_modal').modal('show');
return false;
}
var form_data = jQuery("#createAppointment").serialize();
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_clone_appointment",
user_id,
form_data,
'clone_counter': jQuery('.outerGroup').length
},
success: function (response) {
if (response.status) {
jQuery("#cloneApptDiv").append(response.renderedHtml);
jQuery('.purchase_order_sel').select2();
jQuery('.session_sel').select2();
jQuery('.location_sel').select2();
jQuery('.slot_sel_start').select2();
jQuery('.slot_sel_end').select2();
getDatePicker([]);
jQuery(".css_loader").hide();
} else {
jQuery(".css_loader").hide();
if (response.infofailure) {
var appendinfo = '<p style="text-align: justify;"><strong>' + response.infofailure + '</strong></p>';
} else {
var appendinfo = '';
}
jQuery('#booking_error_modalBody').html('<p><strong>' + response.message + '</strong></p>' + appendinfo);
jQuery('#booking_error_modal').modal('show');
}
},
error: function (data) {
console.log("inside error");
}
});
}
function getMergeMessage(elm) {
var inst_id = elm.value;
var appt_id = jQuery('#sel_first_session').val();
var sec_appt_id = jQuery('#sel_second_session').val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_merge_message",
"appointment_id": appt_id,
"sec_appointment_id": sec_appt_id,
"instructor_id": inst_id
},
success: function (response) {
jQuery("#AssignMessage2").html(response.message);
},
error: function (data) {
console.log("inside error");
}
});
}
function openTabs(evt, tabName) {
var i, tabcontent, tablinks;
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
function setAppointmentStatus_copy(data, status) {
var id = data.value;
if (jQuery('#savedCard_id3').val() == 0) {
toastr.error('Please choose a card.');
return;
}
jQuery('#chargeBtn').attr('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "set_appointment_status",
id,
status,
savedCard_id3: jQuery('#savedCard_id3').val()
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status == 2) {
jQuery(".css_loader").hide();
jQuery('#chargeBtn').val(id);
jQuery('#ChargeModal #ChargeModalBody').empty().append(response.html);
jQuery("#ChargeModal").modal('show');
jQuery('#chargeBtn').removeAttr('disabled');
} else if (response.status == 1) {
jQuery("#ChargeModal").modal('hide');
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else if (response.status == 0) {
jQuery("#ChargeModal").modal('hide');
toastr.error(response.message);
setTimeout(function () {
location.reload();
}, 1000);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function setAppointmentStatus(data, status) {
var id = data.value;
jQuery.ajax({
url: ajaxurl,
dataType: "json",
method: "GET",
data: {
action: "get_appointments",
appointments_id: id
},
success: function (response) {
if (response.is_cancelled == 0) {
if (jQuery('#savedCard_id3').val() == 0) {
toastr.error('Please choose a card.');
return;
}
jQuery('#chargeBtn').attr('disabled', true);
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "set_appointment_status",
id,
status,
savedCard_id3: jQuery('#savedCard_id3').val()
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status == 2) {
jQuery(".css_loader").hide();
jQuery('#chargeBtn').val(id);
jQuery('#ChargeModal #ChargeModalBody').empty().append(response.html);
jQuery("#ChargeModal").modal('show');
jQuery('#chargeBtn').removeAttr('disabled');
} else if (response.status == 1) {
jQuery("#ChargeModal").modal('hide');
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else if (response.status == 0) {
jQuery("#ChargeModal").modal('hide');
toastr.error(response.message);
setTimeout(function () {
location.reload();
}, 1000);
}
},
error: function (data) {
console.log("inside error");
}
});
} else {
jQuery("#cancelMsgModal").modal("show");
}
},
error: function () {
console.log("inside error");
}
});
}
function invokeResetFollowingfn(elm, par) {
// Alter Current Div data
var target_parent = jQuery(elm).parents('div.outerGroup');
switch (par) {
case 'date':
jQuery(target_parent).find(".location_sel").val('').trigger('change').prop("disabled", false);
jQuery(target_parent).find(".slot_sel_start").empty().append('<option value=""> -- Choose -- </option>').val('').trigger('change').prop("disabled", true);
jQuery(target_parent).find(".slot_sel_end").empty().append('<option value=""> -- Choose -- </option>').val('').trigger('change').prop("disabled", true);
//jQuery(target_parent).find(".session_sel").val('').trigger('change').prop("disabled", true);
//jQuery(target_parent).find(".purchase_order_sel").empty().append('<option value=""> -- Choose Child Name -- </option>').val('').trigger('change').prop("disabled", true);
break;
case 'location':
jQuery(target_parent).find(".slot_sel").empty().append('<option value=""> -- Choose Time Slot -- </option>').val('').trigger('change').prop("disabled", true);
//jQuery(target_parent).find(".session_sel").val('').trigger('change').prop("disabled", true);
//jQuery(target_parent).find(".purchase_order_sel").empty().append('<option value=""> -- Choose Child Name -- </option>').val('').trigger('change').prop("disabled", true);
break;
case 'time':
//jQuery(target_parent).find(".session_sel").val('').trigger('change').prop("disabled", false);
// jQuery(target_parent).find(".purchase_order_sel").empty().append('<option value=""> -- Choose Child Name -- </option>').val('').trigger('change').prop("disabled", true);
break;
case 'purchase_order':
//jQuery(target_parent).find(".purchase_order_sel").empty().append('<option value=""> -- Choose Child Name -- </option>').val('').trigger('change').prop("disabled", false);
break;
}
// Alter Multiple Other Div data
jQuery(elm).parents('div.outerGroup').nextAll().each(function (i, obj) {
jQuery(this).find(".date_sel").datepicker('setDate', null);
jQuery(this).find(".location_sel").val('').trigger('change').prop("disabled", false);
jQuery(this).find(".slot_sel_start").empty().append('<option value=""> -- Choose -- </option>').val('').trigger('change').prop("disabled", false);
jQuery(this).find(".slot_sel_end").empty().append('<option value=""> -- Choose -- </option>').val('').trigger('change').prop("disabled", false);
// jQuery(this).find(".session_sel").val('').trigger('change').prop("disabled", false);
//jQuery(this).find(".purchase_order_sel").empty().append('<option value=""> -- Choose Child Name -- </option>').val('').trigger('change').prop("disabled", false);
});
}
function setAllTimings(day) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "set_all_timings",
day
},
success: function (response) {
if (response.status) {
jQuery("#" + day + "_container").html(response.renderedHtml);
jQuery(".css_loader").hide();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function setAllTimings_admin(day) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "set_all_timings_admin",
day
},
success: function (response) {
if (response.status) {
jQuery("#" + day + "_container").html(response.renderedHtml);
jQuery(".css_loader").hide();
}
},
error: function (data) {
console.log("inside error");
}
});
}
// Admin Dashboard - Trigger Charge Manually
function openManualChargeWarningModal(appt) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_manual_charge_warning_modal",
"appointment_id": appt
},
success: function (response) {
if (response.status) {
jQuery("#manualChargeModal #proceedBtn").attr("data-appt_id", appt);
jQuery("#manualChargeModal #appendSavedCardsDiv").empty().append(response.renderedHtml);
jQuery("#manualChargeModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function triggerManualCharge() {
if (!jQuery("#manualChargeModal #savedCard_id").val()) {
toastr.error('Please choose a Card.');
return;
}
var appt = jQuery("#manualChargeModal #proceedBtn").attr("data-appt_id");
var savedCard_id = jQuery("#manualChargeModal #savedCard_id").val();
jQuery("#manualChargeModal").modal('hide');
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "trigger_manual_charge",
appt,
savedCard_id
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function first_session_change() {
jQuery(".css_loader").show();
jQuery("#openMergeAppointmentsModal #insDiv").empty();
if (!jQuery("#openMergeAppointmentsModal #sel_first_session").val()) {
toastr.error('Please choose an Appointment.');
jQuery("#openMergeAppointmentsModal #appendMergeDiv").empty().append('<h4>Choose Appointment to be Merged</h4>');
jQuery("#openMergeAppointmentsModal #f_add_details").empty();
return;
}
var mix_ids = jQuery("#openMergeAppointmentsModal #sel_first_session").val();
var mix_idsArr = mix_ids.split('|');
var occurance = mix_idsArr.pop();
var start_date = jQuery('#start_date').val();
var end_date = jQuery('#end_date').val();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "fetch_remaining_appointments",
'appt_ids': mix_idsArr.join(","),
'start_date': start_date,
'end_date': end_date
},
success: function (response) {
if (response.status) {
jQuery(".css_loader").hide();
jQuery("#openMergeAppointmentsModal #appendMergeDiv").empty().append(response.renderedHtml);
jQuery("#openMergeAppointmentsModal #f_add_details").empty().append(
'<h4>Additional Details</h4><h5>Current Occupancy : <strong>' + occurance + '</strong></h5>');
}else{
jQuery(".css_loader").hide();
}
},
error: function (data) {
jQuery(".css_loader").hide();
console.log("inside error");
}
});
}
function second_first_change() {
jQuery(".css_loader").show();
if (!jQuery("#openMergeAppointmentsModal #sel_second_session").val()) {
toastr.error('Please choose an Appointment.');
jQuery("#openMergeAppointmentsModal #s_add_details").empty();
return;
}
var mix_ids = jQuery("#openMergeAppointmentsModal #sel_second_session").val();
var appt_ids_two = mix_ids.split('|');
var occurance = appt_ids_two.pop();
var mix_ids = jQuery("#openMergeAppointmentsModal #sel_first_session").val();
var appt_ids_one = mix_ids.split('|');
appt_ids_one.pop();
jQuery("#openMergeAppointmentsModal #s_add_details").empty().append(
'<h4>Additional Details</h4><h5>Current Occupancy : <strong>' + occurance + '</strong></h5>');
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "fetch_available_instructors",
'appt_ids_one': appt_ids_one.join(","),
'appt_ids_two': appt_ids_two.join(","),
},
success: function (response) {
if (response.status) {
jQuery(".css_loader").hide();
jQuery("#openMergeAppointmentsModal #insDiv").empty().append(response.renderedHtml);
jQuery('#assign_instructor').multiselect({
buttonWidth: '250px',
widthSynchronizationMode: 'ifPopupIsWider',
nonSelectedText: 'Choose an Instrutor'
});
jQuery('#assign_instructor').multiselect('rebuild');
}
},
error: function (data) {
jQuery(".css_loader").hide();
console.log("inside error");
}
});
}
function mergeSessions() {
if (!jQuery("#openMergeAppointmentsModal #sel_first_session").val()) {
toastr.error('Please choose an Appointment.');
return;
}
if (!jQuery("#openMergeAppointmentsModal #sel_second_session").val()) {
toastr.error('Please choose an Appointment.');
return;
}
if (!jQuery("#openMergeAppointmentsModal #assign_instructor").val()) {
toastr.error('Please choose an Instructor.');
return;
}
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "merge_sessions",
'form_data': jQuery("#openMergeAppointmentsModal #mergeSessionsFormId").serialize()
},
success: function (response) {
if (response.status) {
jQuery(".css_loader").hide();
toastr.success(response.message);
setTimeout(function () {
jQuery("#openMergeAppointmentsModal").modal('hide');
location.reload();
}, 1000);
}
},
error: function (data) {
jQuery(".css_loader").hide();
console.log("inside error");
}
});
}
function package_on_change(elm) {
var form_id = jQuery(elm).val().split('|');
form_id.pop();
var sel_customer = jQuery("#sel_customer").val();
window.location.href = 'admin.php?page=manual_assign_package&pid=' + form_id + '&cus_id=' + sel_customer;
}
function assignHiddenValue() {
// Filter Only submission made by Admin, by checking if an element exists
if (jQuery("#sel_package").length && jQuery("#sel_customer").length) {
var sel_package = jQuery("#sel_package").val();
var sel_customer = jQuery("#sel_customer").val();
var sel_payment = jQuery('.sel_payment:checked').val();
// if( ! ( jQuery("#sel_package").val() && jQuery("#sel_customer").val() ) ) {
// toastr.error('Please choose Package and Customer.');
// // jQuery(".gform_button").prop("type", "button");
// }
var mixPkg = sel_package.split('|');
var product_id = mixPkg.pop();
jQuery('input[name="input_10"]').val(product_id + '|' + sel_customer);
jQuery('input[name="input_11"]').val(sel_payment);
}
}
// jQuery(document).ready(function(){
// jQuery("#sel_customer").change(function() {
// jQuery(".gform_button").prop("type", "submit");
// });
// jQuery('#gform_13').on('submit', function(event){
// var sel_package = jQuery("#sel_package").val();
// var sel_customer = jQuery("#sel_customer").val();
// if( ! ( jQuery("#sel_package").val() && jQuery("#sel_customer").val() ) ) {
// toastr.error('Please choose Package and Customer.');
// event.preventDefault();
// } else{
// jQuery("#gform_13").trigger("submit",[true]);
// }
// });
// });
function admin_appointment() {
jQuery("#email_template").jqte();
jQuery('.timepicker_demo').clockface();
// Check if booking page
if (jQuery("#createAppointment").length) {
if (jQuery("#sel_customer").length) {
jQuery("#cloneApptDiv").empty();
var user_id = jQuery("#sel_customer").val();
cloneAppointment(user_id);
// alert();
if (jQuery("#admin_booking_show").length) {
jQuery("#admin_booking_show").show();
}
}
}
}
function cloneAppointment_backend() {
var user_id = jQuery("#sel_customer").val();
if (!jQuery("#createAppointment").parsley().validate()) {
jQuery('#booking_error_modalBody').html('<p><strong>Please fill all existing fields before initiating multiple booking.</strong></p>');
jQuery('#booking_error_modal').modal('show');
return false;
}
var form_data = jQuery("#createAppointment").serialize();
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_clone_appointment",
user_id,
form_data,
'clone_counter': jQuery('.outerGroup').length
},
success: function (response) {
if (response.status) {
jQuery("#cloneApptDiv").append(response.renderedHtml);
jQuery('.purchase_order_sel').select2();
jQuery('.session_sel').select2();
jQuery('.location_sel').select2();
jQuery('.slot_sel_start').select2();
jQuery('.slot_sel_end').select2();
getDatePicker([]);
jQuery(".css_loader").hide();
} else {
jQuery(".css_loader").hide();
// toastr.error(response.message);
if (response.infofailure) {
var appendinfo = '<p style="text-align: justify;"><strong>' + response.infofailure + '</strong></p>';
} else {
var appendinfo = '';
}
jQuery('#booking_error_modalBody').html('<p><strong>' + response.message + '</strong></p>' + appendinfo);
jQuery('#booking_error_modal').modal('show');
}
},
error: function (data) {
console.log("inside error");
}
});
}
function viewTeamDetailsModel(appt) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_add_child_details_modal",
"appointment_id": appt
},
success: function (response) {
if (response.status) {
jQuery("#addChildDetailsModal #appendChildDetailsDiv").empty().append("<div>Customer not filled details </div>");
jQuery("#addChildDetailsModal .btn-primary").remove();
jQuery("#addChildDetailsModal").modal('show');
// Hide update button
if (response.target == 'update') {
jQuery("#addChildDetailsModal .btn-primary").remove();
jQuery("#addChildDetailsModal #appendChildDetailsDiv").empty().append(response.renderedHtml);
jQuery("#addChildDetailsModal").modal('show');
}
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
function triggerManualCapture(pur_rec_id) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "trigger_manual_capture",
pur_rec_id
},
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
} else {
toastr.error(response.message);
}
setTimeout(function () {
location.reload();
}, 1000);
},
error: function (data) {
console.log("inside error");
}
});
}
// -------------------------
function openSubscriptionPauseModal(customer_purchase_id) {
// alert(customer_purchase_id)
// alert(customer_purchase_id);
jQuery("#pausebtn").attr("data-customer_purchase_id", customer_purchase_id);
jQuery("#SubscriptionPauseModal").appendTo("body").modal("show");
}
function get_count_bookings() {
var location_id = jQuery('#locations').val();
var date = jQuery('#sel_date').val();
if (location_id == "") {
jQuery('#countRow').hide();
jQuery('#BookingsCount').empty();
} else {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "get_bookings_count",
"location_id": location_id,
"date": date
},
success: function (response) {
if (response.status) {
jQuery('#countRow').show();
jQuery('#BookingsCount').empty().append(response.renderedHtml);
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function get_grade() {
var level = jQuery('#level').val();
if (level == "") {
jQuery('#lower').hide();
jQuery('#higher').hide();
} else if(level == "lower") {
jQuery("#lower_grade").prop("required", true);
jQuery("#upper_grade").prop("required", true);
jQuery("#higher_grade").prop("required", false);
jQuery('#lower').show();
jQuery('#higher').hide();
}
else{
jQuery("#higher_grade").prop("required", true);
jQuery("#lower_grade").prop("required", false);
jQuery("#upper_grade").prop("required", false);
jQuery('#higher').show();
jQuery('#lower').hide();
}
}
function SubscriptionPausefun(customer_purchase_id) {
jQuery(".css_loader").show();
var customer_purchase_id = customer_purchase_id;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "Subscription_Pause",
"customer_purchase_id": jQuery(customer_purchase_id).attr("data-customer_purchase_id")
},
success: function (response) {
if (response.status) {
jQuery("#SubscriptionPauseModal").hide();
jQuery(".css_loader").hide();
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openSubscriptionResumeModal(customer_purchase_id) {
jQuery("#resumebtn").attr("data-customer_purchase_id", customer_purchase_id);
jQuery("#SubscriptionResumeModal").appendTo("body").modal("show");
}
function SubscriptionResumefun(customer_purchase_id) {
jQuery(".css_loader").show();
var customer_purchase_id = customer_purchase_id;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "Subscription_Resume",
"customer_purchase_id": jQuery(customer_purchase_id).attr("data-customer_purchase_id")
},
success: function (response) {
if (response.status) {
jQuery("#SubscriptionResumeModal").hide();
jQuery(".css_loader").hide();
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openSubscriptionCancelModal(customer_purchase_id) {
jQuery("#cancelbtn").attr("data-customer_purchase_id", customer_purchase_id);
jQuery("#SubscriptionCancelModal").appendTo("body").modal("show");
}
function SubscriptionCancelfun(customer_purchase_id, is_customer = 0) {
jQuery(".css_loader").show();
var customer_purchase_id = customer_purchase_id;
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "Subscription_cancel",
is_customer,
"customer_purchase_id": jQuery(customer_purchase_id).attr("data-customer_purchase_id")
},
success: function (response) {
if (response.status) {
jQuery("#SubscriptionCancelModal").hide();
jQuery(".css_loader").hide();
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function openNewChildModel(isAppend) {
if (isAppend == 0) {
jQuery(".css_loader").show();
}
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_or_append_new_child",
'isAppend': isAppend
},
success: function (response) {
if (response.status) {
if (isAppend == 1) {
jQuery("#appendNewChildDiv").append(response.renderedHtml);
} else {
jQuery("#appendNewChildDiv").empty().append(response.renderedHtml);
jQuery("#addNewChildModal").modal('show');
}
jQuery(".css_loader").hide();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function saveChild() {
if (jQuery("#createChild").parsley().validate()) {
jQuery(".css_loader").show();
var formData = new FormData();
// console.log(formData);
// console.log("ssssssssssssssssss", document.getElementsByClassName('fileinput').files);
// var file = document.getElementsByClassName('fileinput')[0].files;
// console.log(file);
// var filedata = document.getElementsByName('file').length;
// console.log(filedata);
// var i = 0,
// len = filedata.files.length,
// img, reader, file;
// for (; i < len; i++) {
// file = filedata.files[i];
// formData.append("file", file);
// }
// var fileinputmobile = document.getElementsByClassName('fileinput').files[0];
// console.log(fileinputmobile);
// if(file){
// formData.append("file", file);
// } else {
// formData.append("file", fileinputmobile);
// }
// var totalfiles = document.getElementById('fileinput').files.length;
// for (var index = 0; index < totalfiles; index++) {
// formData.append("files[]", document.getElementById('fileinput').files[index]);
// }
jQuery('.fileinput').each(function (i, file) {
var key = "file" + i;
formData.append(key, jQuery(this)[0].files[0]);
});
// console.log(formData);
formData.append("data", jQuery('#createChild').serialize());
formData.append("action", 'save_child');
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
processData: false,
contentType: false,
data: formData,
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
jQuery('#addchild_error_modalBody').html('<p><strong>' + response.message + '</strong></p>');
jQuery('#addchild_error_modal').modal('show');
}
},
error: function (data) {
toastr.error(data.message);
}
});
}
}
//view all childs
function viewChilds() {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_view_child_details_modal"
},
success: function (response) {
if (response.status) {
jQuery("#viewChildDetailsModal #appendviewChildDetailsDiv").empty().append(response.renderedHtml);
jQuery("#viewChildDetailsModal").modal('show');
} else {
toastr.error(response.message);
}
},
error: function (data) {
console.log("inside error");
}
});
}
// start and end date filter
function ApplyDateFilter() {
var start_date = jQuery("#start_date1").val();
var end_date = jQuery("#end_date1").val();
var url = window.location.href + "&start_date=" + start_date + "&end_date=" + end_date;
window.location.replace(url);
}
// Customer name filter
function ApplyCustNameFilter() {
var name = jQuery("#cust_name").val();
var url = window.location.href + "&search=" + name;
window.location.replace(url);
}
function ApplyPlayerNameFilter() {
var name = jQuery("#cust_name").val();
var url = window.location.href + "&search=" + name;
window.location.replace(url);
}
function editRenewalDate(id) {
jQuery(".css_loader").show();
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "render_renewal_info",
'id': id
},
success: function (response) {
if (response.status) {
jQuery("#ChildBody").empty().append(response.renderedHtml);
jQuery("#editRenewalModal").modal('show');
jQuery(".css_loader").hide();
}
},
error: function (data) {
console.log("inside error");
}
});
}
function updateRenewalDate() {
jQuery("#updateRenewalBtn").attr('disabled', true);
if (jQuery("#RenewalForm").parsley().validate()) {
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
data: {
action: "update_renewal_date",
data: jQuery('#RenewalForm').serialize()
},
success: function (response) {
if (response.status) {
toastr.success(response.message);
location.reload();
}
},
error: function (data) {
console.log("inside error");
}
});
}
}
function updateProfileDet() {
if (jQuery("#updateProfile").parsley().validate()) {
jQuery(".css_loader").show();
var formData = new FormData();
console.log(formData);
var file = document.getElementById('fileinput').files[0];
formData.append("file", file);
formData.append("data", jQuery('#updateProfile').serialize());
formData.append("action", 'update_profile');
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
processData: false,
contentType: false,
data: formData,
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
// jQuery('#addchild_error_modalBody').html('<p><strong>'+response.message+'</strong></p>');
// jQuery('#addchild_error_modal').modal('show');
}
},
error: function (data) {
toastr.error(data.message);
}
});
}
}
function AddComemnt() {
// alert();
if (jQuery("#chatForm").parsley().validate()) {
jQuery(".css_loader").show();
jQuery("#btn_submit").prop("disabled", true);
var formData = new FormData();
console.log(formData);
formData.append("data", jQuery('#chatForm').serialize());
formData.append("action", 'add_comment');
jQuery.ajax({
url: ajaxurl,
method: "post",
dataType: "json",
processData: false,
contentType: false,
data: formData,
success: function (response) {
jQuery(".css_loader").hide();
if (response.status) {
toastr.success(response.message);
setTimeout(function () {
location.reload();
}, 1000);
} else {
// jQuery('#addchild_error_modalBody').html('<p><strong>'+response.message+'</strong></p>');
// jQuery('#addchild_error_modal').modal('show');
}
},
error: function (data) {
toastr.error(data.message);
}
});
}
}
//-----------------------------New Instruction Type Selection----------------
let selectedValue = null;
let selectedSelectId = null;
function showModal(selectId) {
// alert(selectedValue);
selectedSelectId = selectId;
selectedValue = document.getElementById(`select${selectId}`).value;
if(selectedValue){ document.getElementById(`label${selectId}`).innerText =""; }
if(selectedValue == 'both'){
document.getElementById("selectedValue").textContent = selectedValue;
document.getElementById('myModal').style.display = 'block';
document.getElementById(`addmore${selectId}`).style.display = 'block';
document.getElementById(`addTimeGrade${selectId}`).style.display = 'block';
}
else if(selectedValue == 'group')
{
document.getElementById(`addmore${selectId}`).style.display = 'block';
document.getElementById(`addTimeGrade${selectId}`).style.display = 'block';
}
else
{
document.getElementById(`addmore${selectId}`).style.display = 'none';
var functionName = 'removeAllTimeGradeContainers' + selectId;
if (typeof window[functionName] === 'function') {
window[functionName]();
}
}
}
function confirmSelection() {
if (selectedValue !== null) {
const select = document.getElementById(`select${selectedSelectId}`);
select.value = selectedValue;
document.getElementById('myModal').style.display = 'none';
}
}
function cancelSelection() {
selectedValue = "0"; // Set it to the value of the first option
const select = document.getElementById(`select${selectedSelectId}`);
select.value = selectedValue;
document.getElementById('myModal').style.display = 'none';
}
// Define a global variable to store the grade values
let gradeValues = {};
// Function to fetch and store grade values
function fetchGradeValues() {
jQuery.ajax({
url: ajaxurl, // 'ajaxurl' is a global variable in WordPress
method: "get",
dataType: "json",
data: {
action: 'fetch_grade_values' // WordPress AJAX action name
},
success: function (response) {
try {
console.log(response);
gradeValues = response;
// Once the values are fetched, you can call the function to add time-grade fields.
// Add your logic here to determine when to add these fields.
} catch (error) {
console.error('Error parsing JSON:', error);
}
},
error: function (xhr, status, error) {
console.error('AJAX request failed:', error);
}
});
}
// Function to add a time-grade field
function addTimeGradeField(selectId) {
document.getElementById(`timeGradeContainer${selectId}`).style.display = 'block';
const container = document.getElementById(`timeGradeContainer${selectId}`);
if (selectId === 1) {
day = "Monday";
} else if (selectId === 2) {
day = "Tuesday";
} else if (selectId === 3) {
day = "Wednesday";
} else if (selectId === 4) {
day = "Thursday";
} else if (selectId === 5) {
day = "Friday";
} else if (selectId === 6) {
day = "Saturday";
} else if (selectId === 7) {
day = "Sunday";
} else {
// Handle other cases if needed
}
const timeGradeField = document.createElement("div");
const dynamicClass = `split${selectId}`;
timeGradeField.classList.add("split-wrp",dynamicClass);
// Create the dropdown for grade selection
const gradeSelect = document.createElement("select");
gradeSelect.name = `${day}_grade[]`;
gradeSelect.id = `grade_select${selectId}`;
gradeSelect.classList.add(`grade_select${selectId}`);
const initialOption = document.createElement("option");
initialOption.value = ""; // Set an empty value or any other value you prefer
initialOption.text = "Select a Grade"; // Display text for the initial option
gradeSelect.appendChild(initialOption);
// Populate the select box with the stored grade values
let optionText;
jQuery.each(gradeValues, function (index, grade) {
if (grade.upper_grade !== '') {
optionText = 'Grade (' + grade.lower_grade + ' - ' + grade.upper_grade +')';
} else {
optionText = 'Grade (' + grade.lower_grade +')';
}
gradeSelect.appendChild(new Option(optionText, grade.id));
});
timeGradeField.innerHTML = `
<input type="text" id="${day}_stime[]" name="${day}_stime[]" placeholder="Start Time" readonly onchange="Timedata(this)" data-format="hh:mm A" class="timepicker_demo timepicker_demo clockface-open input-style">
<input type="text" id="${day}_etime[]" name="${day}_etime[]" placeholder="End Time" readonly onchange="Timedata(this)" data-format="hh:mm A" class="timepicker_demo timepicker_demo clockface-open input-style">
<input type="text" id="${day}_label[]" name="${day}_label[]" placeholder="Label" class="input-style">
`;
timeGradeField.appendChild(gradeSelect);
// Add a "Remove" button
const removeButton = document.createElement("button");
removeButton.textContent = "Remove";
//removeButton.style.marginLeft = "5px";
removeButton.classList.add("button-wordwrap");
removeButton.onclick = function () {
removeTimeGradeField(timeGradeField, selectId);
};
timeGradeField.appendChild(removeButton);
container.appendChild(timeGradeField);
}
// Call the function to fetch grade values when needed
//fetchGradeValues();
window.onload = function() {
// Get the current page URL
var currentPage = window.location.href;
// Check if it's the second page
if (currentPage.includes('add_location')) {
// Code to be executed when the second page is loaded
fetchGradeValues();
}
};
function removeTimeGradeField(timeGradeField,selectId) {
const container = document.getElementById(`timeGradeContainer${selectId}`);
container.removeChild(timeGradeField);
}
function removeTimeGradeFieldpage(rowId) {
const container = document.getElementById(`timeGradeContainer${rowId}`);
// Clear textbox values
const textboxes = container.querySelectorAll('input[type="text"]');
textboxes.forEach(function(textbox) {
textbox.value = '';
});
const selects = container.querySelectorAll('select');
selects.forEach(function(select) {
select.value = '0'; // Set to the default value or an appropriate value
});
while (container.firstChild) {
container.removeChild(container.firstChild);
}
}
function removeElementsByClass(className) {
const elements = document.querySelectorAll(`.${className}`);
elements.forEach(function(element) {
element.remove();
});
}
function removeAllTimeGradeContainers1() {
removeElementsByClass('split1');
}
function removeAllTimeGradeContainers2() {
removeElementsByClass('split2');
}
function removeAllTimeGradeContainers3() {
removeElementsByClass('split3');
}
function removeAllTimeGradeContainers4() {
removeElementsByClass('split4');
}
function removeAllTimeGradeContainers5() {
removeElementsByClass('split5');
}
function removeAllTimeGradeContainers6() {
removeElementsByClass('split6');
}
function removeAllTimeGradeContainers7() {
removeElementsByClass('split7');
}
// Add more functions as needed
function handlePlatformChange() {
var platformValue = document.querySelector('input[name="platform"]:checked').value;
var customLabelRows = document.querySelectorAll('.customLabel');
if (platformValue === '3') {
customLabelRows.forEach(function (row) {
row.style.display = 'table-row';
});
} else {
customLabelRows.forEach(function (row) {
row.style.display = 'none';
});
}
}
// jQuery(document).ready(function($) {
// var dropdownFieldId = '#input_13_14'; // Update this to your actual player dropdown ID
// var gradeDropdownId = '#input_13_5'; // Update this to your actual grade dropdown ID
// $(dropdownFieldId).change(function() {
// var playerId = $(this).val();
// $.ajax({
// type: 'POST',
// url: ajaxurl,
// data: {
// action: 'get_player_grade',
// player_id: playerId
// },
// success: function(response) {
// var gradeDropdown = $(gradeDropdownId);
// gradeDropdown.empty(); // Clear the current options
// // Assuming response is a JSON array of grades
// var grades = JSON.parse(response);
// //console.log(grades.length);
// if (grades.length > 0) {
// // Append the new options based on the returned grades
// $.each(grades, function(index, grade) {
// gradeDropdown.append($('<option></option>')
// .attr('value', grade.grade) // Use grade.grade to access the current grade value
// .text(grade.grade) // Use grade.grade for the text
// .prop('selected', grade.grade === 'High School') // Example: set 'High School' as selected
// );
// });
// } else {
// gradeDropdown.append($('<option></option>').attr('value', '').text('No grades available')); // Optional: handle no grades case
// }
// },
// error: function(xhr, status, error) {
// console.error('AJAX Error: ' + status + error);
// }
// });
// });
// });