console.log(file_custom_params);
function search_Classes_Data() {
  var data = {};
  $('.search-filter').each(function (index) {
    if ($(this).val() != '' && $(this).val() != 'all') {
      data[$(this).attr('name')] = $(this).val();
    }
  });
  console.log(data);
  render_classes(data);
}
var $ = jQuery;

$(document).ready(function () {
  var $ = jQuery;
  $(function () {
    var start = moment().subtract(29, 'days');
    var end = moment();

    function cb(start, end) {
      $('#reportrange input').val(
        start.format('MM/DD/YYYY') + '-' + end.format('MM/DD/YYYY')
      );
    }
    $('#reportrange').daterangepicker(
      {
        startDate: start,
        endDate: end
      },
      cb
    );

    cb(start, end);
    $('#reportrange input').val('');
  });

  if (file_custom_params.current_page_id == '8154') {
    render_classes(false);
  }
  $('#phone').mask('(000) 000-0000');
  $('#apply_now_form').validate({
    ignore: [],
    rules: {
      address: { required: true },
      application_email: { required: true, email: true },
      application_type: { required: true }
    }
  });
  $('#purchase_process').validate({
    ignore: [],
    rules: {
      first_name: { required: true },
      last_name: { required: true },
      email: { required: true, email: true },
      phone: { required: true },
      password: {
        minlength: 5,
        required: true
      },
      password_confirm: {
        minlength: 5,
        required: true,
        equalTo: '#password'
      },
      // coupon: { required: true },
      // coupon: {
      //     required: function (element) {
      //         return $("#show_payment_section").is(":hidden");
      //     }
      // },
      address: { required: true },
      city: { required: true },
      state: { required: true },
      zip: { required: true },
      program: { required: true },
      card_first_name: {
        required: function (element) {
          return $('#coupon').val() == '';
        }
      },
      card_last_name: {
        required: function (element) {
          return $('#coupon').val() == '';
        }
      },
      cc: {
        required: function (element) {
          return $('#coupon').val() == '';
        }
      },
      month: {
        required: function (element) {
          return $('#coupon').val() == '';
        }
      },
      year: {
        required: function (element) {
          return $('#coupon').val() == '';
        }
      },
      ccv: {
        required: function (element) {
          return $('#coupon').val() == '';
        },
        maxlength: 4
      },
      billing_address: { required: true },
      billing_city: { required: true },
      billing_state: { required: true },
      billing_zip: { required: true },
      agree: { required: true },
      app_training_site: { required: true }
    }
  });
  if ($('#timewarningmodal').length) {
    $('#timewarningmodal').modal({
      show: true,
      backdrop: 'static',
      keyboard: false
    });
  }
  if ($('#purchase_application_note').length) {
    $('#purchase_application_note').modal('show');
  }
  if ($('#price').length) {
    validateTheOnHoldToken();
  }
});

