File size: 23,934 Bytes
59a7a7b | 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 477 478 479 480 481 482 | <!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestion d'Électricité Locale</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">
<script>
tailwind.config = {
theme: {
extend: {
colors: {
primary: '#1e40af',
secondary: '#f97316',
light: '#f8fafc',
dark: '#0f172a'
}
}
}
}
</script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
body {
font-family: 'Poppins', sans-serif;
background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
}
.card {
box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
transition: all 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}
.btn-primary {
background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
transition: all 0.3s ease;
}
.btn-primary:hover {
background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
transform: translateY(-2px);
}
.btn-secondary {
background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
transition: all 0.3s ease;
}
.btn-secondary:hover {
background: linear-gradient(135deg, #ea580c 0%, #dc2626 100%);
transform: translateY(-2px);
}
.btn-whatsapp {
background: #25D366;
transition: all 0.3s ease;
}
.btn-whatsapp:hover {
background: #128C7E;
transform: translateY(-2px);
}
.invoice-header {
background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
}
.history-item {
border-left: 4px solid #3b82f6;
}
.history-item:nth-child(2n) {
border-left: 4px solid #f97316;
}
.input-field:focus {
border-color: #3b82f6;
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}
.fade-in {
animation: fadeIn 0.5s ease-in;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
</head>
<body class="min-h-screen text-gray-800">
<!-- Header -->
<header class="bg-primary text-white shadow-lg">
<div class="container mx-auto px-4 py-6">
<div class="flex flex-col md:flex-row justify-between items-center">
<div class="flex items-center mb-4 md:mb-0">
<i class="fas fa-bolt text-yellow-300 text-2xl mr-3"></i>
<h1 class="text-2xl md:text-3xl font-bold">ÉlectriCITÉ</h1>
</div>
<div class="text-center md:text-right">
<p class="text-sm md:text-base">Gestion locale de la distribution électrique</p>
<p class="text-xs mt-1">Système de facturation simplifié</p>
</div>
</div>
</div>
</header>
<main class="container mx-auto px-4 py-8">
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Formulaire -->
<div class="card bg-white rounded-xl p-6">
<h2 class="text-2xl font-bold text-primary mb-6 flex items-center">
<i class="fas fa-file-invoice mr-3"></i>
Formulaire de consommation
</h2>
<form id="consumptionForm" class="space-y-5">
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="nom" class="block text-sm font-medium text-gray-700 mb-1">Nom</label>
<input type="text" id="nom" class="input-field w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none" required>
</div>
<div>
<label for="prenom" class="block text-sm font-medium text-gray-700 mb-1">Prénom</label>
<input type="text" id="prenom" class="input-field w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none" required>
</div>
</div>
<div>
<label for="whatsapp" class="block text-sm font-medium text-gray-700 mb-1">Numéro WhatsApp</label>
<input type="tel" id="whatsapp" class="input-field w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none" placeholder="221 77 123 45 67" required>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="ancienKw" class="block text-sm font-medium text-gray-700 mb-1">Ancien indice (kW)</label>
<input type="text" id="ancienKw" class="input-field w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none" pattern="[0-9]+([\.,][0-9]+)?" placeholder="0.00" required>
</div>
<div>
<label for="nouveauKw" class="block text-sm font-medium text-gray-700 mb-1">Nouvel indice (kW)</label>
<input type="text" id="nouveauKw" class="input-field w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none" pattern="[0-9]+([\.,][0-9]+)?" placeholder="0.00" required>
</div>
</div>
<div class="bg-blue-50 rounded-lg p-4 border border-blue-100">
<div class="flex items-center">
<i class="fas fa-info-circle text-blue-500 mr-2"></i>
<p class="text-sm text-blue-700">Tarif : 300 F CFA par kW consommé</p>
</div>
</div>
<div class="flex flex-col sm:flex-row gap-3 pt-4">
<button type="submit" class="btn-primary text-white font-medium py-3 px-6 rounded-lg flex-1 flex items-center justify-center">
<i class="fas fa-calculator mr-2"></i>
Calculer la facture
</button>
<button type="button" id="historyBtn" class="btn-secondary text-white font-medium py-3 px-6 rounded-lg flex items-center justify-center">
<i class="fas fa-history mr-2"></i>
Historique
</button>
</div>
</form>
</div>
<!-- Facture -->
<div class="card bg-white rounded-xl p-6">
<h2 class="text-2xl font-bold text-primary mb-6 flex items-center">
<i class="fas fa-receipt mr-3"></i>
Facture de consommation
</h2>
<div id="invoiceContainer" class="fade-in">
<div class="invoice-header text-white rounded-t-lg p-4 mb-4">
<div class="flex justify-between items-center mb-3">
<div>
<h3 class="text-xl font-bold">Facture ÉlectriCITÉ</h3>
<p class="text-sm opacity-90">Date: <span id="invoiceDate">-</span></p>
</div>
<div class="text-right">
<p class="text-lg font-bold">N°: <span id="invoiceNumber">-</span></p>
</div>
</div>
</div>
<div class="mb-6">
<h4 class="text-lg font-semibold text-gray-700 mb-3">Détails du client</h4>
<div class="grid grid-cols-2 gap-2 text-sm">
<p class="font-medium">Nom:</p>
<p id="invoiceNom">-</p>
<p class="font-medium">Prénom:</p>
<p id="invoicePrenom">-</p>
<p class="font-medium">Téléphone:</p>
<p id="invoicePhone">-</p>
</div>
</div>
<div class="mb-6">
<h4 class="text-lg font-semibold text-gray-700 mb-3">Détails de consommation</h4>
<div class="space-y-3">
<div class="flex justify-between border-b border-gray-200 pb-2">
<span>Ancien index (kW):</span>
<span id="oldIndex" class="font-medium">-</span>
</div>
<div class="flex justify-between border-b border-gray-200 pb-2">
<span>Nouvel index (kW):</span>
<span id="newIndex" class="font-medium">-</span>
</div>
<div class="flex justify-between border-b border-gray-200 pb-2">
<span>Consommation (kW):</span>
<span id="consumption" class="font-medium">-</span>
</div>
<div class="flex justify-between pt-3 text-lg font-bold">
<span>Montant à payer:</span>
<span id="amountDue" class="text-secondary">-</span>
</div>
</div>
</div>
<div class="bg-gray-50 p-4 rounded-lg text-center">
<p class="text-sm text-gray-600">Merci pour votre règlement dans les 30 jours</p>
</div>
<div class="mt-6 flex flex-col sm:flex-row gap-3">
<button id="sendBtn" class="btn-whatsapp text-white font-medium py-3 px-6 rounded-lg flex items-center justify-center">
<i class="fab fa-whatsapp mr-2"></i>
Envoyer par WhatsApp
</button>
<button id="newBillBtn" class="btn-primary text-white font-medium py-3 px-6 rounded-lg flex items-center justify-center">
<i class="fas fa-plus mr-2"></i>
Nouvelle facture
</button>
</div>
</div>
</div>
</div>
<!-- Historique -->
<div id="historySection" class="card bg-white rounded-xl p-6 mt-8 hidden">
<h2 class="text-2xl font-bold text-primary mb-6 flex items-center">
<i class="fas fa-history mr-3"></i>
Historique des factures
</h2>
<div id="historyList" class="space-y-4 max-h-96 overflow-y-auto pr-2">
<!-- Les éléments d'historique seront insérés ici -->
</div>
<div class="mt-6 text-center">
<button id="closeHistoryBtn" class="btn-secondary text-white font-medium py-2 px-6 rounded-lg">
Fermer l'historique
</button>
</div>
</div>
</main>
<footer class="bg-primary text-white py-6 mt-12">
<div class="container mx-auto px-4 text-center">
<p>© 2023 ÉlectriCITÉ - Gestion locale d'électricité</p>
<p class="text-sm mt-2 opacity-80">Application de facturation simple et efficace</p>
</div>
</footer>
<script>
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('consumptionForm');
const historyBtn = document.getElementById('historyBtn');
const historySection = document.getElementById('historySection');
const historyList = document.getElementById('historyList');
const closeHistoryBtn = document.getElementById('closeHistoryBtn');
const sendBtn = document.getElementById('sendBtn');
const newBillBtn = document.getElementById('newBillBtn');
const invoiceContainer = document.getElementById('invoiceContainer');
// Variables pour stocker les données
let currentBill = {};
let history = JSON.parse(localStorage.getItem('electricityBills')) || [];
// Initialiser l'affichage de l'historique
updateHistoryDisplay();
// Soumission du formulaire
form.addEventListener('submit', function(e) {
e.preventDefault();
// Récupérer les valeurs
const nom = document.getElementById('nom').value;
const prenom = document.getElementById('prenom').value;
const whatsapp = document.getElementById('whatsapp').value;
let ancienKw = document.getElementById('ancienKw').value.replace(',', '.');
let nouveauKw = document.getElementById('nouveauKw').value.replace(',', '.');
// Vérifier si les valeurs sont des nombres valides
if (isNaN(ancienKw) || isNaN(nouveauKw)) {
alert('Veuillez entrer des valeurs numériques valides pour les index');
return;
}
ancienKw = parseFloat(ancienKw);
nouveauKw = parseFloat(nouveauKw);
// Validation
if (nouveauKw <= ancienKw) {
alert('Le nouvel index doit être supérieur à l\'ancien index');
return;
}
// Calculs
const consommation = nouveauKw - ancienKw;
const montant = consommation * 300;
// Formatage de la date
const now = new Date();
const dateStr = now.toLocaleDateString('fr-FR');
// Générer un numéro de facture
const invoiceNumber = 'FACT-' + (1000 + history.length + 1);
// Sauvegarder la facture actuelle
currentBill = {
id: Date.now(),
invoiceNumber: invoiceNumber,
nom: nom,
prenom: prenom,
whatsapp: whatsapp,
ancienKw: ancienKw,
nouveauKw: nouveauKw,
consommation: consommation,
montant: montant,
date: dateStr
};
// Mettre à jour l'affichage de la facture
document.getElementById('invoiceDate').textContent = dateStr;
document.getElementById('invoiceNumber').textContent = invoiceNumber;
document.getElementById('invoiceNom').textContent = nom;
document.getElementById('invoicePrenom').textContent = prenom;
document.getElementById('invoicePhone').textContent = whatsapp;
document.getElementById('oldIndex').textContent = ancienKw.toFixed(2);
document.getElementById('newIndex').textContent = nouveauKw.toFixed(2);
document.getElementById('consumption').textContent = consommation.toFixed(2);
document.getElementById('amountDue').textContent = montant.toLocaleString('fr-FR') + ' F CFA';
// Ajouter à l'historique et sauvegarder dans localStorage
history.push(currentBill);
localStorage.setItem('electricityBills', JSON.stringify(history));
updateHistoryDisplay();
// Afficher la facture
invoiceContainer.classList.remove('hidden');
});
// Afficher l'historique
historyBtn.addEventListener('click', function() {
historySection.classList.remove('hidden');
historySection.scrollIntoView({ behavior: 'smooth' });
});
// Fermer l'historique
closeHistoryBtn.addEventListener('click', function() {
historySection.classList.add('hidden');
});
// Envoyer par WhatsApp
sendBtn.addEventListener('click', function() {
if (!currentBill.nom) {
alert('Veuillez calculer une facture d\'abord');
return;
}
const message = `Bonjour, voici votre facture ÉlectriCITÉ :
*Facture:* ${currentBill.invoiceNumber}
*Date:* ${currentBill.date}
*Nom:* ${currentBill.nom} ${currentBill.prenom}
*Ancien index:* ${currentBill.ancienKw.toFixed(2)} kW
*Nouvel index:* ${currentBill.nouveauKw.toFixed(2)} kW
*Consommation:* ${currentBill.consommation.toFixed(2)} kW
*Montant à payer:* ${currentBill.montant.toLocaleString('fr-FR')} F CFA
Merci pour votre règlement.`;
const whatsappUrl = `https://wa.me/${currentBill.whatsapp.replace(/\s/g, '')}?text=${encodeURIComponent(message)}`;
window.open(whatsappUrl, '_blank');
});
// Nouvelle facture
newBillBtn.addEventListener('click', function() {
form.reset();
document.getElementById('invoiceDate').textContent = '-';
document.getElementById('invoiceNumber').textContent = '-';
document.getElementById('invoiceNom').textContent = '-';
document.getElementById('invoicePrenom').textContent = '-';
document.getElementById('invoicePhone').textContent = '-';
document.getElementById('oldIndex').textContent = '-';
document.getElementById('newIndex').textContent = '-';
document.getElementById('consumption').textContent = '-';
document.getElementById('amountDue').textContent = '-';
});
// Mettre à jour l'affichage de l'historique
function updateHistoryDisplay() {
if (history.length === 0) {
historyList.innerHTML = `
<div class="text-center py-8">
<i class="fas fa-inbox text-4xl text-gray-300 mb-4"></i>
<p class="text-gray-500">Aucune facture dans l'historique</p>
</div>
`;
return;
}
// Trier par date (plus récent en premier)
const sortedHistory = [...history].sort((a, b) => b.id - a.id);
let html = '';
sortedHistory.forEach((bill, index) => {
html += `
<div class="history-item bg-gray-50 rounded-lg p-4 border border-gray-200">
<div class="flex justify-between items-start">
<div>
<h3 class="font-bold text-lg">${bill.nom} ${bill.prenom}</h3>
<p class="text-sm text-gray-600">Facture: ${bill.invoiceNumber} - ${bill.date}</p>
</div>
<span class="bg-secondary text-white text-xs font-bold px-2 py-1 rounded">
${bill.consommation.toFixed(2)} kW
</span>
</div>
<div class="mt-3 flex justify-between items-center">
<div>
<p class="text-sm">Ancien: ${bill.ancienKw.toFixed(2)} kW</p>
<p class="text-sm">Nouveau: ${bill.nouveauKw.toFixed(2)} kW</p>
</div>
<div class="text-right">
<p class="font-bold text-lg">${bill.montant.toLocaleString('fr-FR')} F CFA</p>
<p class="text-xs text-gray-500">Tél: ${bill.whatsapp}</p>
</div>
</div>
<div class="mt-3 flex justify-end">
<button class="copy-btn text-primary text-sm font-medium" data-id="${bill.id}">
<i class="fas fa-copy mr-1"></i> Copier
</button>
</div>
</div>
`;
});
historyList.innerHTML = html;
// Ajouter les événements pour les boutons de copie
document.querySelectorAll('.copy-btn').forEach(button => {
button.addEventListener('click', function() {
const id = parseInt(this.getAttribute('data-id'));
const bill = history.find(b => b.id === id);
if (bill) {
const text = `Facture ${bill.invoiceNumber} - ${bill.nom} ${bill.prenom} - ${bill.consommation.toFixed(2)} kW - ${bill.montant.toLocaleString('fr-FR')} F CFA`;
navigator.clipboard.writeText(text)
.then(() => {
const originalText = this.innerHTML;
this.innerHTML = '<i class="fas fa-check mr-1"></i> Copié!';
setTimeout(() => {
this.innerHTML = originalText;
}, 2000);
})
.catch(err => {
console.error('Erreur lors de la copie: ', err);
});
}
});
});
}
});
</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=RebCode/gestle" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |