Spaces:
Running

fce-compta / admin.html
ELHASSOUNI's picture
ok merci. le tranfert des pièces justificatives est très long, ç'est même bloquant. merci de corriger - Follow Up Deployment
26352da verified
Raw History Blame Contribute Delete
22.3 kB
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FC Ensisheim - Administration</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
<script src="https://cdn.sheetjs.com/xlsx-0.19.3/package/dist/xlsx.full.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<style>
.bg-fc-red {
background-color: #d62828;
}
.text-fc-red {
color: #d62828;
}
.border-fc-red {
border-color: #d62828;
}
.bg-fc-white {
background-color: #ffffff;
}
.hover\:bg-fc-red:hover {
background-color: #d62828;
}
.hover\:text-fc-white:hover {
color: #ffffff;
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<div id="app" class="min-h-screen flex flex-col">
<!-- Header -->
<header class="bg-fc-red text-white shadow-md">
<div class="container mx-auto px-4 py-4 flex items-center justify-between">
<div class="flex items-center space-x-2">
<img src="https://enzostvs-deepsite.hf.space/_next/image?url=https%3A%2F%2Fhuggingface.co%2Fspaces%2FELHASSOUNI%2Ffce-compta%2Fresolve%2Fmain%2Fimages%2Flogo__FCE%202.jpg&w=64&q=75" alt="Logo FC Ensisheim" class="h-12 w-12 rounded-full border-2 border-white">
<h1 class="text-xl font-bold">FC Ensisheim - Administration</h1>
</div>
<nav>
<ul class="flex space-x-6">
<li><a href="index.html" class="hover:text-gray-200 transition">Formulaire</a></li>
<li><a href="admin.html" class="hover:text-gray-200 transition">Admin</a></li>
<li><button onclick="shareApp()" class="hover:text-gray-200 transition">Partager</button></li>
<li><a href="#" class="hover:text-gray-200 transition">Déconnexion</a></li>
</ul>
</nav>
</div>
</header>
<!-- Main Content -->
<main class="flex-grow container mx-auto px-4 py-8">
<div class="flex justify-between items-center mb-8">
<h2 class="text-2xl font-bold text-gray-800">Documents Comptables</h2>
<div class="flex space-x-4">
<button id="exportExcel" class="bg-green-600 hover:bg-green-700 text-white px-4 py-2 rounded-md flex items-center transition">
<i data-feather="download" class="mr-2"></i>
Exporter Excel
</button>
<button onclick="addNewDocument()" class="bg-fc-red hover:bg-red-700 text-white px-4 py-2 rounded-md flex items-center transition">
<i data-feather="plus" class="mr-2"></i>
Ajouter un document
</button>
</div>
</div>
<div class="bg-white rounded-lg shadow-md overflow-hidden" data-aos="fade-up">
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Nom</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Type</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Date</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Montants</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Remarque</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Justificatif</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
<!-- Dynamic Data Rows will be inserted here -->
</tbody>
</table>
</div>
<!-- Pagination -->
<div class="bg-gray-50 px-4 py-3 flex items-center justify-between border-t border-gray-200 sm:px-6">
<div class="flex-1 flex justify-between sm:hidden">
<a href="#" class="relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">Précédent</a>
<a href="#" class="ml-3 relative inline-flex items-center px-4 py-2 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50">Suivant</a>
</div>
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
<div>
<p class="text-sm text-gray-700">
Affichage de <span class="font-medium">1</span> à <span class="font-medium">3</span> sur <span class="font-medium">12</span> résultats
</p>
</div>
<div>
<nav class="relative z-0 inline-flex rounded-md shadow-sm -space-x-px" aria-label="Pagination">
<button onclick="prevPage()" class="relative inline-flex items-center px-2 py-2 rounded-l-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
<span class="sr-only">Précédent</span>
<i data-feather="chevron-left" class="h-5 w-5"></i>
</button>
<button onclick="goToPage(1)" aria-current="page" class="z-10 bg-fc-red border-fc-red text-white relative inline-flex items-center px-4 py-2 border text-sm font-medium">1</button>
<button onclick="goToPage(2)" class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium">2</button>
<button onclick="goToPage(3)" class="bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center px-4 py-2 border text-sm font-medium">3</button>
<button onclick="nextPage()" class="relative inline-flex items-center px-2 py-2 rounded-r-md border border-gray-300 bg-white text-sm font-medium text-gray-500 hover:bg-gray-50">
<span class="sr-only">Suivant</span>
<i data-feather="chevron-right" class="h-5 w-5"></i>
</button>
</nav>
</div>
</div>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-gray-800 text-white py-6">
<div class="container mx-auto px-4">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="mb-4 md:mb-0">
<img src="https://enzostvs-deepsite.hf.space/_next/image?url=https%3A%2F%2Fhuggingface.co%2Fspaces%2FELHASSOUNI%2Ffce-compta%2Fresolve%2Fmain%2Fimages%2Flogo__FCE%202.jpg&w=64&q=75" alt="Logo FC Ensisheim" class="h-10 w-10 rounded-full border border-white inline-block mr-2">
<span class="font-semibold">FC Ensisheim - Administration</span>
</div>
<div class="text-sm">
<p>&copy; 2025 FC Ensisheim. Tous droits réservés.</p>
</div>
</div>
</div>
</footer>
</div>
<script>
AOS.init();
feather.replace();
function shareApp() {
const shareUrl = window.location.href;
const shareData = {
title: 'FC Ensisheim - Administration',
text: 'Accédez au tableau de bord administratif',
url: shareUrl
};
if (navigator.share) {
navigator.share(shareData)
.catch(err => {
// Fallback to clipboard if share fails
navigator.clipboard.writeText(shareUrl)
.then(() => alert('Lien copié dans le presse-papiers !\n' + shareUrl))
.catch(() => {
// Final fallback if clipboard also fails
prompt('Copiez ce lien pour partager:', shareUrl);
});
});
} else {
// Web Share API not supported
navigator.clipboard.writeText(shareUrl)
.then(() => alert('Lien copié dans le presse-papiers !\n' + shareUrl))
.catch(() => {
prompt('Copiez ce lien pour partager:', shareUrl);
});
}
}
// Pagination functions
let currentPage = 1;
function goToPage(page) {
currentPage = page;
// In a real app, you would fetch data for this page
alert(`Affichage de la page ${page}`);
updatePaginationUI();
}
function prevPage() {
if (currentPage > 1) {
goToPage(currentPage - 1);
}
}
function nextPage() {
// In a real app, you would check if there are more pages
goToPage(currentPage + 1);
}
function updatePaginationUI() {
// Update active page styling
document.querySelectorAll('[aria-current="page"]').forEach(el => {
el.classList.remove('bg-fc-red', 'border-fc-red', 'text-white');
el.classList.add('bg-white', 'border-gray-300', 'text-gray-500');
el.removeAttribute('aria-current');
});
const activePageBtn = document.querySelector(`button[onclick="goToPage(${currentPage})"]`);
if (activePageBtn) {
activePageBtn.classList.remove('bg-white', 'border-gray-300', 'text-gray-500');
activePageBtn.classList.add('bg-fc-red', 'border-fc-red', 'text-white');
activePageBtn.setAttribute('aria-current', 'page');
}
}
function openFile(timestamp) {
const documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
const doc = documents.find(d => d.timestamp === timestamp);
if (doc && doc.file) {
alert(`Fichier: ${doc.file.name}\nType: ${doc.file.type}\nTaille: ${(doc.file.size / 1024).toFixed(2)} KB`);
// In a real implementation, you would prompt the user to upload the actual file
}
}
function viewDocument(timestamp) {
const documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
const doc = documents.find(d => d.timestamp === timestamp);
if (doc) {
const modalContent = `
<div class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50">
<div class="bg-white rounded-lg p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto">
<div class="flex justify-between items-center mb-4">
<h3 class="text-lg font-bold">Détails du document</h3>
<button onclick="closeModal()" class="text-gray-500 hover:text-gray-700">
<i data-feather="x"></i>
</button>
</div>
<div class="space-y-4">
<div>
<label class="font-medium">Nom:</label>
<p>${doc.name}</p>
</div>
<div>
<label class="font-medium">Type:</label>
<p>${doc.type === 'depense' ? 'Dépense' : 'Recette'}</p>
</div>
<div>
<label class="font-medium">Date:</label>
<p>${doc.date}</p>
</div>
<div>
<label class="font-medium">Montants:</label>
<p>CB: ${doc.cb_amount}€</p>
<p>Espèce: ${doc.cash_amount}€</p>
<p>Billets: ${doc.check_amount}€</p>
<p>Chèque: ${doc.cheque_amount}€</p>
</div>
<div>
<label class="font-medium">Remarque:</label>
<p>${doc.remarks || 'Aucune'}</p>
</div>
${doc.file ? `
<div>
<label class="font-medium">Pièce justificative:</label>
<p>${doc.file.name}</p>
<button onclick="openFile('${doc.timestamp}')" class="mt-2 bg-fc-red hover:bg-red-700 text-white px-3 py-1 rounded text-sm">
Ouvrir le fichier
</button>
</div>` : ''}
</div>
</div>
</div>
`;
document.body.insertAdjacentHTML('beforeend', modalContent);
feather.replace();
}
}
function editDocument(timestamp) {
const documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
const doc = documents.find(d => d.timestamp === timestamp);
if (doc) {
// Pré-remplir le formulaire avec les données existantes
document.getElementById('name').value = doc.name;
document.querySelector(`input[name="type"][value="${doc.type}"]`).checked = true;
document.getElementById('date').value = doc.date;
document.getElementById('cb_amount').value = doc.cb_amount;
document.getElementById('cash_amount').value = doc.cash_amount;
document.getElementById('check_amount').value = doc.check_amount;
document.getElementById('cheque_amount').value = doc.cheque_amount;
document.getElementById('remarks').value = doc.remarks;
// Supprimer l'ancien document
deleteDocument(timestamp, false);
// Faire défiler vers le formulaire
document.getElementById('accountingForm').scrollIntoView({ behavior: 'smooth' });
}
}
function deleteDocument(timestamp, showAlert = true) {
if (!showAlert || confirm("Êtes-vous sûr de vouloir supprimer ce document ?")) {
let documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
documents = documents.filter(d => d.timestamp !== timestamp);
localStorage.setItem('accountingDocuments', JSON.stringify(documents));
loadDocuments();
if (showAlert) {
alert("Document supprimé avec succès !");
}
}
}
function closeModal() {
const modal = document.querySelector('.fixed.inset-0');
if (modal) modal.remove();
}
function addNewDocument() {
alert("Ouverture du formulaire pour ajouter un nouveau document");
// Ici vous pourriez ouvrir un modal ou rediriger vers un formulaire
}
// Load and display documents from localStorage
function loadDocuments() {
const documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
const tbody = document.querySelector('tbody');
// Clear existing rows except header
tbody.innerHTML = '';
documents.forEach(doc => {
const row = document.createElement('tr');
row.innerHTML = `
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">${doc.name}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${doc.type === 'depense' ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800'}">
${doc.type === 'depense' ? 'Dépense' : 'Recette'}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">${doc.date}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<div>CB: ${doc.cb_amount}€</div>
<div>Espèce: ${doc.cash_amount}€</div>
<div>Billets: ${doc.check_amount}€</div>
<div>Chèque: ${doc.cheque_amount}€</div>
</td>
<td class="px-6 py-4 text-sm text-gray-500">${doc.remarks}</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
${doc.file ? `<a href="javascript:void(0)" onclick="openFile('${doc.timestamp}')" class="text-fc-red hover:text-red-700">Voir</a>` : 'Aucun'}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
<button onclick="viewDocument('${doc.timestamp}')" class="text-green-600 hover:text-green-900 mr-3" title="Voir"><i data-feather="eye"></i></button>
<button onclick="editDocument('${doc.timestamp}')" class="text-blue-600 hover:text-blue-900 mr-3" title="Modifier"><i data-feather="edit"></i></button>
<button onclick="deleteDocument('${doc.timestamp}')" class="text-red-600 hover:text-red-900" title="Supprimer"><i data-feather="trash-2"></i></button>
</td>
`;
tbody.appendChild(row);
});
feather.replace();
}
// Export to Excel functionality
document.getElementById('exportExcel').addEventListener('click', function() {
const documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
// Prepare data for Excel
const data = [
["Nom", "Type", "Date", "CB (€)", "Espèce (€)", "Billets (€)", "Chèque (€)", "Remarque", "Pièce Jointe"]
];
documents.forEach(doc => {
data.push([
doc.name,
doc.type === 'depense' ? 'Dépense' : 'Recette',
doc.date,
doc.cb_amount,
doc.cash_amount,
doc.check_amount,
doc.cheque_amount,
doc.remarks,
doc.file ? doc.file.name : 'Aucune'
]);
});
// Create Excel file
const wb = XLSX.utils.book_new();
const ws = XLSX.utils.aoa_to_sheet(data);
XLSX.utils.book_append_sheet(wb, ws, "Documents Comptables");
XLSX.writeFile(wb, "documents_comptables.xlsx");
});
// Edit document function
function editDocument(timestamp) {
const documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
const doc = documents.find(d => d.timestamp === timestamp);
if (doc) {
alert(`Modification du document de ${doc.name} (${doc.date})`);
// In a real app, you would open a modal or redirect to edit form
}
}
// Delete document function
function deleteDocument(timestamp) {
if (confirm("Êtes-vous sûr de vouloir supprimer ce document ?")) {
let documents = JSON.parse(localStorage.getItem('accountingDocuments')) || [];
documents = documents.filter(d => d.timestamp !== timestamp);
localStorage.setItem('accountingDocuments', JSON.stringify(documents));
loadDocuments();
alert("Document supprimé avec succès !");
}
}
// Load documents when page loads
document.addEventListener('DOMContentLoaded', loadDocuments);
</script>
</body>
</html>