function render_classes(arg) {
  var $ = jQuery;
  loader_start();

  $.ajax({
    type: 'POST',
    dataType: 'json',
    url: file_custom_params.ajax_url, //Getting URL of Purchase application
    data: {
      action: 'render_classes', //function calling from JS
      data: arg
    },
    success: function (response) {
      console.log(response);
      $('#class-list').html(response.html);
      if (response.class_type_html) {
        $('#classes_types').html(response.class_type_html);
      }
      if (response.class_region_html) {
        $('#classes_region').html(response.class_region_html);
      }
      if (arg) {
        console.log('I AM HERE');
        trigger_filters();
      }
      setTimeout(function () {
        loader_end();
      }, 2000);
    }
  });
}
function initialize() {
  var input = document.getElementById('searchTextField');
  var options = {
    types: ['address'],
    componentRestrictions: {
      country: 'us'
    }
  };
  autocomplete = new google.maps.places.Autocomplete(input, options);
  google.maps.event.addListener(autocomplete, 'place_changed', function () {
    var place = autocomplete.getPlace();
    var address = place.address_components;
    var street_number = '';
    var street = '';
    var city = '';
    var county = '';
    var state = '';
    var country = '';
    var postal_code = '';
    //   if(address.length){
    // 	valid_address = true;
    // 	trigger_calidate();
    //   } else {
    // 	valid_address = false;
    //   }
    $.each(address, function (i, obj) {
      //console.log(obj);
      var value = obj.long_name;
      var short = obj.short_name;
      var name = obj.types[0];
      //console.log(name);
      //console.log(value);
      if (name === 'street_number') {
        street_number = value;
      }
      if (name === 'route') {
        street = value;
      }
      if (name === 'administrative_area_level_3' || name === 'locality') {
        city = value;
        city = city.replace('Township', '').trim();
      }
      if (name === 'administrative_area_level_2') {
        county = value;
      }
      if (name === 'administrative_area_level_1') {
        state = short;
      }
      if (name === 'country') {
        country = value;
        county = county.replace('County', '').trim();
      }
      if (name === 'postal_code') {
        zip = value;
      }
    });
    $('#street_number').val(street_number);
    $('#street').val(street);
    $('#city').val(city);
    $('#state').val(state);
    $('#zip').val(zip);
    $('#county').val(county);
    console.log(street_number);
    console.log(street);
    console.log(city);
    console.log(state);
    console.log(zip);
    console.log(county);
    if ($('#street_number').val() == '') {
      valid_address = false;
    } else {
      valid_address = true;
    }
    if ($('#street').val() == '') {
      valid_address = false;
    } else {
      valid_address = true;
    }
    if ($('#city').val() == '') {
      valid_address = false;
    } else {
      valid_address = true;
    }
    if ($('#state').val() == '') {
      valid_address = false;
    } else {
      valid_address = true;
    }
    if ($('#zip').val() == '') {
      valid_address = false;
    } else {
      valid_address = true;
    }
    if ($('#county').val() == '') {
      valid_address = false;
    } else {
      valid_address = true;
    }
    if (valid_address == true) {
      $('#searchTextField').removeClass('highlight-red');
      $('#searchTextField').addClass('highlight-green');
      $('#address-note').hide();
    }
  });
}
google.maps.event.addDomListener(window, 'load', initialize);

//-----------------------------------//

function trigger_filters() {
  var classes_region = '';
  var classes_types = '';
  var classes_daterange = '';
  search = '';

  if ($("select[name='classes_region']").length) {
    classes_region = $("select[name='classes_region']").val();
  }
  if ($("select[name='classes_types']").length) {
    classes_types = $("select[name='classes_types']").val();
  }
  if ($("select[name='classes_daterange']").length) {
    classes_daterange = $("select[name='classes_daterange']").val();
  }
  if ($("input[name='search']").length) {
    search = $("input[name='search']").val();
  }
  filter_class_data(classes_region, classes_types, classes_daterange, search);
}
$(document).on('keyup', '.search-filter', function (e) {
  trigger_filters();
});
$(document).on('change', '.search-filter ', function (e) {
  trigger_filters();
});
$(document).on('change', '#classes_daterange ', function (e) {
  if ($('#reportrange input').val() != '') {
    $('#reportrange input').val('');
    render_date_filtered_data();
  }

  trigger_filters();
});
$(document).on('click', '.applyBtn', function (e) {
  render_date_filtered_data();
});
function filter_class_data(
  classes_region,
  classes_types,
  classes_daterange,
  search
) {
  if (classes_daterange == 'custom-date') {
    $('#display-daterange').show();
  }

  $('#class-list .single-class').each(function (e) {
    var search_text_row_found = false;
    if (
      $(this).attr('class_name').toLowerCase().indexOf(search.toLowerCase()) >=
      0
    ) {
      search_text_row_found = true;
    }
    if (
      (classes_region != 'All' && $(this).attr('region') != classes_region) ||
      (classes_types != 'All' && $(this).attr('type') != classes_types) ||
      (classes_daterange != 'All' &&
        parseInt($(this).attr('days')) >= classes_daterange) ||
      !search_text_row_found
    ) {
      if (classes_daterange == 'custom-date') {
        $('#display-daterange').show();
      } else {
        $('#display-daterange').hide();
      }
      $(this).hide();
    } else {
      $(this).show();
    }
  });
  check_results();
}
function check_results() {
  // var total_length = $("#class-list .single-class");
  var total_hidden_length = $('#class-list .single-class').is(':visible');
  if (!total_hidden_length && $('#class-list .single-class').length) {
    $('.not-found').show();
  } else {
    $('.not-found').hide();
  }
}

