Ceci est une ancienne révision du document !
<!DOCTYPE html> <html lang=“fr” data-bs-theme=“light”>
<head>
<meta charset="UTF-8"> <title>Migration Tool - Marin Dumont</title> <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script> <style> body { padding-top: 70px; transition: background-color 0.3s; }
.card {
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.btn-copy {
font-size: 0.8em;
margin-left: 5px;
padding: 0px 5px;
}
.flash-msg {
color: #198754;
font-weight: bold;
margin-left: 5px;
opacity: 0;
transition: opacity 0.5s;
}
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container-fluid">
<a class="navbar-brand" href="#">MigrationTool</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">Mantis</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item"
href="https://srv-mantis.cpasbru.be/mantisbt/bug_report_page.php"
target="_blank">Créer un ticket</a></li>
<li><a class="dropdown-item" href="https://srv-mantis.cpasbru.be/mantisbt/my_view_page.php"
target="_blank">Ma vue</a></li>
</ul>
</li>
<li class="nav-item"><a class="nav-link" href="https://srv-spx.cpasbru.be/ESS/"
target="_blank">Pointeuse</a></li>
<li class="nav-item"><a class="nav-link" href="https://intranet.cpasbru.be/drupal/fr"
target="_blank">Intranet</a></li>
<li class="nav-item"><a class="nav-link" href="http://srv-del-cont1.cpasbru.be/Director/"
target="_blank">Director</a></li>
</ul>
<div class="d-flex">
<button class="btn btn-outline-light btn-sm" onclick="toggleTheme()" id="theme-btn">Thème
Sombre</button>
</div>
</div>
</div>
</nav>
<div class="container card p-4">
<h2 class="mb-4 text-primary">Migration Tool v3.3 (Compatible Firefox)</h2>
<input type="file" id="file-picker" webkitdirectory directory multiple class="d-none">
<button onclick="document.getElementById('file-picker').click()" class="btn btn-outline-primary mb-3">Charger le
dossier des Waves</button>
<div id="statut-global" class="fw-bold mb-3"></div>
<div class="row g-2 mb-4">
<div class="col-md-3"><input type="text" id="id-in" class="form-control" placeholder="ID"></div>
<div class="col-md-3"><input type="text" id="prenom-in" class="form-control" placeholder="Prénom"></div>
<div class="col-md-3"><input type="text" id="nom-in" class="form-control" placeholder="Nom"></div>
<div class="col-md-3">
<button onclick="rechercher()" class="btn btn-primary">Rechercher</button>
<button onclick="effacer()" class="btn btn-secondary">Effacer</button>
</div>
</div>
<table class="table table-striped table-bordered align-middle">
<thead class="table-dark">
<tr>
<th>Fichier</th>
<th>ID</th>
<th>Nom Complet</th>
<th>Email</th>
</tr>
</thead>
<tbody id="result-body"></tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> <script> let filesData = [];
// Gestion du chargement via input type="file"
document.getElementById('file-picker').addEventListener('change', async (event) => {
filesData = Array.from(event.target.files).filter(f => f.name.match(/^Wave [1-4] - SIM - HRA - NTT\.xlsx$/));
document.getElementById('statut-global').innerText = `✔ ${filesData.length} fichiers chargés.`;
});
function toggleTheme() {
const html = document.documentElement;
const btn = document.getElementById('theme-btn');
const isLight = html.getAttribute('data-bs-theme') === 'light';
html.setAttribute('data-bs-theme', isLight ? 'dark' : 'light');
btn.innerText = isLight ? "Thème Sombre" : "Thème Clair";
}
function creerCellule(texte) {
const td = document.createElement('td');
td.innerHTML = `<div class="d-flex align-items-center"><span class="text-truncate">${texte}</span><button class="btn btn-sm btn-outline-info btn-copy" onclick="copyToClipboard('${texte}', this)">📋</button><span class="flash-msg">✓</span></div>`;
return td;
}
function copyToClipboard(text, element) {
navigator.clipboard.writeText(text);
const flash = element.parentElement.querySelector('.flash-msg');
flash.style.opacity = "1";
setTimeout(() => { flash.style.opacity = "0"; }, 2000);
}
function effacer() {
document.getElementById('result-body').innerHTML = "";
}
async function rechercher() {
const tbody = document.getElementById('result-body');
tbody.innerHTML = "";
const idQ = document.getElementById('id-in').value.toLowerCase();
const prenomQ = document.getElementById('prenom-in').value.toLowerCase();
const nomQ = document.getElementById('nom-in').value.toLowerCase();
for (let file of filesData) {
const data = await file.arrayBuffer();
const wb = XLSX.read(data, { type: 'array' });
const json = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
json.forEach(row => {
const email = String(row['Email address'] || '').toLowerCase();
const parts = email.split('@')[0].split('.');
const prenom = parts[0] || "";
const nom = parts[1] || "";
if (String(row.ID || '').toLowerCase().includes(idQ) &&
prenom.toLowerCase().includes(prenomQ) &&
nom.toLowerCase().includes(nomQ)) {
const tr = document.createElement('tr');
tr.appendChild(creerCellule(file.name));
tr.appendChild(creerCellule(String(row.ID)));
tr.appendChild(creerCellule(row.Name || (nom.toUpperCase() + ' ' + prenom)));
tr.appendChild(creerCellule(row['Email address'] || ''));
tbody.appendChild(tr);
}
});
}
}
</script>
</body>
</html>
