File size: 27,196 Bytes
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80d1f93
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e618091
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc655ac
 
 
 
 
 
 
 
 
 
 
 
 
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80d1f93
665073c
 
 
 
 
 
e618091
665073c
 
 
 
e618091
665073c
 
 
 
e618091
665073c
 
 
 
 
 
 
 
 
 
80d1f93
665073c
 
80d1f93
 
 
665073c
 
 
 
 
 
 
 
80d1f93
665073c
bc655ac
 
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc655ac
665073c
 
 
 
 
 
bc655ac
 
 
 
 
 
 
 
665073c
 
 
 
 
 
 
 
bc655ac
 
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc655ac
 
 
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc655ac
 
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
80d1f93
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80d1f93
665073c
 
 
 
 
 
 
 
 
 
 
80d1f93
665073c
bc655ac
 
665073c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e618091
 
665073c
 
 
 
e618091
665073c
 
e618091
665073c
 
 
 
e618091
665073c
 
 
 
e618091
 
 
 
665073c
 
 
 
80d1f93
 
 
 
 
665073c
 
 
 
 
80d1f93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bc655ac
 
80d1f93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
665073c
 
 
80d1f93
665073c
 
 
 
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
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>MAZRAAT EL HIDHAB - Gestion Agricole</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .custom-shadow {
            box-shadow: 0 4px 6px -1px rgba(0, 100, 0, 0.1), 0 2px 4px -1px rgba(0, 100, 0, 0.06);
        }
        .total-box {
            background: linear-gradient(135deg, #fef9c3 0%, #fef08a 100%);
        }
        .btn-primary {
            background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
        }
        .btn-secondary {
            background: linear-gradient(135deg, #eab308 0%, #facc15 100%);
        }
        .btn-danger {
            background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
        }
        .btn-info {
            background: linear-gradient(135deg, #0ea5e9 0%, #38bdf8 100%);
        }
        .btn-success {
            background: linear-gradient(135deg, #059669 0%, #10b981 100%);
        }
    </style>
</head>
<body class="bg-gray-50 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="mb-8">
            <div class="flex items-center justify-between mb-6">
                <div class="flex items-center">
                    <img src="https://scontent.forn2-2.fna.fbcdn.net/v/t39.30808-6/504380147_3935532786710927_2542747152483551594_n.jpg?_nc_cat=104&ccb=1-7&_nc_sid=833d8c&_nc_eui2=AeEzZZwNbAkYyEQWbnT_yyQZ6diWv2mmTCHp2Ja_aaZMIc88j-4zXRElG7rmL-9VkusZnKX8_8Qt1b-eMyBko_cn&_nc_ohc=QcSpFX1XXHEQ7kNvwEbKygz&_nc_oc=Adm32ekJ3k85OlWON1gaUsocJSNyGwxboPraVqfiyGoVP_KRVCcUh88Pg9PCWSf55U4&_nc_zt=23&_nc_ht=scontent.forn2-2.fna&_nc_gid=MGVaqZuxtfMBy2i6sRlpHQ&oh=00_AfPVsuqzQcoA51e-puR69uD_Av7nMarE1gBUpgIwAIvOdA&oe=686848D3" alt="Logo" class="h-16 mr-4">
                    <div>
                        <h1 class="text-4xl font-bold text-green-800">MAZRAAT EL HIDHAB</h1>
                        <p class="text-yellow-600 font-medium">Système de Gestion Agricole</p>
                    </div>
                </div>
            </div>
        </header>

        <!-- Main Content -->
        <div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
            <!-- Form Section -->
            <div class="lg:col-span-2 bg-white rounded-lg custom-shadow p-6">
                <h2 class="text-2xl font-semibold text-green-700 mb-6 border-b pb-2">Formulaire d'Enregistrement</h2>
                
                <form id="agricultureForm" class="space-y-4">
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label for="date" class="block text-sm font-medium text-gray-700 mb-1">Date</label>
                            <input type="date" id="date" name="date" required 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500">
                        </div>
                        <div>
                            <label for="matricule" class="block text-sm font-medium text-gray-700 mb-1">Matricule</label>
                            <input type="text" id="matricule" name="matricule" required 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500">
                        </div>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label for="matiere" class="block text-sm font-medium text-gray-700 mb-1">Matière</label>
                            <select id="matiere" name="matiere" required 
                                    class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500">
                                <option value="">Sélectionner</option>
                                <option value="MAIS">MAIS</option>
                                <option value="SOJA">SOJA</option>
                            </select>
                        </div>
                        <div>
                            <label for="quantite" class="block text-sm font-medium text-gray-700 mb-1">Quantité (Quintal)</label>
                            <input type="number" id="quantite" name="quantite" step="0.01" required 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500">
                        </div>
                    </div>

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
                        <div>
                            <label for="prix_unitaire" class="block text-sm font-medium text-gray-700 mb-1">Prix Unitaire (DA)</label>
                            <input type="number" id="prix_unitaire" name="prix_unitaire" step="0.01" required 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500">
                        </div>
                        <div>
                            <label for="montant" class="block text-sm font-medium text-gray-700 mb-1">Montant (DA)</label>
                            <input type="number" id="montant" name="montant" readonly 
                                   class="w-full px-3 py-2 border border-gray-300 bg-gray-100 rounded-md">
                        </div>
                    </div>

                    <input type="hidden" id="recordId">

                    <div class="grid grid-cols-1 md:grid-cols-2 gap-4 pt-4">
                        <div>
                            <label for="versement" class="block text-sm font-medium text-gray-700 mb-1">Versement en DA</label>
                            <input type="number" id="versement" name="versement" step="0.01" 
                                   class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-green-500">
                        </div>
                        <div>
                            <label for="reste" class="block text-sm font-medium text-gray-700 mb-1">Reste</label>
                            <input type="number" id="reste" name="reste" readonly 
                                   class="w-full px-3 py-2 border border-gray-300 bg-gray-100 rounded-md">
                        </div>
                    </div>

                    <div class="flex flex-wrap gap-3 pt-4">
                        <button type="button" id="btnNouveau" class="btn-primary text-white px-4 py-2 rounded-md font-medium">
                            <i class="fas fa-plus mr-2"></i>Nouveau
                        </button>
                        <button type="submit" id="btnEnregistrer" class="btn-success text-white px-4 py-2 rounded-md font-medium">
                            <i class="fas fa-save mr-2"></i>Enregistrer
                        </button>
                        <button type="button" id="btnModifier" class="btn-secondary text-white px-4 py-2 rounded-md font-medium hidden">
                            <i class="fas fa-edit mr-2"></i>Modifier
                        </button>
                        <button type="button" id="btnSupprimer" class="btn-danger text-white px-4 py-2 rounded-md font-medium hidden">
                            <i class="fas fa-trash mr-2"></i>Supprimer
                        </button>
                    </div>
                </form>


                <!-- Totals Section -->
                <div class="mt-8 total-box p-4 rounded-lg">
                    <h3 class="text-lg font-semibold text-gray-800 mb-3">Totaux</h3>
                    <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
                        <div class="bg-white p-3 rounded shadow">
                            <p class="text-sm text-gray-600">Total MAIS</p>
                            <p class="text-sm text-gray-500">Quantité: <span id="qtyMais">0</span> Quintal</p>
                            <p class="text-xl font-bold text-green-700" id="totalMais">0 DA</p>
                        </div>
                        <div class="bg-white p-3 rounded shadow">
                            <p class="text-sm text-gray-600">Total SOJA</p>
                            <p class="text-sm text-gray-500">Quantité: <span id="qtySoja">0</span> Quintal</p>
                            <p class="text-xl font-bold text-yellow-600" id="totalSoja">0 DA</p>
                        </div>
                        <div class="bg-white p-3 rounded shadow">
                            <p class="text-sm text-gray-600">Total Général</p>
                            <p class="text-sm text-gray-500">Quantité: <span id="qtyTotal">0</span> Quintal</p>
                            <p class="text-xl font-bold text-green-800" id="totalGeneral">0 DA</p>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Records Section -->
            <div class="bg-white rounded-lg custom-shadow p-6">
                <div class="flex justify-between items-center mb-6">
                    <h2 class="text-2xl font-semibold text-green-700">Enregistrements</h2>
                    <button id="btnConsulter" class="btn-info text-white px-3 py-1 rounded-md text-sm font-medium mr-2">
                        <i class="fas fa-sync-alt mr-1"></i>Actualiser
                    </button>
                    <button id="btnImprimer" class="btn-primary text-white px-3 py-1 rounded-md text-sm font-medium">
                        <i class="fas fa-print mr-1"></i>Imprimer
                    </button>
                </div>

                <div class="overflow-x-auto">
                    <table class="min-w-full divide-y divide-gray-200">
                        <thead class="bg-green-50">
                            <tr>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Date</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Matière</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Quantité</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Montant</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Versement</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Reste</th>
                                <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Actions</th>
                            </tr>
                        </thead>
                        <tbody id="recordsTable" class="bg-white divide-y divide-gray-200">
                            <!-- Records will be inserted here by JavaScript -->
                        </tbody>
                    </table>
                </div>

                <div class="mt-6 text-center text-sm text-gray-500">
                    <p>Total enregistrements: <span id="totalRecords" class="font-medium">0</span></p>
                </div>
            </div>
        </div>

        <!-- Footer -->
        <footer class="mt-12 text-center text-gray-600 text-sm">
            <p>Designed by <span class="font-semibold text-green-700">SAMIR BENKOLLI 2025</span></p>
        </footer>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            // Simulated database
            let database = JSON.parse(localStorage.getItem('mazraatDB')) || [];
            
            // Form elements
            const form = document.getElementById('agricultureForm');
            const dateInput = document.getElementById('date');
            const matriculeInput = document.getElementById('matricule');
            const matiereInput = document.getElementById('matiere');
            const quantiteInput = document.getElementById('quantite');
            const prixUnitaireInput = document.getElementById('prix_unitaire');
            const montantInput = document.getElementById('montant');
            const recordIdInput = document.getElementById('recordId');
            
            // Buttons
            const btnNouveau = document.getElementById('btnNouveau');
            const btnEnregistrer = document.getElementById('btnEnregistrer');
            const btnModifier = document.getElementById('btnModifier');
            const btnSupprimer = document.getElementById('btnSupprimer');
            const btnConsulter = document.getElementById('btnConsulter');
            
            // Totals
            const totalMais = document.getElementById('totalMais');
            const totalSoja = document.getElementById('totalSoja');
            const totalGeneral = document.getElementById('totalGeneral');
            const totalRecords = document.getElementById('totalRecords');
            
            // Table body
            const recordsTable = document.getElementById('recordsTable');
            
            // Set today's date as default
            const today = new Date().toISOString().split('T')[0];
            dateInput.value = today;
            
            // Calculate montant when quantity or price changes
            quantiteInput.addEventListener('input', calculateMontant);
            prixUnitaireInput.addEventListener('input', calculateMontant);
            document.getElementById('versement').addEventListener('input', calculateReste);
            
            function calculateMontant() {
                const quantite = parseFloat(quantiteInput.value) || 0;
                const prixUnitaire = parseFloat(prixUnitaireInput.value) || 0;
                const montant = quantite * prixUnitaire;
                montantInput.value = montant.toFixed(2);
                calculateReste();
            }

            function calculateReste() {
                const versement = parseFloat(document.getElementById('versement').value) || 0;
                const montant = parseFloat(montantInput.value) || 0;
                const reste = versement - montant;
                document.getElementById('reste').value = reste.toFixed(2);
            }
            
            // New record button
            btnNouveau.addEventListener('click', function() {
                form.reset();
                recordIdInput.value = '';
                dateInput.value = today;
                montantInput.value = '';
                document.getElementById('versement').value = '';
                document.getElementById('reste').value = '';
                btnModifier.classList.add('hidden');
                btnSupprimer.classList.add('hidden');
                btnEnregistrer.classList.remove('hidden');
            });
            
            // Save record
            form.addEventListener('submit', function(e) {
                e.preventDefault();
                
                const record = {
                    id: recordIdInput.value || Date.now().toString(),
                    date: dateInput.value,
                    matricule: matriculeInput.value,
                    matiere: matiereInput.value,
                    quantite: parseFloat(quantiteInput.value),
                    prix_unitaire: parseFloat(prixUnitaireInput.value),
                    montant: parseFloat(montantInput.value),
                    versement: parseFloat(document.getElementById('versement').value) || 0,
                    reste: parseFloat(document.getElementById('reste').value) || 0
                };
                
                if (recordIdInput.value) {
                    // Update existing record
                    const index = database.findIndex(item => item.id === recordIdInput.value);
                    if (index !== -1) {
                        database[index] = record;
                    }
                } else {
                    // Add new record
                    database.push(record);
                }
                
                // Save to localStorage
                localStorage.setItem('mazraatDB', JSON.stringify(database));
                
                // Refresh UI
                refreshRecords();
                calculateTotals();
                
                // Reset form
                btnNouveau.click();
                
                // Show success message
                alert('Enregistrement effectué avec succès!');
            });
            
            // Edit record
            function editRecord(id) {
                const record = database.find(item => item.id === id);
                if (record) {
                    recordIdInput.value = record.id;
                    dateInput.value = record.date;
                    matriculeInput.value = record.matricule;
                    matiereInput.value = record.matiere;
                    quantiteInput.value = record.quantite;
                    prixUnitaireInput.value = record.prix_unitaire;
                    montantInput.value = record.montant.toFixed(2);
                    document.getElementById('versement').value = record.versement?.toFixed(2) || '';
                    document.getElementById('reste').value = record.reste?.toFixed(2) || '';
                    
                    btnModifier.classList.remove('hidden');
                    btnSupprimer.classList.remove('hidden');
                    btnEnregistrer.classList.add('hidden');
                }
            }
            
            // Delete record
            btnSupprimer.addEventListener('click', function() {
                if (confirm('Voulez-vous vraiment supprimer cet enregistrement?')) {
                    database = database.filter(item => item.id !== recordIdInput.value);
                    localStorage.setItem('mazraatDB', JSON.stringify(database));
                    refreshRecords();
                    calculateTotals();
                    calculateDailyQuantities();
                    btnNouveau.click();
                }
            });
            
            // Refresh records
            btnConsulter.addEventListener('click', function() {
                refreshRecords();
                calculateTotals();
            });
            
            // Display records in table
            function refreshRecords() {
                recordsTable.innerHTML = '';
                
                if (database.length === 0) {
                    const row = document.createElement('tr');
                    row.innerHTML = `
                        <td colspan="5" class="px-4 py-4 text-center text-sm text-gray-500">
                            Aucun enregistrement trouvé
                        </td>
                    `;
                    recordsTable.appendChild(row);
                } else {
                    database.forEach(record => {
                        const row = document.createElement('tr');
                        row.className = 'hover:bg-green-50';
                        row.innerHTML = `
                            <td class="px-4 py-2 text-sm text-gray-700">${formatDate(record.date)}</td>
                            <td class="px-4 py-2 text-sm font-medium ${record.matiere === 'MAIS' ? 'text-green-600' : 'text-yellow-600'}">${record.matiere}</td>
                            <td class="px-4 py-2 text-sm text-gray-700">${record.quantite.toFixed(2)} Q</td>
                            <td class="px-4 py-2 text-sm text-gray-700">${record.montant.toFixed(2)} DA</td>
                            <td class="px-4 py-2 text-sm text-gray-700">${record.versement?.toFixed(2) || '0.00'} DA</td>
                            <td class="px-4 py-2 text-sm text-gray-700">${record.reste?.toFixed(2) || '0.00'} DA</td>
                            <td class="px-4 py-2 text-sm">
                                <button onclick="editRecord('${record.id}')" class="text-green-600 hover:text-green-800 mr-2">
                                    <i class="fas fa-edit"></i>
                                </button>
                            </td>
                        `;
                        recordsTable.appendChild(row);
                    });
                }
                
                totalRecords.textContent = database.length;
            }
            
            // Calculate totals
            function calculateTotals() {
                let totalMaisValue = 0;
                let totalSojaValue = 0;
                let qtyMais = 0;
                let qtySoja = 0;
                
                database.forEach(record => {
                    if (record.matiere === 'MAIS') {
                        totalMaisValue += record.montant;
                        qtyMais += record.quantite;
                    } else if (record.matiere === 'SOJA') {
                        totalSojaValue += record.montant;
                        qtySoja += record.quantite;
                    }
                });
                
                const totalGeneralValue = totalMaisValue + totalSojaValue;
                const qtyTotal = qtyMais + qtySoja;
                
                totalMais.textContent = totalMaisValue.toFixed(2) + ' DA';
                totalSoja.textContent = totalSojaValue.toFixed(2) + ' DA';
                totalGeneral.textContent = totalGeneralValue.toFixed(2) + ' DA';
                
                document.getElementById('qtyMais').textContent = qtyMais.toFixed(2);
                document.getElementById('qtySoja').textContent = qtySoja.toFixed(2);
                document.getElementById('qtyTotal').textContent = qtyTotal.toFixed(2);
            }
            
            // Format date for display
            function formatDate(dateString) {
                const date = new Date(dateString);
                const day = date.getDate().toString().padStart(2, '0');
                const month = (date.getMonth() + 1).toString().padStart(2, '0');
                const year = date.getFullYear();
                return `${day}/${month}/${year}`;
            }
            
            // Make editRecord function available globally for inline onclick
            window.editRecord = editRecord;
            
            // Print button functionality
            document.getElementById('btnImprimer').addEventListener('click', function() {
                const recordsContent = document.getElementById('recordsTable').outerHTML;
                const totalsContent = document.querySelector('.total-box').outerHTML;
                const originalContents = document.body.innerHTML;
                
                const printDate = new Date().toLocaleDateString('fr-FR');
                document.body.innerHTML = `
                    <div class="p-8">
                        <div class="flex items-center justify-between mb-6">
                            <div class="flex items-center">
                                <img src="https://scontent.forn2-2.fna.fbcdn.net/v/t39.30808-6/504380147_3935532786710927_2542747152483551594_n.jpg?_nc_cat=104&ccb=1-7&_nc_sid=833d8c&_nc_eui2=AeEzZZwNbAkYyEQWbnT_yyQZ6diWv2mmTCHp2Ja_aaZMIc88j-4zXRElG7rmL-9VkusZnKX8_8Qt1b-eMyBko_cn&_nc_ohc=QcSpFX1XXHEQ7kNvwEbKygz&_nc_oc=Adm32ekJ3k85OlWON1gaUsocJSNyGwxboPraVqfiyGoVP_KRVCcUh88Pg9PCWSf55U4&_nc_zt=23&_nc_ht=scontent.forn2-2.fna&_nc_gid=MGVaqZuxtfMBy2i6sRlpHQ&oh=00_AfPVsuqzQcoA51e-puR69uD_Av7nMarE1gBUpgIwAIvOdA&oe=686848D3" alt="Logo" class="h-16 mr-4">
                                <div>
                                    <h1 class="text-2xl font-bold text-green-800">MAZRAAT EL HIDHAB</h1>
                                    <p class="text-yellow-600 font-medium">Rapport d'activité</p>
                                </div>
                            </div>
                            <div class="text-sm text-gray-600">
                                Imprimé le: ${printDate}
                            </div>
                        </div>
                        <div class="bg-white rounded-lg shadow p-6 mb-6">
                            <h2 class="text-xl font-semibold text-green-700 mb-4">Enregistrements</h2>
                            <table class="min-w-full divide-y divide-gray-200">
                                <thead class="bg-green-50">
                                    <tr>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Date</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Matière</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Quantité</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Montant</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Versement</th>
                                        <th class="px-4 py-2 text-left text-xs font-medium text-green-800 uppercase tracking-wider">Reste</th>
                                    </tr>
                                </thead>
                                ${recordsContent}
                            </table>
                        </div>
                        ${totalsContent}
                    </div>
                    <div style="text-align: right; font-size: 9px; margin-top: 20px;">
                        Designed by SAMIR BENKOLLI
                    </div>
                `;
                
                window.print();
                document.body.innerHTML = originalContents;
                refreshRecords();
            });
            
            // Initial load
            refreshRecords();
            calculateTotals();
            calculateDailyQuantities();
        });
    </script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=ANOUSBENKO/https-huggingface-com-space-samir-mazraat" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>