function render_date_filtered_data() {
  var dates = $('#reportrange input').val();
  var classes_region = 'All';
  var classes_types = 'All';
  if ($("select[name='classes_region']").length) {
    classes_region = $("select[name='classes_region']").val();
  }
  if ($("select[name='classes_types']").length) {
    classes_types = $("select[name='classes_types']").val();
  }
  var data = {
    set_date: dates,
    classes_region: classes_region,
    classes_types: classes_types
  };
  render_classes(data);
}
//-------------------------//
$(document).on('click', '#sameasbilling', function (e) {
  if ($(this).is(':checked')) {
    $('#billing_zip').val($('#zip').val());
    $('#billing_address').val($('#address').val());
    $('#billing_apt').val($('#apt').val());
    $('#billing_city').val($('#city').val());
    $('#billing_state').val($('#state').val());
    $('#card_first_name').val($('#first_name').val());
    $('#card_last_name').val($('#last_name').val());
  } else {
    $('#billing_address').val('');
    $('#billing_apt').val('');
    $('#billing_city').val('');
    $('#billing_state').val('');
    $('#billing_zip').val('');
    $('#card_first_name').val('');
    $('#card_last_name').val('');
  }
});
function fireNotification(heading, text, type, delay = false) {
  var $ = jQuery;
  if (type == 'error') {
    var bgColor = 'red';
    var hideAfter = 2000;
  } else {
    var bgColor = 'green';
    var hideAfter = 500;
  }
  if (delay) {
    hideAfter = delay;
  }
  $.toast({
    heading: heading,
    text: text,
    showHideTransition: 'slide', // It can be plain, fade or slide
    bgColor: bgColor, // Background color for toast
    textColor: '#ffffff', // text color
    allowToastClose: true, // Show the close button or not
    hideAfter: hideAfter, // `false` to make it sticky or time in miliseconds to hide after
    stack: 5,
    icon: type, // `fakse` to show one stack at a time count showing the number of toasts that can be shown at once
    textAlign: 'left', // Alignment of text i.e. left, right, center
    position: 'top-right',
    loader: false,
    beforeShow: function () {}, // will be triggered before the toast is shown
    afterShown: function () {}, // will be triggered after the toat has been shown
    beforeHide: function () {}, // will be triggered before the toast gets hidden
    afterHidden: function () {} // will be triggered after the toast has been hidden
  });
}
function loader_start() {
  jQuery('body').waitMe({
    effect: 'rotation',
    text: 'Please Wait',
    fontSize: '40px'
  });
}
function loader_end() {
  jQuery('body').waitMe('hide');
}
function process_application(e) {
  var $ = jQuery;
  let form_id = jQuery('#purchase_process');
  var form_data = form_id.serializeObject();
  console.log(form_data);
  var check_validate = false;
  check_validate = form_id.valid();
  if (check_validate) {
    loader_start();
    $.ajax({
      type: 'POST',
      dataType: 'json',
      url: file_custom_params.ajax_url, //Getting URL of Purchase application
      data: {
        action: 'process_application', //function calling from JS
        form: form_data
      },
      success: function (response) {
        console.log(response);
        if (response.status == 201) {
          if (response.redirect) {
            alertify.success('Please wait');
            window.location = response.redirect;
          }
        } else {
          loader_end();
          // scroll_to(form_id)
          alertify.error(response.message);
        }
      }
    });
    return true;
  } else {
    // scroll_to(form_id)
  }
}
function scroll_to(form_id) {
  $('html, body').animate(
    {
      scrollTop: form_id.offset().top
    },
    2000
  );
}

