ANOUSBENKO's picture
Reste = Versement - Total Général - Follow Up Deployment
bc655ac verified
Raw History Blame Contribute Delete
27.2 kB
<!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>