<script>
    //Fonction d'activation des champs au clic sur le bouton modifier
    function modifier(id) {
        $('.input').prop('disabled', false);
        $('select').prop('disabled', false);
        $('#btn_modif').prop('disabled', true);
        $('#btn_enr').prop('disabled', false);
    }

    //JS pour la modification et l'enregistrement des infos de l'eleve
    $('#btn_enr').on('click', function() {
        $('#info_eleve').validate({
            rules: {
                nom: {
                    required: true,
                },
                prenom: {
                    required: true,
                },
                date_naissance: {
                    required: true,
                },
                lieu_naissance: {
                    required: true,
                },
                adresse: {
                    required: true,
                },
                tuteur: {
                    required: true,
                },
                tel_tuteur: {
                    required: true,
                },
                autre_tel: {
                    required: false,
                },
                classe: {
                    required: true,
                },
                inscription: {
                    required: true,
                },
                mensualite: {
                    required: true,
                },
            },
            messages: {
                nom: {
                    required: "Le nom est obligatoire!",
                },
                prenom: {
                    required: "Le prénom est obligatoire!",
                },
                date_naissance: {
                    required: "La date de naissance est obligatoire!",
                },
                lieu_naissance: {
                    required: "Le lieu de naissance est obligatoire!",
                },
                adresse: {
                    required: "L'adresse est obligatoire!",
                },
                tuteur: {
                    required: "Le prénom et le nom du tuteur sont obligatoires!",
                },
                tel_tuteur: {
                    required: "Le téléphone du tuteur est obligatoire!",
                },
                classe: {
                    required: "La classe est obligatoire!",
                },
                inscription: {
                    required: "Le montant de l'inscription est obligatoire",
                },
                mensualite: {
                    required: "Le montant de la mensualite est obligatoire",
                },
            },
            submitHandler: function() {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: "/accueil/classe/<?php echo e($classe->slug); ?>/eleve/<?php echo e(request('eleve_slug')); ?>",
                    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: {
                        nom: $('#nom').val(),
                        prenom: $('#prenom').val(),
                        date_naissance: $('#date_naissance').val(),
                        lieu_naissance: $('#lieu_naissance').val(),
                        adresse: $('#adresse').val(),
                        tuteur: $('#tuteur').val(),
                        tel_tuteur: $('#tel_tuteur').val(),
                        autre_tel: $('#autre_tel').val(),
                        classe_id: $('#classe').val(),
                        inscription: Number($('#inscription').val().replace(/\s/g, '')),
                        mensualite: Number($('#mensualite').val().replace(/\s/g, '')),
                    },
                    success: function(response) {
                        if (response == true) {
                            window.location.replace(
                                '/accueil/classe/<?php echo e($classe->slug); ?>/eleve/<?php echo e(request('eleve_slug')); ?>'
                            );
                        }
                    },
                    error: function(response) {
                        console.log(response);
                    }
                });
            }
        });
    });

    //JS pour la suppression d'un eleve
    $('#btn_supp').on('click', function() {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            url: "/accueil/classe/<?php echo e($classe->slug); ?>/eleve/<?php echo e(request('eleve_slug')); ?>/delete",
            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: {
                nom: $('#nom').val(),
                prenom: $('#prenom').val(),
                date_naissance: $('#date_naissance').val(),
                lieu_naissance: $('#lieu_naissance').val(),
                adresse: $('#adresse').val(),
                tuteur: $('#tuteur').val(),
                tel_tuteur: $('#tel_tuteur').val(),
                autre_tel: $('#autre_tel').val(),
                classe_id: $('#classe').val(),
                inscription: Number($('#inscription_id').val().replace(/\s/g, '')),
                mensualite: Number($('#mensualite_id').val().replace(/\s/g, '')),
            },
            success: function(response) {
                if (response == true) {
                    window.location.replace(
                        '/accueil/classe/<?php echo e($classe->slug); ?>'
                    );
                }
            },
            error: function(response) {
                console.log(response);
            }
        });
    });

    //Fonction pour le panel tab
    function openContent(evt, contentId) {

        var i, tabcontent, tablinks;


        tabcontent = document.getElementsByClassName("panel-block");

        for (i = 0; i < tabcontent.length; i++) {
            tabcontent[i].style.display = "none";
            //console.log(tabcontent[i])
        }


        tablinks = document.getElementsByClassName("tab");
        for (i = 0; i < tablinks.length; i++) {
            tablinks[i].className = tablinks[i].className.replace("is-active", "");
            //console.log(tablinks[i])
        }


        document.getElementById(contentId).style.display = "flex";
        if (evt == null) {
            document.getElementById('default').className += " is-active";
        } else {
            evt.currentTarget.className += " is-active";
        }

    }
    openContent(event, 'info');

    //JS pour les boutons des payements
    var eleve_id = 0;
    var classe_libelle = "";
    var classe_slug = "";
    var payement_id = 0;
    var payement_montant = 0;
    var payement_type = "";
    var eleve_slug = "";

    function get_id_eleve(id) {
        eleve_id = id;
        //console.log(eleve_id);
    }

    function get_libelle_classe(libelle) {
        classe_libelle = libelle;
        //console.log(classe_libelle);
    }

    function get_classe_slug(slug) {
        classe_slug = slug;
    }

    function get_eleve_slug(slug) {
        eleve_slug = slug;
    }

    function get_id_payement(id) {
        payement_id = id;
    }

    function get_montant_payement(montant) {
        payement_montant = montant;
        $('#montant_id').val(payement_montant);
    }

    function get_type_payement(type) {
        payement_type = type;
        $('#value_type_id').html(payement_type)
    }

    //Bouton Frais paye
    $('.btn_paye').on('click', () => {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            url: "/accueil/classe/" + classe_slug + "/eleve/" + eleve_slug + "/payement/" +
                payement_id + "/payer",
            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,
                payement_id: payement_id,
            },
            success: function(response) {
                if (response == true) {
                    window.location.replace(
                        '/accueil/classe/' + classe_slug + '/eleve/' + eleve_slug);
                    eleve_id = 0;
                    classe_libelle = "";
                    payement_id = 0;
                    classe_slug = "";
                    eleve_slug = "";
                } else {
                    console.log('Le payement n\'est pas enregistré');
                    eleve_id = 0;
                    classe_libelle = "";
                    payement_id = 0;
                    classe_slug = "";
                    eleve_slug = "";
                }
            },
            error: function(response) {
                console.log(response);
            }
        });
    });

    //Bouton frais impaye
    $('.btn_impaye').on('click', () => {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            url: "/accueil/classe/" + classe_slug + "/eleve/" + eleve_slug + "/payement/" +
                payement_id + "/impayer",
            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,
                payement_id: payement_id,
            },
            success: function(response) {
                if (response == true) {
                    window.location.replace(
                        '/accueil/classe/' + classe_slug + '/eleve/' + eleve_slug);
                    eleve_id = 0;
                    classe_libelle = "";
                    payement_id = 0;
                    classe_slug = "";
                    eleve_slug = "";
                } else {
                    console.log('Le payement n\'est pas enregistré');
                    eleve_id = 0;
                    classe_libelle = "";
                    payement_id = 0;
                    classe_slug = "";
                }
            },
            error: function(response) {
                console.log(response);
            }
        });
    })

    //Modifier payement
    $('#submit_form_modifier_payement').on('click', function(e) {
        $('#form_modifier_payement').validate({
            rules: {
                type: {
                    required: true,
                },
                montant: {
                    required: true,
                }
            },
            messages: {
                type: {
                    required: "Choisissez un type svp!",
                },
                montant: {
                    required: "Précisez le montant svp!",
                },
            },
            submitHandler: function() {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: "/accueil/classe/" + classe_slug + "/eleve/" + eleve_slug +
                        "/payement/" + payement_id + "/modifier",
                    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,
                        payement_id: payement_id,
                        payement_type: payement_type,
                        payement_montant: Number($('#montant_id').val().replace(/\s/g, '')),
                    },
                    success: function(response) {
                        if (response == true) {
                            window.location.replace(
                                '/accueil/classe/' + classe_slug + '/eleve/' +
                                eleve_slug);
                            eleve_id = 0;
                            payement_id = 0;
                            payement_type = "";
                            eleve_slug = "";
                        }
                    },
                    error: function(response) {
                        console.log('Payement non modifié');
                    }
                });
            }
        })
    });

    //Bouton supprimer payement
    $('.btn_supp').on('click', () => {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            url: "/accueil/classe/" + classe_slug + "/eleve/" + eleve_slug + "/payement/" +
                payement_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,
                payement_id: payement_id,
            },
            success: function(response) {
                if (response == true) {
                    window.location.replace(
                        '/accueil/classe/' + classe_slug + '/eleve/' + eleve_slug);
                    eleve_id = 0;
                    classe_libelle = "";
                    payement_id = 0;
                    eleve_slug = "";
                } else {
                    console.log('Le payement n\'est pas supprimé');
                    eleve_id = 0;
                    classe_libelle = "";
                    payement_id = 0;
                    eleve_slug = "";
                }
            },
            error: function(response) {
                console.log(response);
            }
        });
    });

    //Ajouter Frais
    $('#is_payed').change(function() {
        if (this.checked) {
            $(this).val(1)
        } else {
            $(this).val(0)
        }
    });
    $('#submit_form_ajouter_frais').on('click', function(e) {
        $('#form_ajouter_frais').validate({
            rules: {
                type_frais: {
                    required: true,
                },
                montant_frais: {
                    required: true,
                }
            },
            messages: {
                type_frais: {
                    required: "Renseigner le type du frais svp!",
                },
                montant_frais: {
                    required: "Précisez le montant du frais svp!",
                },
            },
            submitHandler: function() {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: "/accueil/classe/<?php echo e($classe->slug); ?>/eleve/" + eleve_slug +
                        "/payement/ajouterFrais",
                    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_slug: eleve_slug,
                        type_frais: $('#type_frais_id').val(),
                        montant_frais: Number($('#montant_frais_id').val().replace(/\s/g,
                            '')),
                        est_paye: $('#is_payed').val(),
                    },
                    success: function(response) {
                        if (response == true) {
                            window.location.replace(
                                '/accueil/classe/<?php echo e($classe->slug); ?>/eleve/' +
                                eleve_slug
                            );
                        }
                    },
                    error: function(response) {
                        console.log(response);
                    }
                });
            }
        })
    });

    //Reinscription
    var newMensualite = 0;
    var newInscription = 0;
    var eleve_id = 0;

    function getNewMensualite(mensualite) {
        newMensualite = mensualite;
    }

    function getNewInscription(inscription) {
        newInscription = inscription;
    }

    $('#submit_form_reinscrire').on('click', function() {
        $('#form_reinscrire').validate({
            rules: {
                new_classe: {
                    required: true,
                },
                new_inscription: {
                    required: true,
                },
                new_mensualite: {
                    required: true,
                },
            },
            messages: {
                new_classe: {
                    required: "La classe est obligatoire!",
                },
                new_inscription: {
                    required: "Le montant de l'inscription est obligatoire",
                },
                new_mensualite: {
                    required: "Le montant de la mensualite est obligatoire",
                },
            },
            submitHandler: function() {
                $.ajaxSetup({
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    }
                });
                $.ajax({
                    url: "/accueil/classe/<?php echo e($classe->slug); ?>/eleve/<?php echo e($eleve->slug); ?>/reinscrire",
                    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,
                        new_classe_id: $('#new_classe_id').val(),
                        new_inscription: Number($('#new_inscription_id').val().replace(
                            /\s/g, '')),
                        new_mensualite: Number($('#new_mensualite_id').val().replace(/\s/g,
                            '')),
                    },
                    success: function(response) {
                        if (response == true) {
                            window.location.replace(
                                '/accueil/classe/<?php echo e($classe->slug); ?>/eleve/<?php echo e($eleve->slug); ?>'
                            );
                        }
                    },
                    error: function(response) {
                        console.log(response);
                    }
                });
            }
        });
    });

    //Reinitialisation password
    var compte_slug = "";

    function get_compte_slug(slug) {
        compte_slug = slug;
    }

    $('#btn_reinPassword').on('click', function() {
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        $.ajax({
            url: "/accueil/comptes/compte/" + compte_slug + "/reinpassword",
            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: {

            },
            success: function(response) {
                if (response == true) {
                    window.location.replace(
                        '/accueil/classe/<?php echo e($classe->slug); ?>/eleve/<?php echo e($eleve->slug); ?>'
                    );
                }
            },
            error: function(response) {
                console.log(response);
            }
        });
    });

    //JS pour le formatage des montant afficher des payements et des telephones
    var cleave = new Cleave('#tel_tuteur', {
        phone: true,
        phoneRegionCode: 'SN'
    });

    var cleave = new Cleave('#inscription', {
        delimiter: ' ',
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });

    var cleave = new Cleave('#new_inscription_id', {
        delimiter: ' ',
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });

    var cleave = new Cleave('#mensualite', {
        delimiter: ' ',
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });

    var cleave = new Cleave('#new_mensualite_id', {
        delimiter: ' ',
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });

    var cleave = new Cleave('#montant_id', {
        delimiter: ' ',
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });

    var cleave = new Cleave('#montant_frais_id', {
        delimiter: ' ',
        numeral: true,
        numeralThousandsGroupStyle: 'thousand'
    });

    //ChartJs
    const labels1 = [
        <?php $__currentLoopData = $evaluations1; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            "<?php echo e($evaluation->date); ?> . <?php echo e(str_replace('\'', ' ', $evaluation->matiere->libelle)); ?>",
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    ];

    const data1 = {
        labels: labels1,
        datasets: [{
            label: 'Evolution 1er semestre/trimestre',
            backgroundColor: 'rgb(62,142,208)',
            borderColor: 'rgb(62,142,208)',
            data: [
                <?php $__currentLoopData = $notes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $note): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($classe->type == 'Primaire'): ?>
                        <?php $__currentLoopData = $evaluations1; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($evaluation->id == $note->evaluation_id): ?>
                                <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($matiere->id == $evaluation->matiere_id): ?>
                                        (<?php echo e($note->valeur); ?> * 10) / <?php echo e($matiere->coefficient); ?>,
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php else: ?>
                        <?php $__currentLoopData = $evaluations1; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($evaluation->id == $note->evaluation_id): ?>
                                <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($matiere->id == $evaluation->matiere_id): ?>
                                        <?php echo e($note->valeur); ?>,
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            ],
        }]
    };

    const config1 = {
        type: 'line',
        data: data1,
        options: {
            scales: {
                y: { // defining min and max so hiding the dataset does not change scale range
                    min: 0,
                    <?php if($classe->type == 'Primaire'): ?>
                        max: 10
                    <?php else: ?>
                        max: 20
                    <?php endif; ?>
                },
                x: {
                    display: false
                }
            }
        }
    };

    const chartEleve1 = new Chart(
        document.getElementById('chartEleve1'),
        config1
    );

    //
    //ChartJs
    const labels2 = [
        <?php $__currentLoopData = $evaluations2; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            "<?php echo e($evaluation->date); ?> . <?php echo e(str_replace('\'', ' ', $evaluation->matiere->libelle)); ?>",
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    ];

    const data2 = {
        labels: labels2,
        datasets: [{
            label: 'Evolution 2nd semestre/trimestre',
            backgroundColor: 'rgb(62,142,208)',
            borderColor: 'rgb(62,142,208)',
            data: [
                <?php $__currentLoopData = $notes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $note): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($classe->type == 'Primaire'): ?>
                        <?php $__currentLoopData = $evaluations2; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($evaluation->id == $note->evaluation_id): ?>
                                <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($matiere->id == $evaluation->matiere_id): ?>
                                        (<?php echo e($note->valeur); ?> * 10) / <?php echo e($matiere->coefficient); ?>,
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php else: ?>
                        <?php $__currentLoopData = $evaluations2; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($evaluation->id == $note->evaluation_id): ?>
                                <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($matiere->id == $evaluation->matiere_id): ?>
                                        <?php echo e($note->valeur); ?>,
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            ],
        }]
    };

    const config2 = {
        type: 'line',
        data: data2,
        options: {
            scales: {
                y: { // defining min and max so hiding the dataset does not change scale range
                    min: 0,
                    <?php if($classe->type == 'Primaire'): ?>
                        max: 10
                    <?php else: ?>
                        max: 20
                    <?php endif; ?>
                },
                x: {
                    display: false
                }
            }
        }
    };

    const chartEleve2 = new Chart(
        document.getElementById('chartEleve2'),
        config2
    );

    //
    //ChartJs
    const labels3 = [
        <?php $__currentLoopData = $evaluations3; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            "<?php echo e($evaluation->date); ?> . <?php echo e(str_replace('\'', ' ', $evaluation->matiere->libelle)); ?>",
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    ];

    const data3 = {
        labels: labels3,
        datasets: [{
            label: 'Evolution 3e trimestre',
            backgroundColor: 'rgb(62,142,208)',
            borderColor: 'rgb(62,142,208)',
            data: [
                <?php $__currentLoopData = $notes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $note): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php if($classe->type == 'Primaire'): ?>
                        <?php $__currentLoopData = $evaluations3; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($evaluation->id == $note->evaluation_id): ?>
                                <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($matiere->id == $evaluation->matiere_id): ?>
                                        (<?php echo e($note->valeur); ?> * 10) / <?php echo e($matiere->coefficient); ?>,
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php else: ?>
                        <?php $__currentLoopData = $evaluations3; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $evaluation): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <?php if($evaluation->id == $note->evaluation_id): ?>
                                <?php $__currentLoopData = $matieres; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $matiere): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                    <?php if($matiere->id == $evaluation->matiere_id): ?>
                                        <?php echo e($note->valeur); ?>,
                                    <?php endif; ?>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                            <?php endif; ?>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    <?php endif; ?>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            ],
        }]
    };

    const config3 = {
        type: 'line',
        data: data3,
        options: {
            scales: {
                y: { // defining min and max so hiding the dataset does not change scale range
                    min: 0,
                    <?php if($classe->type == 'Primaire'): ?>
                        max: 10
                    <?php else: ?>
                        max: 20
                    <?php endif; ?>
                },
                x: {
                    display: false
                }
            }
        }
    };

    const chartEleve3 = new Chart(
        document.getElementById('chartEleve3'),
        config3
    );
</script>
<?php /**PATH /home/dide1435/luqman.upschool-sn.com/resources/views//partials/eleveJs.blade.php ENDPATH**/ ?>