Spaces:
Running

File size: 22,321 Bytes
b52a4c0
 
 
 
 
 
 
 
 
 
 
 
 
28c9b71
b52a4c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2c6a2c7
b52a4c0
 
 
 
2c6a2c7
 
54d2e9e
b52a4c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9cc6b3c
b52a4c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4900203
b52a4c0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9cc6b3c
b52a4c0
 
9cc6b3c
 
 
 
 
b52a4c0
 
9cc6b3c
b52a4c0
 
 
 
 
 
 
 
 
 
 
 
2c6a2c7
b52a4c0
 
 
dd6f930
b52a4c0
 
 
 
 
 
 
 
 
54d2e9e
 
dd6f930
54d2e9e
 
 
2c6a2c7
54d2e9e
 
 
 
c644216
 
 
 
 
 
 
 
 
54d2e9e
c644216
54d2e9e
2c6a2c7
c644216
 
 
54d2e9e
 
b52a4c0
97a492f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28c9b71
 
 
 
26352da
 
28c9b71
 
 
a7efb3b
234af0b
a7efb3b
234af0b
a7efb3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28c9b71
 
 
 
a7efb3b
 
 
 
 
 
 
234af0b
 
 
a7efb3b
234af0b
a7efb3b
234af0b
a7efb3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234af0b
9cc6b3c
 
a7efb3b
 
234af0b
a7efb3b
234af0b
 
a7efb3b
 
 
9cc6b3c
 
 
a7efb3b
 
 
 
 
9cc6b3c
 
 
 
 
4900203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28c9b71
4900203
 
a7efb3b
 
 
4900203
 
 
 
 
 
 
 
26352da
 
4900203
b52a4c0
4900203
b52a4c0
26352da
b52a4c0
 
4900203
 
 
 
 
 
 
 
 
26352da
 
4900203
 
 
28c9b71
4900203
b52a4c0
 
26352da
b52a4c0
4900203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b52a4c0
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
<!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>