<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Mes Informations</title>
    <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
    <link rel="icon" href="../../media/img/logoIcon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../../css/PROF/mes-infos.css">
</head>
<body>

    <div class="header w3-bar w3-card-4 w3-dark-blue">
        <!-- Logo pour retourner à l'accueil -->
        <div class="logo-container w3-bar-item">
            <img src="../../media/img/logoWhite.png" alt="Logo Accueil" class="w3-image" style="width:150px; height:40px;">
        </div>
    
        <!-- Bouton burger pour petit écran -->
        <a href="javascript:void(0)" class="w3-bar-item w3-button w3-hide-large w3-right w3-padding-16" onclick="toggleMenu()">☰</a>
    
        <!-- Catégories dans le header -->
        <div id="menu" class="categories w3-hide-small w3-hide-medium w3-bar-item">
            <a href="./enseignant_permanent.html" class="w3-bar-item w3-button">Accueil</a>
            <a href="./mes-heures.html" class="w3-bar-item w3-button">Heures</a>
            <a href="./paiements.html" class="w3-bar-item w3-button">Paiements</a>
            <a href="./mes-informations.html" class="w3-bar-item w3-button">Mes informations et documents</a>
        </div>
    
        <!-- Section utilisateur avec déconnexion -->
        <div class="user-section w3-right w3-hide-small w3-hide-medium">
            <div class="user-name">
                Denis MONNERAT
            </div>
            <div class="logout-container w3-bar-item">
                <a href="./notifications.html" title="Notifications">
                    <img src="../../media/img/notifs.png" alt="Logo notification" style="width:24px; height:24px;">
                </a>
                <a href="./settings.html" title="Paramètres">
                    <img src="../../media/img/settings.png" alt="Logo paramètres" style="width:24px; height:24px;">
                </a>
                <a href="../../index.html" title="Se déconnecter">
                    <img src="../../media/img/LogOutWhite.png" alt="Logo Déconnexion" style="width:24px; height:24px;">
                </a>
            </div>
        </div>
    
        <!-- Menu mobile caché au départ -->
        <div id="mobileMenu" class="w3-bar-block w3-hide w3-hide-large w3-dark-blue">
            <a href="./enseignant_permanent.html" class="w3-bar-item w3-button">Accueil</a>
            <a href="./mes-heures.html" class="w3-bar-item w3-button">Heures</a>
            <a href="./paiements.html" class="w3-bar-item w3-button">Paiements</a>
            <a href="./mes-informations.html" class="w3-bar-item w3-button">Mes informations et documents</a>
    
            <!-- Section utilisateur pour mobile -->
            <div class="w3-bar-item w3-border-top w3-margin-top">
                <div class="user-name">Denis MONNERAT</div>
                <a href="./notifications.html" title="Notifications">
                    <img src="../../media/img/notifs.png" alt="Logo notification" style="width:24px; height:24px;">
                </a>
                <a href="./settings.html" title="Paramètres">
                    <img src="../../media/img/settings.png" alt="Logo paramètres" style="width:24px; height:24px;">
                </a>
                <a href="../../index.html" title="Se déconnecter">
                    <img src="../../media/img/LogOutWhite.png" alt="Logo Déconnexion" style="width:24px; height:24px;">
                </a>
            </div>
        </div>
    </div>