$(document).on('blur', '#coupon', function (e) {
  var coupon = $(this).val();
  console.log(coupon.length);
  if (coupon.length == 6) {
    loader_start();
    $.ajax({
      type: 'POST',
      dataType: 'json',
      async: true,
      url: file_custom_params.ajax_url,
      data: {
        action: 'check_coupon',
        coupon: coupon
      },
      success: function (response) {
        console.log(response);
        if (response.status == 201) {
          fireNotification('Success', response.message, 'success', 4000);
          $('#show_payment_section').hide();
          loader_end();
        } else {
          $('#coupon').val('');
          fireNotification('Error', response.message, 'error', 2000);
          $('#show_payment_section').show();
          loader_end();
        }
      }
    });
  } else {
    $('#show_payment_section').show();
  }
});
$(document).on('click', '.next-submit', function (e) {
  e.preventDefault();
  var check_validate = jQuery('#apply_now_form').valid();
  console.log(check_validate);
  if (!check_validate) {
    return false;
  }
  if ($('#county').val() == '') {
    Swal.fire({
      icon: 'error',
      html:
        '<h2 style="color:#ff0000;margin:0px;padding:0px;">Address not found<h2><br>' +
        '<p style="font-size:22px;">Please select the correct address by using google instruction.</p>',
      confirmButtonText: 'Close'
    });
    return false;
  }
  check_availability();
});
function check_availability() {
  var $ = jQuery;
  loader_start();
  var form_data = {
    email: $('#application_email').val(),
    county: $('#county').val(),
    type: $('#application_type').val(),
    random: Math.floor(Math.random() * 10)
  };
  $.ajax({
    type: 'GET', // define the type of HTTP verb we want to use (POST for our form)
    // url: '/test-apis/check-area-type-application-availability.php?email=' + encodeURI($('#email').val()) + '&county=' + county + '&type=' + type + '&random=' + Math.floor(Math.random() * 10), // the url where we want to POST
    dataType: 'json',
    url: file_custom_params.ajax_url,
    data: {
      action: 'check-area-type-application-availability', //function calling from JS
      form: form_data
    },
    success: function (data) {
      console.log(data);
      var available = data.data.result.available;
      var appareaid = data.data.result.id;
      var settoken = data.data.settoken;
      $.cookie('settoken', settoken, { path: '/' });
      $('#settoken').val(settoken);
      $.cookie('available', available, { path: '/' });
      $('#available').val(available);
      $.cookie('appareaid', appareaid, { path: '/' });
      $('#appareaid').val(appareaid);
      $.cookie('street_number', $('#street_number').val(), { path: '/' });
      $.cookie('street', $('#street').val(), { path: '/' });
      $.cookie('city', $('#city').val(), { path: '/' });
      $.cookie('state', $('#state').val(), { path: '/' });
      $.cookie('zip', $('#zip').val(), { path: '/' });
      $.cookie('county', form_data.county, { path: '/' });
      $.cookie('email', form_data.email, { path: '/' });
      $.cookie('type', form_data.type, { path: '/' });
      if (parseInt(available) > 0) {
        // window.location = '/purchase-application';
        setTimeout(function () {
          $('#apply_now_form').submit();
        }, 500);
      } else {
        var typetext = $('#type option:selected').text();
        Swal.fire({
          icon: 'error',
          html:
            '<!--<h2 style="color:#ff0000;margin:0px;padding:0px;">Application Not Available<h2>--><h2 style="color:#ff0000;margin:0px;padding:0px;">Applications Closed<h2><br>' +
            '<!--<p style="font-size:22px;">Apprenticeship applications are open March 01 - March 16, 2025. <br><br> Please check back for our Spring Applications in April.</p>--><p style="font-size:22px;">Apprenticeship Applications will be open again on March 1 - 16, 2025.</p>',
          confirmButtonText: 'Close'
        });
        loader_end();
      }
    }
  });
}

function validateTheOnHoldToken() {
  'use strict';
  var settoken = $.cookie('settoken');
  if (settoken === undefined) {
    settoken = $('#token').val();
  }
  $.ajax({
    type: 'GET', // define the type of HTTP verb we want to use (POST for our form)
    // url: '/test-apis/validate-application-on-hold-token.php', // the url where we want to POST
    dataType: 'json',
    url: file_custom_params.ajax_url,
    data: {
      action: 'validate-application-on-hold-token', //function calling from JS
      token: settoken
    },
    success: function (data) {
      loader_end();
      var results = data.data;
      if (parseInt(results.code) === 301) {
        $.cookie('available', '', { path: '/' });
        $.cookie('appareaid', '', { path: '/' });
        $.cookie('street_number', '', { path: '/' });
        $.cookie('street', '', { path: '/' });
        $.cookie('city', '', { path: '/' });
        $.cookie('state', '', { path: '/' });
        $.cookie('zip', '', { path: '/' });
        $.cookie('county', '', { path: '/' });
        $.cookie('settoken', '', { path: '/' });
        $.cookie('email', '', { path: '/' });
        $.cookie('type', '', { path: '/' });
        $.cookie('app_id', '', { path: '/' });
        window.location = file_custom_params.site_url;
      } else {
        $('#price').val(results.result.price);
        if (results.posts.token !== undefined) {
          console.log(results.posts.token);
          $('#token').val(results.posts.token);
        }
        // $('.countdown').downCount({
        // 	date: results.result.expires,
        // 	offset: 0
        // }, function () {
        // 	timeIsupRedirect();
        // });
        console.log(data);
      }
    }
  });
}

