var url_controller = baseUrl + '/' + prefix_folder_admin + 'home/';
var save_method;
var id_use = 0;
var table;
let no = 1;
var list_courses = $('#list-courses');
var list_batch_courses = $('#list-batch-course');
var list_news = $('#list-news');
const lightbox = GLightbox();
$(document).ready(function () {
// $('#skill').select2({
// placeholder: 'Semua skill',
// searchInputPlaceholder: 'Cari Skill',
// width: '100%'
// });
// $('#category').select2({
// placeholder: 'Pilih kategori keahlian',
// searchInputPlaceholder: 'Cari kategori',
// width: '100%'
// });
// $('#open_course').select2({
// placeholder: 'Semua Pelatihan',
// width: '100%'
// });
// $('#filter_news').select2({
// placeholder: 'Semua Pelatihan',
// width: '100%'
// });
$(".select2-search>input[aria-controls='select2-open_course-results']").remove();
$(document).on('select2:open', function () {
$(".select2-search>input[aria-controls='select2-filter_news-results']").remove();
});
$('.owl-instructor').owlCarousel({
responsiveClass: true,
responsive: {
0: {
items: 1,
},
600: {
items: 3,
},
1000: {
items: 5,
loop: false
}
},
loop: true,
margin: 10,
items: 4,
autoplay: true,
autoplayHoverPause: true,
nav: true,
navText: ['', ''],
})
$('.owl-info').owlCarousel({
responsiveClass: true,
loop: false,
items: 3,
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 2,
nav: true,
},
1000: {
items: 3,
nav: true,
loop: false
}
},
autoplay: true,
autoplayHoverPause: true,
margin: 24,
nav: true,
navText: ['', ''],
})
$('.owl-running-company').owlCarousel({
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 3,
nav: true,
},
1000: {
items: 5,
nav: true,
loop: false
}
},
loop: true,
margin: 40,
items: 6,
autoplay: true,
autoplayTimeout: 1000,
autoplayHoverPause: true,
nav: true,
dots: false,
navText: ['', ''],
})
$('.owl-course').owlCarousel({
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
767: {
items: 2,
nav: false
},
1000: {
items: 3,
nav: true,
loop: false
}
},
loop: true,
margin: 24,
items: 3,
autoplay: true,
autoplayTimeout: 6000,
autoplayHoverPause: true,
nav: true,
navText: ['', ''],
})
$('.owl-news').owlCarousel({
responsiveClass: true,
responsive: {
0: {
items: 1,
},
600: {
items: 2,
},
1000: {
items: 3,
}
},
loop: false,
margin: 40,
items: 3,
autoplay: true,
autoplayTimeout: 6000,
autoplayHoverPause: true,
nav: true,
navText: ['', ''],
})
$('.owl-batch-main').owlCarousel({
center: true,
responsiveClass: true,
responsive: {
0: {
items: 1,
},
600: {
items: 2,
},
1000: {
items: 3,
}
},
loop: false,
margin: 40,
items: 3,
autoplay: true,
autoplayTimeout: 6000,
autoplayHoverPause: true,
nav: true,
navText: ['', ''],
})
$('.owl-batch-course').owlCarousel({
responsiveClass: true,
responsive: {
0: {
items: 1,
nav: true
},
600: {
items: 2,
nav: false
},
1000: {
items: 3,
nav: true,
loop: false
}
},
loop: true,
margin: 24,
items: 3,
autoplay: true,
autoplayTimeout: 6000,
autoplayHoverPause: true,
nav: true,
navText: ['', ''],
})
$(".owl-nav").addClass('d-flex justify-content-between');
let clone_owl = $(".instrutor-carousel").find('.owl-nav .owl-prev').clone();
$(".instrutor-carousel").find('.owl-nav .owl-prev').remove();
$(".instrutor-carousel").find('.owl-nav').append(clone_owl);
});
$(window).on('load', function () {
setTimeout(() => {
$('#integrityModal').appendTo("body").modal('show');
}, 700);
})
$('.btn-filter').click(function (e) {
e.preventDefault();
var formData = new FormData($('#filter-courses')[0]);
formData.append(csrfName, get_csrf());
$('#js-preloader').removeClass('loaded');
$.ajax({
type: "POST",
url: baseUrl + '',
data: formData,
contentType: false,
processData: false,
dataType: "JSON",
success: function (data) {
update_csrf(data.csrfToken);
$('#js-preloader').addClass('loaded');
if (data.status) {
list_courses.html(data.data);
$('#pagination').html(data.pagination);
lightbox.reload();
} else {
for (var i = 0; i < data.inputerror.length; i++) {
$('[name="' + data.inputerror[i] + '"]').addClass("is-invalid");
$('[name="' + data.inputerror[i] + '"]').siblings(':last').addClass('d-block');
$('[name="' + data.inputerror[i] + '"]').siblings(':last').text(data.error_string[i]);
}
}
}
});
});
$('#open_course').change(function (e) {
e.preventDefault();
var formData = new FormData($('#filter-batch-courses')[0]);
formData.append(csrfName, get_csrf());
$('#js-preloader').removeClass('loaded');
$.ajax({
type: "POST",
url: baseUrl + '',
data: formData,
contentType: false,
processData: false,
dataType: "JSON",
success: function (data) {
update_csrf(data.csrfToken);
$('#js-preloader').addClass('loaded');
if (data.status) {
list_batch_courses.html(data.data);
$('#pagination').html(data.pagination);
lightbox.reload();
} else {
for (var i = 0; i < data.inputerror.length; i++) {
$('[name="' + data.inputerror[i] + '"]').addClass("is-invalid");
$('[name="' + data.inputerror[i] + '"]').siblings(':last').addClass('d-block');
$('[name="' + data.inputerror[i] + '"]').siblings(':last').text(data.error_string[i]);
}
}
}
});
});
$('#filter_news').change(function (e) {
e.preventDefault();
var formData = new FormData($('#filter-news')[0]);
formData.append(csrfName, get_csrf());
$('#js-preloader').removeClass('loaded');
$.ajax({
type: "POST",
url: baseUrl + '',
data: formData,
contentType: false,
processData: false,
dataType: "JSON",
success: function (data) {
update_csrf(data.csrfToken);
$('#js-preloader').addClass('loaded');
if (data.status) {
list_news.html(data.data);
$('#pagination').html(data.pagination);
lightbox.reload();
} else {
for (var i = 0; i < data.inputerror.length; i++) {
$('[name="' + data.inputerror[i] + '"]').addClass("is-invalid");
$('[name="' + data.inputerror[i] + '"]').siblings(':last').addClass('d-block');
$('[name="' + data.inputerror[i] + '"]').siblings(':last').text(data.error_string[i]);
}
}
}
});
});
$('.form-send-mail').submit(function (e) {
e.preventDefault();
var formData = new FormData($(this)[0]);
formData.append(csrfName, get_csrf());
showLoading();
$.ajax({
type: "POST",
url: baseUrl + '/send-mail',
data: formData,
contentType: false,
processData: false,
dataType: "JSON",
success: function (data) {
hideLoading();
update_csrf(data.csrfToken);
var icon = data.status ? 'success' : 'error';
Swal.fire({
icon: icon,
title: data.msg,
showConfirmButton: false,
timer: 1500
})
}
});
})
// table alumni and peserta
let alumni_table = new DataTable('#alumni_table', {
paging: true,
lengthChange: false,
searching: true,
ordering: true,
info: true,
autoWidth: false,
responsive: true,
pageLength: 50
});