<div class="container">
    <!-- Section Informations Personnelles -->
    <div class="info-card">
        <h2>Informations Personnelles</h2>
        <table class="info-table">
            <tr>
                <th>Nom Complet</th>
                <td><input type="text" id="nom" value="Denis MONNERAT" class="non-editable" readonly></td>
            </tr>
            <tr>
                <th>Date de Naissance</th>
                <td><input type="text" id="date_naissance" value="15 Mars 1985" class="non-editable" readonly></td>
            </tr>
            <tr>
                <th>Ville de Naissance</th>
                <td><input type="text" id="ville_naissance" value="Paris" class="non-editable" readonly></td>
            </tr>
            <tr>
                <th>Adresse</th>
                <td><input type="text" id="adresse" value="12 Rue de la République, 75000 Paris"></td>
            </tr>
            <tr>
                <th>E-mail (professionnel)</th>
                <td><input type="email" id="email-pro" value="denis.monnerat@u-pec.fr"></td>
            </tr>
            <tr>
                <th>Téléphone</th>
                <td><input type="tel" id="telephone" value="07 69 55 14 55"></td>
            </tr>
            <tr>
                <th>Numéro de Sécurité Sociale</th>
                <td><input type="text" id="numero_securite" value="1 85 03 75 123 456 78" class="non-editable" readonly></td>
            </tr>
        </table>
        <button class="action-btn" onclick="saveInfo()">Sauvegarder les modifications</button>
    </div>

    <!-- Section Informations Bancaires -->
    <div class="info-card">
        <h2>Informations Bancaires</h2>
        <table class="info-table">
            <tr>
                <th>Banque</th>
                <td><input type="text" id="banque" value="BNP Paribas"></td>
            </tr>
            <tr>
                <th>IBAN</th>
                <td><input type="text" id="iban" value="FR76 3000 6000 0112 3456 7890 189"></td>
            </tr>
            <tr>
                <th>BIC</th>
                <td><input type="text" id="bic" value="BNPAFRPPXXX"></td>
            </tr>
        </table>
        <button class="action-btn" onclick="saveBankInfo()">Sauvegarder les informations bancaires</button>
    </div>

    <!-- Section Documents -->
    <div class="info-card">
        <h2>Documents Officiels</h2>
        <table class="info-table">
            <tr>
                <th>Pièce d'identité</th>
                <td><a href="../../media/documents/VACATAIRE/CarteIdentite.pdf">Télécharger</a></td>
            </tr>
            <tr>
                <th>Contrat de Travail</th>
                <td><a href="../../media/documents/VACATAIRE/ContratDeTravail.pdf">Télécharger</a></td>
            </tr>
            <tr>
                <th>Justificatif de Domicile</th>
                <td><a href="../../media/documents/VACATAIRE/JustificatifDomicile.pdf">Télécharger</a></td>
            </tr>
        </table>
    </div>

    <div class="info-card">
        <h2>Envoyer un Document</h2>
        <form id="uploadForm" onsubmit="return false;">
            <label for="documentType">Type de document :</label>
            <select id="documentType" class="document-select">
                <option value="" disabled selected>Sélectionnez un type de document</option>
                <option value="carte_identite">Carte d'Identité</option>
                <option value="contrat_travail">Contrat de Travail</option>
                <option value="justificatif_domicile">Justificatif de Domicile</option>
                <option value="releve_bancaire">Relevé Bancaire</option>
                <option value="certificat_medical">Certificat Médical</option>
                <option value="avis_imposition">Avis d'Imposition</option>
                <option value="permis_conduire">Permis de Conduire</option>
                <option value="passeport">Passeport</option>
                <option value="facture">Facture</option>
                <option value="autre">Autre</option>
            </select>
    
            <label for="newDocument" class="file-upload-label">
                Choisir un fichier
            </label>
            <input type="file" id="newDocument" accept=".pdf,.doc,.docx" style="display: none;" onchange="updateFileName()">
            <span id="fileName" class="file-name">Aucun fichier choisi</span>
            <button class="action-btn" onclick="uploadDocument()">Envoyer le document</button>
        </form>
    </div>
   
</div>

<!-- Popup de confirmation -->
<div class="popup" id="popup">
    <img src="https://img.icons8.com/ios-filled/50/155724/checkmark.png" alt="Coche">
    <h4>Message envoyé</h4>
    <p>Votre document a été transmis à la direction. Un email de confirmation vous a été envoyé.</p>
    <button onclick="fermerPopup()">Fermer</button>
</div>

<!-- Footer -->
<div class="footer">
    <p>&copy; 2024 IUT de Fontainebleau. Tous droits réservés | <a href="html/mentions_legales.html" style="color: white;">Mentions légales</a></p>
</div>

