<script>
    //Generer facture
    $('#submit_form_facture').on('click', function(e) {
        $('#form_facture').validate({
            rules: {
                facture_month: {
                    required: true,
                },
                facture_limit: {
                    required: true,
                },
            },
            messages: {
                facture_month: {
                    required: "Le mois est obligatoire!",
                },
                facture_limit: {
                    required: "Le jour limite de payement est obligatoire!",
                },
            },
            /* submitHandler: function() {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: "/factures/{{$classe->id}}",
                    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: {
                        facture_limit: $('#facture_limit_id').val(),
                        facture_month: $('#facture_month_id').val(),
                    },
                    success: function(response) {
                        if (response == true) {
                            window.location.replace(
                                '/accueil/classe/{{$classe->slug}}');
                        }
                    },
                    error: function(response) {
                        console.log(response);
                    }
                });
            } */
        })
    });
</script>