(function ($) {
  $.fn.serializeObject = function () {
    var self = this,
      json = {},
      push_counters = {},
      patterns = {
        validate: /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
        key: /[a-zA-Z0-9_]+|(?=\[\])/g,
        push: /^$/,
        fixed: /^\d+$/,
        named: /^[a-zA-Z0-9_]+$/
      };
    this.build = function (base, key, value) {
      base[key] = value;
      return base;
    };
    this.push_counter = function (key) {
      if (push_counters[key] === undefined) {
        push_counters[key] = 0;
      }
      return push_counters[key]++;
    };
    $.each($(this).serializeArray(), function () {
      // skip invalid keys
      // if (!patterns.validate.test(this.name)) {
      //     return;
      // }
      var k,
        keys = this.name.match(patterns.key),
        merge = this.value,
        reverse_key = this.name;
      while ((k = keys.pop()) !== undefined) {
        // adjust reverse_key
        reverse_key = reverse_key.replace(new RegExp('\\[' + k + '\\]$'), '');
        // push
        if (k.match(patterns.push)) {
          merge = self.build([], self.push_counter(reverse_key), merge);
        }
        // fixed
        else if (k.match(patterns.fixed)) {
          merge = self.build([], k, merge);
        }
        // named
        else if (k.match(patterns.named)) {
          merge = self.build({}, k, merge);
        }
      }
      json = $.extend(true, json, merge);
    });
    return json;
  };
})(jQuery);

//------Calendar------//

function dateAddDays(/*string dd/mm/yyyy*/ datstr, /*int*/ ndays) {
  var dattmp = datstr.split('/').reverse().join('/');
  var nwdate = new Date(dattmp);
  nwdate.setDate(nwdate.getDate() + (ndays || 1));
  return [
    nwdate.getFullYear(),
    zeroPad(nwdate.getMonth() + 1, 10),
    zeroPad(nwdate.getDate(), 10)
  ].join('-');
}

//function to add zero to date/month < 10
function zeroPad(nr, base) {
  var len = String(base).length - String(nr).length + 1;
  return len > 0 ? new Array(len).join('0') + nr : nr;
}

