assure/Vue/Ajaxconnexioncookie/french.php

436 lines
17 KiB
PHP
Executable File

<?php
$maintenance = $societeusersaas['maintenance'];
if($maintenance=='1')
{
$msgErreur = 'Site en maintenance, veuillez vous reconnecter plus tard!';
}
?>
<!-- Tableau desktop (affiché sur les écrans moyens et grands) -->
<div class="d-md-none">
<!-- VERSION MOBILE PARFAITEMENT HARMONISÉE -->
<div style="width: 100%; max-width: 100%; box-sizing: border-box; padding: 15px;">
<!-- Titre -->
<span class="login100-form-title" style="font-family: Play-Bold; color:#e5e5e5; margin: 10px 0 20px 0; display: block; font-size: 20px; text-align: center; line-height: 1.2;">
Portail Assuré
</span>
<?php if (isset($msgErreur) and $msgErreur>" "): ?>
<div class="text-center" style="margin-bottom: 15px;">
<div style="background-color: #f8d7da; color: #721c24; padding: 10px; border-radius: 8px; font-size: 13px; border: 1px solid #f5c6cb; max-width: 300px; margin: 0 auto;">
<?= $msgErreur ?>
</div>
</div>
<?php else: ?>
<div class="text-center" id="div_msgErreur_mobile" style="margin-bottom: 15px;"></div>
<?php endif; ?>
<?php if($maintenance!='1'): ?>
<!-- CONTENEUR UNIFORME POUR TOUS LES ÉLÉMENTS -->
<div style="width: 100%; max-width: 300px; margin: 0 auto;">
<!-- Langue -->
<div style="margin-bottom: 15px;">
<label for="langue_mobile" style="font-size: 12pt; display: block; margin-bottom: 5px; text-align: center; width: 100%;">Langue</label>
<select id="langue_mobile" name="langue_mobile"
style="width: 100%; height: 42px; padding: 0 15px; border: 2px solid #7D4FFE; border-radius: 9px; background: #ffffff; font-size: 14px; color: #7D4FFE; text-align: center; box-sizing: border-box; -webkit-appearance: none; -moz-appearance: none; appearance: none;"
required onchange="changerLangueMobile(this.value);">
<?php liste_options($langues, $_SESSION['lang'], true); ?>
</select>
</div>
<!-- Entité -->
<div style="margin-bottom: 15px;">
<label for="codeSociete_mobile" style="font-size: 12pt; display: block; margin-bottom: 5px; text-align: center; width: 100%;">Entité</label>
<input type="text" id="codeSociete_mobile" name="codeSociete_mobile" value="<?= $codeSociete ?>"
placeholder="Entité"
style="width: 100%; height: 42px; padding: 0 15px; border: 2px solid #7D4FFE; border-radius: 9px; color: #7D4FFE; text-align: center; box-sizing: border-box; font-size: 14px; background: #ffffff;"
required autocomplete="off"
onchange="changerEntiteMobile(this.value);">
</div>
<!-- Identifiant -->
<div style="margin-bottom: 15px;">
<label for="login_mobile" style="font-size: 12pt; display: block; margin-bottom: 5px; text-align: center; width: 100%;">Identifiant</label>
<input type="text" id="login_mobile" name="login_mobile" value="<?= $codeUtilisateur ?>"
placeholder="Identifiant"
style="width: 100%; height: 42px; padding: 0 15px; border: 2px solid #7D4FFE; border-radius: 9px; color: #7D4FFE; text-align: center; box-sizing: border-box; font-size: 14px; background: #ffffff;"
required autocomplete="off">
</div>
<!-- Mot de passe -->
<div style="margin-bottom: 20px;">
<label for="mdp_mobile" style="font-size: 12pt; display: block; margin-bottom: 5px; text-align: center; width: 100%;">Mot de passe</label>
<input type="password" id="mdp_mobile" name="mdp_mobile" placeholder="Mot de passe"
style="width: 100%; height: 42px; padding: 0 15px; border: 2px solid #7D4FFE; border-radius: 9px; color: #7D4FFE; text-align: center; box-sizing: border-box; font-size: 14px; background: #ffffff;"
required autocomplete="off">
</div>
<!-- Bouton Connexion - MÊME LARGEUR -->
<div style="margin-bottom: 15px;">
<button type="button" id="btn_connexion_mobile"
style="width: 100%; height: 46px; background: #7D4FFE; color: white; font-size: 16px; font-weight: 700; border-radius: 9px; border: none; box-sizing: border-box; cursor: pointer;">
Connexion
</button>
</div>
</div>
<!-- Footer -->
<div style="font-size: 11px; text-align: center; padding: 10px 0; color: #666; width: 100%; max-width: 300px; margin: 20px auto 0;">
Tous droits réservés <a href="https://www.ebene.info/" style="color: #7D4FFE; text-decoration: none;">&copy; EBENE SOLUTIONS INFORMATIQUES</a>
</div>
<?php endif; ?>
</div>
</div>
<!-- STYLES POUR HARMONISATION ET CONNEXION -->
<style>
/* STYLES MOBILE HARMONISÉS */
@media screen and (max-width: 767px) {
/* 1. MASQUER DESKTOP, MONTRER MOBILE */
.d-none.d-md-block {
display: none !important;
}
.d-md-none {
display: block !important;
width: 100vw !important;
max-width: 100vw !important;
overflow-x: hidden !important;
}
/* 2. CORRECTIONS GLOBALES */
body, html {
overflow-x: hidden !important;
width: 100vw !important;
}
.container-fluid {
width: 100vw !important;
max-width: 100vw !important;
}
/* 3. HARMONISATION DES LARGEURS - TOUT À 300px */
.d-md-none > div > div:last-child {
width: 100% !important;
max-width: 300px !important;
margin: 0 auto !important;
}
/* 4. STYLES IDENTIQUES POUR TOUS LES CHAMPS */
.d-md-none select,
.d-md-none input[type="text"],
.d-md-none input[type="password"] {
width: 100% !important;
max-width: 300px !important;
height: 42px !important;
border: 2px solid #7D4FFE !important;
border-radius: 9px !important;
background: #ffffff !important;
color: #7D4FFE !important;
font-size: 14px !important;
text-align: center !important;
padding: 0 15px !important;
box-sizing: border-box !important;
margin: 0 auto !important;
display: block !important;
}
/* 5. BOUTON - MÊME LARGEUR */
#btn_connexion_mobile {
width: 100% !important;
max-width: 300px !important;
height: 46px !important;
background: #7D4FFE !important;
color: white !important;
border-radius: 9px !important;
font-size: 16px !important;
margin: 0 auto !important;
display: block !important;
}
/* 6. HOVER CONSISTANT */
#btn_connexion_mobile:hover,
#btn_connexion_mobile:active {
background: white !important;
color: #7D4FFE !important;
border: 2px solid #7D4FFE !important;
}
/* 7. FOCUS STYLES */
.d-md-none select:focus,
.d-md-none input:focus {
outline: none !important;
box-shadow: 0 0 0 3px rgba(125, 79, 254, 0.2) !important;
}
/* 8. PLACEHOLDER */
.d-md-none input::placeholder {
font-weight: bold !important;
color: #7D4FFE !important;
opacity: 0.7 !important;
}
/* 9. LABELS CONSISTANTS */
.d-md-none label {
font-size: 12pt !important;
text-align: center !important;
display: block !important;
width: 100% !important;
margin-bottom: 5px !important;
}
/* 10. CORRECTION SELECT (supprimer flèche par défaut) */
.d-md-none select {
-webkit-appearance: none !important;
-moz-appearance: none !important;
appearance: none !important;
background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%237D4FFE'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e") !important;
background-repeat: no-repeat !important;
background-position: right 15px center !important;
background-size: 20px !important;
}
/* 11. ESPACEMENT UNIFORME */
.d-md-none > div > div:last-child > div {
margin-bottom: 15px !important;
}
/* 12. FOOTER HARMONISÉ */
.d-md-none .footer {
max-width: 300px !important;
margin: 20px auto 0 !important;
font-size: 11px !important;
}
}
/* POUR TRÈS PETITS ÉCRANS */
@media screen and (max-width: 320px) {
.d-md-none > div > div:last-child,
.d-md-none select,
.d-md-none input,
#btn_connexion_mobile,
.d-md-none .footer {
max-width: 280px !important;
}
}
/* CACHER MOBILE SUR DESKTOP */
@media screen and (min-width: 768px) {
.d-md-none {
display: none !important;
}
}
</style>
<script>
// ============================================
// LOGIQUE DE CONNEXION FONCTIONNELLE
// ============================================
// 1. SYNCHRONISATION AVEC LE DESKTOP
function synchroniserAvecDesktop() {
// Synchroniser les valeurs entre mobile et desktop
const champs = [
{mobile: 'langue_mobile', desktop: 'langue'},
{mobile: 'codeSociete_mobile', desktop: 'codeSociete'},
{mobile: 'login_mobile', desktop: 'login'},
{mobile: 'mdp_mobile', desktop: 'mdp'}
];
champs.forEach(champ => {
const champMobile = document.getElementById(champ.mobile);
const champDesktop = document.getElementById(champ.desktop);
if (champMobile && champDesktop) {
// Mobile → Desktop
champMobile.addEventListener('change', function() {
champDesktop.value = this.value;
});
// Desktop → Mobile (au cas où)
champDesktop.addEventListener('change', function() {
champMobile.value = this.value;
});
}
});
}
// 2. FONCTIONS DE CHANGEMENT
function changerLangueMobile(langue) {
const desktopLangue = document.getElementById('langue');
if (desktopLangue) {
desktopLangue.value = langue;
// Déclencher l'événement original
if (typeof changer_langue_connexion === 'function') {
changer_langue_connexion();
}
}
}
function changerEntiteMobile(entite) {
const desktopEntite = document.getElementById('codeSociete');
if (desktopEntite) {
desktopEntite.value = entite;
// Déclencher l'événement original
if (typeof changer_entite_portail === 'function') {
changer_entite_portail();
}
}
}
// 3. FONCTION DE CONNEXION PRINCIPALE
function connecterMobile() {
// Récupérer les valeurs
const codeSociete = document.getElementById('codeSociete_mobile').value.trim();
const login = document.getElementById('login_mobile').value.trim();
const mdp = document.getElementById('mdp_mobile').value.trim();
const langue = document.getElementById('langue_mobile').value;
// Validation
if (!codeSociete || !login || !mdp) {
alert('Veuillez remplir tous les champs obligatoires');
return false;
}
console.log('Tentative de connexion mobile:', {codeSociete, login, mdp, langue});
// OPTION 1: Utiliser le formulaire desktop existant
const formulaireDesktop = document.querySelector('form');
if (formulaireDesktop) {
// Mettre à jour les champs du formulaire
const donnees = {
'codeSociete': codeSociete,
'login': login,
'mdp': mdp,
'langue': langue
};
Object.keys(donnees).forEach(nom => {
const champ = document.getElementById(nom);
if (champ) {
champ.value = donnees[nom];
}
});
// Soumettre le formulaire
formulaireDesktop.submit();
return true;
}
// OPTION 2: Si pas de formulaire, utiliser fetch/AJAX
// (Adaptez cette partie à votre backend)
const donnees = new FormData();
donnees.append('codeSociete', codeSociete);
donnees.append('login', login);
donnees.append('mdp', mdp);
donnees.append('langue', langue);
donnees.append('action', 'connexion_mobile');
fetch(window.location.href, {
method: 'POST',
body: donnees,
headers: {
'X-Requested-With': 'XMLHttpRequest'
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
window.location.href = data.redirect || window.location.href;
} else {
alert(data.message || 'Erreur de connexion');
}
})
.catch(error => {
console.error('Erreur:', error);
alert('Erreur réseau');
});
return false;
}
// 4. INITIALISATION AU CHARGEMENT
document.addEventListener('DOMContentLoaded', function() {
// Synchroniser les champs
synchroniserAvecDesktop();
// Gérer le bouton de connexion mobile
const btnMobile = document.getElementById('btn_connexion_mobile');
if (btnMobile) {
btnMobile.addEventListener('click', connecterMobile);
}
// Gérer la touche Entrée
document.querySelectorAll('.d-md-none input').forEach(input => {
input.addEventListener('keypress', function(e) {
if (e.key === 'Enter') {
e.preventDefault();
connecterMobile();
}
});
});
// Gestion responsive
function gererAffichageResponsive() {
const isMobile = window.innerWidth <= 767;
const mobileDiv = document.querySelector('.d-md-none');
const desktopDiv = document.querySelector('.d-none.d-md-block');
if (isMobile) {
if (mobileDiv) mobileDiv.style.display = 'block';
if (desktopDiv) desktopDiv.style.display = 'none';
} else {
if (mobileDiv) mobileDiv.style.display = 'none';
if (desktopDiv) desktopDiv.style.display = 'block';
}
}
// Appliquer
gererAffichageResponsive();
window.addEventListener('resize', gererAffichageResponsive);
// Forcer l'harmonisation des largeurs
setTimeout(function() {
if (window.innerWidth <= 767) {
const elements = document.querySelectorAll('.d-md-none select, .d-md-none input, #btn_connexion_mobile');
elements.forEach(el => {
el.style.width = '100%';
el.style.maxWidth = '300px';
el.style.margin = '0 auto';
el.style.display = 'block';
});
}
}, 100);
});
// 5. FALLBACK: Si les fonctions desktop existent, les utiliser
function utiliserFonctionsDesktop() {
// Bouton de connexion desktop
const btnDesktop = document.getElementById('btn_connexion');
if (btnDesktop) {
btnDesktop.addEventListener('click', function() {
// Récupérer les valeurs mobiles
const codeSociete = document.getElementById('codeSociete_mobile').value;
const login = document.getElementById('login_mobile').value;
const mdp = document.getElementById('mdp_mobile').value;
// Mettre à jour les champs desktop
document.getElementById('codeSociete').value = codeSociete;
document.getElementById('login').value = login;
document.getElementById('mdp').value = mdp;
// Déclencher le clic sur le bouton desktop
this.click();
});
}
}
// Exécuter le fallback
setTimeout(utiliserFonctionsDesktop, 500);
</script>