<script>
    // Sauvegarder les informations personnelles dans le localStorage
    function saveInfo() {
        const ville_naissance = document.getElementById('ville_naissance').value;
        const adresse = document.getElementById('adresse').value;
        const email_pro = document.getElementById('email-pro').value;
        const telephone = document.getElementById('telephone').value;
        const numero_securite = document.getElementById('numero_securite').value;
        const statut = document.getElementById('statut').value;

        // Enregistrer les valeurs dans le localStorage
        localStorage.setItem('ville_naissance', ville_naissance);
        localStorage.setItem('adresse', adresse);
        localStorage.setItem('email-pro', email_pro);
        localStorage.setItem('telephone', telephone);
        localStorage.setItem('numero_securite', numero_securite);
        localStorage.setItem('statut', statut);

        alert('Informations personnelles sauvegardées !');
    }

    // Sauvegarder les informations bancaires dans le localStorage
    function saveBankInfo() {
        const banque = document.getElementById('banque').value;
        const iban = document.getElementById('iban').value;
        const bic = document.getElementById('bic').value;

        // Enregistrer les valeurs dans le localStorage
        localStorage.setItem('banque', banque);
        localStorage.setItem('iban', iban);
        localStorage.setItem('bic', bic);

        alert('Informations bancaires sauvegardées !');
    }

    // Récupérer les informations depuis le localStorage (si elles existent)
    function loadInfo() {
        if(localStorage.getItem('ville_naissance')) {
            document.getElementById('ville_naissance').value = localStorage.getItem('ville_naissance');
        }
        if(localStorage.getItem('adresse')) {
            document.getElementById('adresse').value = localStorage.getItem('adresse');
        }
        
        if(localStorage.getItem('email-pro')) {
            document.getElementById('email-pro').value = localStorage.getItem('email-pro');
        }
        if(localStorage.getItem('telephone')) {
            document.getElementById('telephone').value = localStorage.getItem('telephone');
        }
        if(localStorage.getItem('numero_securite')) {
            document.getElementById('numero_securite').value = localStorage.getItem('numero_securite');
        }
        if(localStorage.getItem('statut')) {
            document.getElementById('statut').value = localStorage.getItem('statut');
        }

        // Informations bancaires
        if(localStorage.getItem('banque')) {
            document.getElementById('banque').value = localStorage.getItem('banque');
        }
        if(localStorage.getItem('iban')) {
            document.getElementById('iban').value = localStorage.getItem('iban');
        }
        if(localStorage.getItem('bic')) {
            document.getElementById('bic').value = localStorage.getItem('bic');
        }
    }

    // Charger les informations quand la page est chargée
    window.onload = loadInfo;

    function uploadDocument() {
        const documentType = document.getElementById('documentType').value;
        const fileInput = document.getElementById('newDocument').files[0];
        
        if (!documentType) {
            alert("Veuillez sélectionner un type de document.");
            return;
        }

        if (!fileInput) {
            alert("Veuillez choisir un fichier à envoyer.");
            return;
        }

        // Simulation d'un envoi réussi (ajoutez votre logique d'envoi ici)
        document.getElementById('fileName').textContent = "Aucun fichier choisi"; // Réinitialiser le nom de fichier
        
        // Afficher le document en attente de traitement
        const documentsTable = document.querySelector('.info-table'); // La table où afficher les documents
        const newRow = documentsTable.insertRow(-1); // Insérer une nouvelle ligne à la fin

        // Ajouter des cellules pour le type de document et le statut
        newRow.innerHTML = `<th>${documentType.replace(/_/g, ' ').toUpperCase()}</th><td>En attente de traitement</td>`;

        // Ouvrir le pop-up de confirmation
        document.getElementById('popup').style.display = 'block'; // Ouvrir le pop-up
    }


    function updateFileName() {
    const fileInput = document.getElementById('newDocument');
    const fileNameDisplay = document.getElementById('fileName');
    if (fileInput.files.length > 0) {
        fileNameDisplay.textContent = fileInput.files[0].name;
    } else {
        fileNameDisplay.textContent = 'Aucun fichier choisi';
    }
}


    // Fermer la pop-up
    function fermerPopup() {
        document.getElementById('popup').style.display = 'none';
    }

    function toggleMenu() {
            var x = document.getElementById("mobileMenu");
            if (x.className.indexOf("w3-show") == -1) {
                x.className += " w3-show";
            } else {
                x.className = x.className.replace(" w3-show", "");
            }
        }

</script>

</body>
</html>