function render_calender_data(calender) {
  var $ = jQuery;
  loader_start();
  $.ajax({
    type: 'POST',
    dataType: 'json',
    url: file_custom_params.ajax_url, //Getting URL of Purchase application
    data: {
      action: 'render_calender_data' //function calling from JS
    },
    success: function (response) {
      var start_date_api = '';
      var end_date_api = '';
      // 	var testEvent = {title: 'CHECK THIS EVENT',
      // 	daysOfWeek: [ '1','2','3','4','5' ],
      // 	startTime: '10:30:00',
      // 	endTime: '12:30:00',
      // 	startRecur:'2021-09-07',
      // 	endRecur:'2021-09-20',
      // 	displayEventEnd: true
      // };
      // 	calender.addEvent(testEvent);

      response['data']['upcoming'].forEach(element => {
        if (element.startdate != null && element.enddate != null) {
          start_date_api = element.startdate + 'T' + element.class_start_time;
          end_date_api = element.enddate + 'T' + element.class_end_time;
        } else {
          start_date_api = element.startdate + 'T' + element.class_start_time;
          end_date_api = element.startdate + 'T' + element.class_start_time;
        }

        // var updatedEnddate = moment(element.utc_enddate).add(1, 'day');
        // var timestring = element.utc_enddate.split(" ")[1];
        // var formatted_time = updatedEnddate.format("YYYY-MM-DD");
        // var end_day_new = formatted_time +' '+ timestring;

        // console.log(formatted_time +' '+ timestring);
        // console.log(element.utc_enddate);

        var pass_args = {
          // groupId: element.id,
          // startRecur: start_date_api,
          // endRecur: end_date_api,
          title: element.class_type,
          // start: start_date_api,
          // end: end_date_api,
          daysOfWeek: ['1', '2', '3', '4', '5'],
          startTime: element.class_start_time,
          endTime: element.class_end_time,

          startRecur: start_date_api,
          endRecur: end_date_api,
          backgroundColor: element.background_color,
          color: element.background_color,
          textColor: element.font_color,
          class_image: element.image,
          class_instructors: element.instructors,
          class_type: element.class_type,
          class_name: element.class_name,
          class_location_name: element.location_name,
          class_location_city: element.location_city,
          class_location_state: element.location_state,
          class_hours: element.hours,
          class_description: element.description,
          readable_class_date: element.readable_class_date,
          readable_class_start_time: element.readable_class_start_time,
          readable_class_end_time: element.readable_class_end_time
        };
        // console.log(pass_args);
        // // die("here");
        calender.addEvent(pass_args);
      });
      loader_end();
    }
  });
}
if (file_custom_params.current_page_id == 8158) {
  // document.addEventListener("DOMContentLoaded", function () {
  // 	var calendarEl = document.getElementById("classes-calendar");
  // 	var calendar = new FullCalendar.Calendar(calendarEl, {
  // 		headerToolbar: {
  // 			center: "title",
  // 			left: "dayGridMonth,dayGridWeek,dayGridDay", // buttons for switching between views
  // 		},

  // 		initialView: "dayGridMonth",
  // 		hiddenDays: [ 0,6 ], // hide Tuesdays and Thursdays

  // 		eventSources: [
  // 			// your event source
  // 			{
  // 				events: [],
  // 			},
  // 			// any other event sources...
  // 		],
  // 		eventClick: function (info) {
  // 			$(".calendar-class .course-content-items a").html(
  // 				info.event.extendedProps.class_name +
  // 					" | " +
  // 					info.event.extendedProps.class_type
  // 			);
  // 			$(".calendar-class .course-instructor span").html(
  // 				info.event.extendedProps.class_instructors
  // 			);
  // 			$(".calendar-class .course-location span").html(
  // 				info.event.extendedProps.class_location_name +
  // 					", " +
  // 					info.event.extendedProps.class_location_city +
  // 					", " +
  // 					info.event.extendedProps.class_location_state
  // 			);
  // 			$(".calendar-class .course-hours span").html(
  // 				info.event.extendedProps.class_hours + " hours"
  // 			);
  // 			$(".calendar-class .course-description").html(
  // 				info.event.extendedProps.class_description
  // 			);
  // 			$(".calendar-class .course-date span").html(
  // 				info.event.extendedProps.readable_class_date
  // 			);
  // 			$(".calendar-class .course-timings span").html(
  // 				info.event.extendedProps.readable_class_start_time +
  // 					" - " +
  // 					info.event.extendedProps.readable_class_end_time
  // 			);
  // 			$(".calendar-class .class-img-box").css(
  // 				"background-image",
  // 				"url(" + info.event.extendedProps.class_image + ")"
  // 			);
  // 			$("#model-class").modal({
  // 				keyboard: true,
  // 			});
  // 		},
  // 	});
  // 	calendar.render();
  // 	render_calender_data(calendar);
  // });

  document.addEventListener('DOMContentLoaded', function () {
    var calendarEl = document.getElementById('classes-calendar');

    var calendar = new FullCalendar.Calendar(calendarEl, {
      // hiddenDays: [0, 6],
      // initialView: "dayGridMonth",
      // headerToolbar: {
      // 	left: "prev,next today",
      // 	center: "title",
      // 	right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek",
      // },
      // selectable: true,
      firstDay: 1,
      ignoreTimezone: true,
      nowIndicator: true,
      headerToolbar: {
        left: 'prev,next today',
        center: 'title',
        right: 'dayGridMonth,timeGridWeek,timeGridDay,listWeek'
      },
      eventDisplay: 'block',
      navLinks: true, // can click day/week names to navigate views
      editable: false,
      selectable: false,
      selectMirror: false,
      dayMaxEvents: false, // allow "more" link when too many events
      events: [],

      eventClick: function (info) {
        $('.calendar-class .course-content-items a').html(
          info.event.extendedProps.class_name +
            ' | ' +
            info.event.extendedProps.class_type
        );
        $('.calendar-class .course-instructor span').html(
          info.event.extendedProps.class_instructors
        );
        $('.calendar-class .course-location span').html(
          info.event.extendedProps.class_location_name +
            ', ' +
            info.event.extendedProps.class_location_city +
            ', ' +
            info.event.extendedProps.class_location_state
        );
        $('.calendar-class .course-hours span').html(
          info.event.extendedProps.class_hours + ' hours'
        );
        $('.calendar-class .course-description').html(
          info.event.extendedProps.class_description
        );
        $('.calendar-class .course-date span').html(
          info.event.extendedProps.readable_class_date
        );
        $('.calendar-class .course-timings span').html(
          info.event.extendedProps.readable_class_start_time +
            ' - ' +
            info.event.extendedProps.readable_class_end_time
        );
        $('.calendar-class .class-img-box').css(
          'background-image',
          'url(' + info.event.extendedProps.class_image + ')'
        );
        $('#model-class').modal({
          keyboard: true
        });
      }
    });

    calendar.render();
    render_calender_data(calendar);
  });
}
//------Calendar------//
