File: /var/www/vhost/disk-apps/demo.sports-crowd.com/public/js/academy_reports.js
$(document).ready(function () {
Dropzone.options.saveReports = {
success: function (file, response) {
//Here you can get your response.
if (response.r == 200) {
const get = document.getElementById('button');
get.addEventListener('click', e => { });
get.dispatchEvent(new Event('click'));
}
}
}
});
function viewReport(academy_user_id) {
validateUserAcademy(academy_user_id);
}
function validateUserAcademy(academy_user_id) {
$.ajax({
url: "/academy_user/performance_reports/" + academy_user_id,
type: "GET",
contentType: "application/json",
headers: {
"X-CSRF-TOKEN": $('meta[name="csrf-token"]').attr("content"),
"Content-Type": "application/json",
},
success: function (r) {
if (r.r == false) {
swal("Error", r.m, "error");
} else {
$(location).attr("href", "/academy_user/performance_reports/" + academy_user_id);
}
},
error: function (e) {
swal("Error", Lang.get("messagesClient.academy_states.error_modifying"), "error");
},
});
}
function clickEvent() {
createToast();
}
const button = document.getElementById('button')
const toast = document.getElementById('toasts')
const messages = [
'El informe se ha guardado con éxito',
]
const types = [
'success',
]
function createToast(message = null, type = null) {
let properties
const notif = document.createElement('div')
const notifIcon = document.createElement('span')
notifIcon.style = "margin: 0 20px 0 0;";
const notificationType = type ? type : getRandomType()
properties = setProperties(notificationType)
notif.classList.add('toast')
notif.classList.add(notificationType)
notifIcon.classList.add(properties[0])
notifIcon.classList.add(properties[1])
notif.innerText = messages[properties[2]]
toast.appendChild(notif)
notif.append(notifIcon)
setTimeout(() => {
notif.remove()
}, 5000)
}
function setProperties(notificationType) {
let propertyList
switch (notificationType) {
case 'success':
propertyList = ['fa', 'fa-file-pdf-o', 0]
break
}
return propertyList;
}
function getRandomType() {
return types[Math.floor(Math.random() * types.length)]
}