<script>
    //Supprimer Absence
    var classe_libelle = "";
    var eleve_id = 0;
    var absence_id = 0;
    var classe_slug = "";
    var eleve_slug = ""

    function get_classe_slug(slug) {
        classe_slug = slug;
    }

    function getClasseLibelle(libelle) {
        classe_libelle = libelle;
    }

    function getEleveId(id) {
        eleve_id = id;
    }

    function getAbsenceId(id) {
        absence_id = id;
    }

    function get_eleve_slug(slug) {
        eleve_slug = slug;
    }

    $('.supp_absence').on('click', () => {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            url: "/accueil/classe/" + classe_slug + "/eleve/" + eleve_slug + "/absences/" +
                absence_id + "/supprimer",
            type: "POST",
            dataType: 'json',
            beforeSend: function() {
                $('#loader').removeClass('is-hidden')
                $('*').css('pointer-events', 'none')
            },
            complete: function() { // Set our complete callback, adding the .hidden class and hiding the spinner.
                $('#loader').addClass('is-hidden')
                $('*').css('pointer-events', 'all')
            },
            data: {
                eleve_id: eleve_id,
                classe_libelle: classe_libelle,
                absence_id: absence_id,
            },
            success: function(response) {
                if (response == true) {
                    window.location.replace(
                        '/accueil/classe/' + classe_slug + '/eleve/' + eleve_slug);
                    eleve_id = 0;
                    classe_libelle = "";
                    absence_id = 0;
                    classe_slug = "";
                    eleve_slug = "";
                }
            },
            error: function(response) {
                console.log(response);
            }
        });
    });
</script>
