{"id":544,"date":"2025-03-18T00:46:01","date_gmt":"2025-03-17T23:46:01","guid":{"rendered":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/?page_id=544"},"modified":"2025-04-01T09:57:55","modified_gmt":"2025-04-01T07:57:55","slug":"saisie-comptage-des-eleves-v2","status":"publish","type":"page","link":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/saisie-comptage-des-eleves-v2\/","title":{"rendered":"Saisie Participation"},"content":{"rendered":"\n<!DOCTYPE html>\n<html lang=\"fr\">\n<head>\n    <meta charset=\"UTF-8\">\n    <title>Liste des \u00e9coles<\/title>\n    <style>\n       \n #tableauComptage {\n            display: none;\n            margin-left: 15cm; \/* D\u00e9calage de 15 cm \u00e0 droite *\/\n            margin-top: 10px;\n        }\n #schoolList {\n            margin-left: 15cm; \/* D\u00e9calage de 15 cm \u00e0 droite *\/\n            margin-bottom: 20px;\n        }\n #schoolInfo {\n            margin-left: 18cm; \/* D\u00e9calage de 18 cm \u00e0 droite *\/\n            margin-bottom: 20px;\n        }\n\n\n\n\n        buttons {\n            display: flex;\n            justify-content: center;\n        }\n.buttons {\n    margin-left: 18cm; \/* D\u00e9calage de 18 cm \u00e0 droite *\/\n    margin-bottom: 20px;\n    display: flex;\n    justify-content: center;\n}        \n.buttons button {\n            margin: 0 10px;\n            padding: 10px 20px;\n            border: none;\n            border-radius: 5px;\n            cursor: pointer;\n            font-size: 16px;\n        }\n        .buttons button.red {\n            background-color: #e74c3c;\n            color: #fff;\n        }\n        .buttons button.green {\n            background-color: #2ecc71;\n            color: #fff;\n        }\n\n\n\n\n #tableauComptage {\n            display: none;\n            margin-top: 10px;\n        }\n table {\n            width: 100%;\n            border-collapse: collapse;\n        }\n th, td {\n            text-align: center;\n            padding: 8px;\n        }\n #tableauComptageTitle {\n    font-size: 24px;\n    margin-bottom: 10px;\n    text-align: center; \/* Centrer le texte *\/\n    }\n #validateButton {\n    display: flex;\n    justify-content: center;\n    margin-top: 20px;\n    }\n #validateButton button {\n     padding: 10px 20px;\n     border: none;\n     border-radius: 5px;\n     cursor: pointer;\n     font-size: 16px;\n     background-color: #2ecc71;\n     color: #fff;\n     }\n    <\/style>\n    <script>\n        function lectureDatabase() {\n            const xhr = new XMLHttpRequest();\n            xhr.open(\"GET\", \"https:\/\/ecoliers-cyclistes.avelomalo.fr\/wp-content\/php-scripts-jbj\/lire-inscription.php\", true);\n            xhr.onreadystatechange = function () {\n                if (xhr.readyState === 4) {\n                    if (xhr.status === 200) {\n                        const jsonResponse = JSON.parse(xhr.responseText);\n                        if (jsonResponse.data) {\n                            const select = document.getElementById('schoolList');\n                            jsonResponse.data.forEach(function(school) {\n                                const option = document.createElement('option');\n                                option.value = JSON.stringify(school);\n                                option.text = school.nom_ecole;\n                                select.appendChild(option);\n                            });\n                            select.addEventListener('change', function() {\n                                const selectedSchool = JSON.parse(select.value);\n   document.getElementById('schoolInfo').innerHTML = \n   `Nom de l'\u00e9cole: ${selectedSchool.nom_ecole}<br>\n Adresse: ${selectedSchool.adresse_ecole}<br>\n Commune: ${selectedSchool.commune_ecole}<br>\n \u00c9tat Inscription: ${selectedSchool.etat_inscription}<br>\n Nombre d'\u00e9l\u00e8ves participants: ${selectedSchool.nombre_eleves_participants}<br>\n Nom du R\u00e9f\u00e9rent: ${selectedSchool.nom_referent}`;\n                                document.getElementById('buttons').style.display = 'block';\n                                document.getElementById('tableauComptageTitle').innerText = `Tableau de comptage - ${selectedSchool.nom_ecole}`;\n    document.getElementById('lundi19').value = selectedSchool.nb_lundi;\n    document.getElementById('mardi20').value = selectedSchool.nb_mardi;\n    document.getElementById('jeudi22').value = selectedSchool.nb_jeudi;\n    document.getElementById('vendredi23').value = selectedSchool.nb_vendredi;\n                            });\n                        }\n                    } else {\n                        console.error(`Erreur lors de la requ\u00eate : ${xhr.status} ${xhr.statusText}`);\n                    }\n                }\n            };\n            xhr.onerror = function() {\n                console.error(\"Erreur de connexion.\");\n            };\n            xhr.send();\n        }\n\n        function resetPage() {\n            document.getElementById('schoolList').selectedIndex = 0;\n            document.getElementById('schoolInfo').innerHTML = '';\n            document.getElementById('buttons').style.display = 'none';\n            document.getElementById('tableauComptage').style.display = 'none';\n        }\n\n        function validateSelection() {\n            const selectedSchool = JSON.parse(document.getElementById('schoolList').value);\n            document.getElementById('schoolList').style.display = 'none';\n            document.getElementById('buttons').style.display = 'none';\n            document.getElementById('schoolInfo').innerHTML = '';\n            document.getElementById('tableauComptageTitle').innerText = `Tableau de comptage - ${selectedSchool.nom_ecole}`;\n            document.getElementById('tableauComptage').style.display = 'block';\n        }\n\n\nfunction updateDatabase() {\n    const selectedSchool = JSON.parse(document.getElementById('schoolList').value);\n    const nb_lundi = document.getElementById('lundi19').value;\n    const nb_mardi = document.getElementById('mardi20').value;\n    const nb_jeudi = document.getElementById('jeudi22').value;\n    const nb_vendredi = document.getElementById('vendredi23').value;\n\n    const xhr = new XMLHttpRequest();\n    xhr.open(\"POST\", \"https:\/\/ecoliers-cyclistes.avelomalo.fr\/wp-content\/php-scripts-jbj\/ecrire-modification-comptage.php\", true);\n    xhr.setRequestHeader(\"Content-Type\", \"application\/x-www-form-urlencoded\");\n    xhr.onreadystatechange = function () {\n        if (xhr.readyState === 4 && xhr.status === 200) {\n            \/\/ Afficher les informations\n            const currentTime = new Date().toLocaleTimeString();\n            document.getElementById('confirmationMessage').innerHTML = \n                `Mise \u00e0 jour effectu\u00e9e \u00e0 ${currentTime}<br>\n                Nom de l'\u00e9cole: ${selectedSchool.nom_ecole}<br>\n                Nouvelle valeur de nb_lundi: ${nb_lundi}<br>\n                Nouvelle valeur de nb_mardi: ${nb_mardi}<br>\n                Nouvelle valeur de nb_jeudi: ${nb_jeudi}<br>\n                Nouvelle valeur de nb_vendredi: ${nb_vendredi}`;\n    \/\/ Assurer que le message de confirmation reste visible\n    document.getElementById('confirmationMessage').style.display = 'block';\n    \/\/ Cacher le tableau de comptage et le bouton \"Valider\"\n    \/\/ document.getElementById('tableauComptage').style.display = 'none';\n    \/\/ document.getElementById('validateButton').style.display = 'none';\n           \n          } else if (xhr.readyState === 4) {\n            alert(\"Erreur lors de la mise \u00e0 jour des donn\u00e9es.\");\n        }\n    };\n    xhr.send(`nom_ecole=${selectedSchool.nom_ecole}&nb_lundi=${nb_lundi}&nb_mardi=${nb_mardi}&nb_jeudi=${nb_jeudi}&nb_vendredi=${nb_vendredi}`);\n}\n\n     <\/script>\n<\/head>\n<body onload=\"lectureDatabase()\">\n    <select id=\"schoolList\">\n        <option value=\"\">S\u00e9lectionnez une \u00e9cole<\/option>\n    <\/select>\n    <div id=\"schoolInfo\"><\/div>\n    <div id=\"buttons\" class=\"buttons\" style=\"display: none;\">\n        <button style=\"background-color: red;\" onclick=\"resetPage()\">Corriger<\/button>\n        <button style=\"background-color: green;\" onclick=\"validateSelection()\">Valider<\/button>\n    <\/div>\n    <div id=\"tableauComptage\">\n        <h2 id=\"tableauComptageTitle\">Tableau de comptage<\/h2>\n        <table border=\"1\">\n            <tr>\n                <th>Lundi 19<\/th>\n                <th>Mardi 20<\/th>\n                <th>Jeudi 22<\/th>\n                <th>Vendredi 23<\/th>\n            <\/tr>\n            <tr>\n  <td><input type=\"number\" id=\"lundi19\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n  <td><input type=\"number\" id=\"mardi20\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n  <td><input type=\"number\" id=\"jeudi22\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n  <td><input type=\"number\" id=\"vendredi23\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n            <\/tr>\n        <\/table>\n\n\n<div id=\"validateButton\">\n    <button onclick=\"updateDatabase()\">Valider<\/button>\n<\/div>\n<div id=\"confirmationMessage\"><\/div>\n<div id=\"tableauComptage\">\n    <h2 id=\"tableauComptageTitle\">Tableau de comptage<\/h2>\n    <table border=\"1\">\n        <tr>\n            <th>Lundi 19<\/th>\n            <th>Mardi 20<\/th>\n            <th>Jeudi 22<\/th>\n            <th>Vendredi 23<\/th>\n        <\/tr>\n        <tr>\n  <td><input type=\"number\" id=\"lundi19\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n  <td><input type=\"number\" id=\"mardi20\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n  <td><input type=\"number\" id=\"jeudi22\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n  <td><input type=\"number\" id=\"vendredi23\" placeholder=\"Nombre d'\u00e9l\u00e8ves\"><\/td>\n        <\/tr>\n    <\/table>\n<\/div>\n\n\n<\/body>\n<\/html>\n","protected":false},"excerpt":{"rendered":"<p>Liste des \u00e9coles S\u00e9lectionnez une \u00e9cole Corriger Valider Tableau de comptage Lundi 19 Mardi 20 Jeudi 22 Vendredi 23 Valider Tableau de comptage Lundi 19 Mardi 20 Jeudi 22 Vendredi 23<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-544","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/pages\/544","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/comments?post=544"}],"version-history":[{"count":58,"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/pages\/544\/revisions"}],"predecessor-version":[{"id":899,"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/pages\/544\/revisions\/899"}],"wp:attachment":[{"href":"https:\/\/ecoliers-cyclistes.avelomalo.fr\/index.php\/wp-json\/wp\/v2\/media?parent=544"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}