Spaces:
Running
Running
File size: 21,029 Bytes
9d7e09e |
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 |
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Offerte Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
body {
font-family: 'Roboto', sans-serif;
}
.a4-container {
width: 210mm;
min-height: 297mm;
margin: 0 auto;
background: white;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
position: relative;
}
.a4-content {
padding: 20mm;
}
.logo-placeholder {
width: 150px;
height: 80px;
background-color: #f3f4f6;
display: flex;
align-items: center;
justify-content: center;
color: #9ca3af;
border: 1px dashed #d1d5db;
}
.article-row {
transition: all 0.2s ease;
}
.article-row:hover {
background-color: #f9fafb;
}
.remove-article {
opacity: 0;
transition: opacity 0.2s ease;
}
.article-row:hover .remove-article {
opacity: 1;
}
@media print {
body * {
visibility: hidden;
}
.a4-container, .a4-container * {
visibility: visible;
}
.a4-container {
position: absolute;
left: 0;
top: 0;
width: 100%;
box-shadow: none;
}
.no-print {
display: none !important;
}
}
</style>
</head>
<body class="bg-gray-100 p-4">
<div class="container mx-auto">
<h1 class="text-3xl font-bold text-center mb-8 text-gray-800">Offerte Generator</h1>
<div class="flex flex-col lg:flex-row gap-8">
<!-- Formulier -->
<div class="w-full lg:w-1/3 bg-white p-6 rounded-lg shadow-md no-print">
<h2 class="text-xl font-semibold mb-4 text-gray-700">Offertegegevens</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Bedrijfsnaam</label>
<input type="text" id="company-name" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Klantnaam</label>
<input type="text" id="customer-name" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Offertenummer</label>
<input type="text" id="quote-number" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" value="Q-2023-001">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Datum</label>
<input type="date" id="quote-date" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Vervaldatum</label>
<input type="date" id="expiry-date" class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500">
</div>
<div class="pt-4 border-t border-gray-200">
<h3 class="text-lg font-medium text-gray-700 mb-2">Artikelen</h3>
<div id="articles-container">
<!-- Artikelen worden hier toegevoegd -->
</div>
<button id="add-article" class="mt-2 w-full bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-md transition duration-200">
Artikel toevoegen
</button>
</div>
</div>
<div class="mt-6 flex gap-2">
<button id="generate-pdf" class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-md transition duration-200">
Download als Afbeelding
</button>
<button id="print-quote" class="flex-1 bg-gray-500 hover:bg-gray-600 text-white py-2 px-4 rounded-md transition duration-200 no-print">
Afdrukken
</button>
</div>
</div>
<!-- Offerte preview -->
<div class="w-full lg:w-2/3 flex justify-center">
<div id="quote-preview" class="a4-container">
<div class="a4-content">
<!-- Header -->
<div class="flex justify-between items-start mb-8">
<div class="logo-placeholder">
Logo hier
</div>
<div class="text-right">
<h1 id="preview-company-name" class="text-2xl font-bold text-gray-800">Bedrijfsnaam</h1>
<p class="text-gray-600">Offerte</p>
</div>
</div>
<!-- Klantgegevens -->
<div class="mb-8">
<div class="bg-gray-100 p-4 rounded-md">
<h2 class="font-medium text-gray-700 mb-2">Aan:</h2>
<p id="preview-customer-name" class="text-gray-800">Klantnaam</p>
</div>
</div>
<!-- Offerte details -->
<div class="flex justify-between mb-8">
<div>
<p class="text-gray-600"><span class="font-medium">Offertenummer:</span> <span id="preview-quote-number">Q-2023-001</span></p>
<p class="text-gray-600"><span class="font-medium">Datum:</span> <span id="preview-quote-date">01-01-2023</span></p>
<p class="text-gray-600"><span class="font-medium">Vervaldatum:</span> <span id="preview-expiry-date">15-01-2023</span></p>
</div>
</div>
<!-- Artikellijst -->
<div class="mb-8">
<table class="w-full border-collapse">
<thead>
<tr class="bg-gray-100">
<th class="text-left py-2 px-4 border border-gray-200 font-medium text-gray-700">Omschrijving</th>
<th class="text-right py-2 px-4 border border-gray-200 font-medium text-gray-700">Aantal</th>
<th class="text-right py-2 px-4 border border-gray-200 font-medium text-gray-700">Prijs</th>
<th class="text-right py-2 px-4 border border-gray-200 font-medium text-gray-700">Totaal</th>
</tr>
</thead>
<tbody id="preview-articles">
<!-- Artikelen worden hier toegevoegd -->
<tr>
<td colspan="4" class="py-4 text-center text-gray-500">Voeg artikelen toe</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3" class="text-right py-2 px-4 border border-gray-200 font-medium text-gray-700">Subtotaal</td>
<td id="subtotal" class="text-right py-2 px-4 border border-gray-200">€0.00</td>
</tr>
<tr>
<td colspan="3" class="text-right py-2 px-4 border border-gray-200 font-medium text-gray-700">BTW (21%)</td>
<td id="vat" class="text-right py-2 px-4 border border-gray-200">€0.00</td>
</tr>
<tr class="bg-gray-100">
<td colspan="3" class="text-right py-2 px-4 border border-gray-200 font-bold text-gray-700">Totaal</td>
<td id="total" class="text-right py-2 px-4 border border-gray-200 font-bold">€0.00</td>
</tr>
</tfoot>
</table>
</div>
<!-- Opmerkingen -->
<div class="mb-8">
<h2 class="font-medium text-gray-700 mb-2">Opmerkingen</h2>
<p class="text-gray-600">Deze offerte is geldig tot de vervaldatum. Betaling binnen 14 dagen na facturering.</p>
</div>
<!-- Handtekening -->
<div class="mt-16">
<div class="pt-8 border-t border-gray-200 w-1/3">
<p class="text-gray-600">Handtekening</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Stel vandaag in als standaarddatum
const today = new Date();
document.getElementById('quote-date').valueAsDate = today;
// Voeg 14 dagen toe voor vervaldatum
const expiryDate = new Date();
expiryDate.setDate(today.getDate() + 14);
document.getElementById('expiry-date').valueAsDate = expiryDate;
// Update preview bij input wijzigingen
document.getElementById('company-name').addEventListener('input', updatePreview);
document.getElementById('customer-name').addEventListener('input', updatePreview);
document.getElementById('quote-number').addEventListener('input', updatePreview);
document.getElementById('quote-date').addEventListener('input', updatePreview);
document.getElementById('expiry-date').addEventListener('input', updatePreview);
// Voeg een artikel toe
document.getElementById('add-article').addEventListener('click', addArticle);
// Genereer PDF
document.getElementById('generate-pdf').addEventListener('click', generateImage);
// Afdrukken
document.getElementById('print-quote').addEventListener('click', function() {
window.print();
});
// Initialiseer preview
updatePreview();
// Voeg een standaard artikel toe
addArticle();
function updatePreview() {
document.getElementById('preview-company-name').textContent = document.getElementById('company-name').value || 'Bedrijfsnaam';
document.getElementById('preview-customer-name').textContent = document.getElementById('customer-name').value || 'Klantnaam';
document.getElementById('preview-quote-number').textContent = document.getElementById('quote-number').value || 'Q-2023-001';
const quoteDate = document.getElementById('quote-date').valueAsDate;
if (quoteDate) {
document.getElementById('preview-quote-date').textContent = formatDate(quoteDate);
}
const expiryDate = document.getElementById('expiry-date').valueAsDate;
if (expiryDate) {
document.getElementById('preview-expiry-date').textContent = formatDate(expiryDate);
}
}
function formatDate(date) {
const day = String(date.getDate()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, '0');
const year = date.getFullYear();
return `${day}-${month}-${year}`;
}
function addArticle() {
const articleId = Date.now();
// Voeg artikel toe aan formulier
const articlesContainer = document.getElementById('articles-container');
const articleDiv = document.createElement('div');
articleDiv.className = 'article-row bg-gray-50 p-3 rounded-md mb-2 relative';
articleDiv.dataset.id = articleId;
articleDiv.innerHTML = `
<div class="grid grid-cols-12 gap-2">
<div class="col-span-6">
<input type="text" placeholder="Omschrijving" class="article-description w-full px-2 py-1 border border-gray-300 rounded-md text-sm">
</div>
<div class="col-span-2">
<input type="number" placeholder="Aantal" min="1" value="1" class="article-quantity w-full px-2 py-1 border border-gray-300 rounded-md text-sm">
</div>
<div class="col-span-2">
<input type="number" placeholder="Prijs" min="0" step="0.01" value="0.00" class="article-price w-full px-2 py-1 border border-gray-300 rounded-md text-sm">
</div>
<div class="col-span-2 flex items-center">
<span class="article-total text-sm font-medium">€0.00</span>
<button class="remove-article ml-2 text-red-500 hover:text-red-700 text-sm absolute right-2 top-1/2 transform -translate-y-1/2">
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
</svg>
</button>
</div>
</div>
`;
articlesContainer.appendChild(articleDiv);
// Voeg event listeners toe voor berekeningen
const descriptionInput = articleDiv.querySelector('.article-description');
const quantityInput = articleDiv.querySelector('.article-quantity');
const priceInput = articleDiv.querySelector('.article-price');
const totalSpan = articleDiv.querySelector('.article-total');
const removeBtn = articleDiv.querySelector('.remove-article');
descriptionInput.addEventListener('input', updateArticlesPreview);
quantityInput.addEventListener('input', updateArticleTotal);
priceInput.addEventListener('input', updateArticleTotal);
removeBtn.addEventListener('click', function() {
articleDiv.remove();
updateArticlesPreview();
});
// Initialiseer artikel total
updateArticleTotal();
function updateArticleTotal() {
const quantity = parseFloat(quantityInput.value) || 0;
const price = parseFloat(priceInput.value) || 0;
const total = quantity * price;
totalSpan.textContent = `€${total.toFixed(2)}`;
updateArticlesPreview();
}
}
function updateArticlesPreview() {
const articlesContainer = document.getElementById('preview-articles');
articlesContainer.innerHTML = '';
const articleRows = document.querySelectorAll('.article-row');
let subtotal = 0;
if (articleRows.length === 0) {
articlesContainer.innerHTML = `
<tr>
<td colspan="4" class="py-4 text-center text-gray-500">Voeg artikelen toe</td>
</tr>
`;
} else {
articleRows.forEach(row => {
const description = row.querySelector('.article-description').value || 'Artikel';
const quantity = parseFloat(row.querySelector('.article-quantity').value) || 0;
const price = parseFloat(row.querySelector('.article-price').value) || 0;
const total = quantity * price;
subtotal += total;
const tr = document.createElement('tr');
tr.className = 'border-b border-gray-200';
tr.innerHTML = `
<td class="py-2 px-4 border border-gray-200">${description}</td>
<td class="py-2 px-4 border border-gray-200 text-right">${quantity}</td>
<td class="py-2 px-4 border border-gray-200 text-right">€${price.toFixed(2)}</td>
<td class="py-2 px-4 border border-gray-200 text-right">€${total.toFixed(2)}</td>
`;
articlesContainer.appendChild(tr);
});
}
const vat = subtotal * 0.21;
const total = subtotal + vat;
document.getElementById('subtotal').textContent = `€${subtotal.toFixed(2)}`;
document.getElementById('vat').textContent = `€${vat.toFixed(2)}`;
document.getElementById('total').textContent = `€${total.toFixed(2)}`;
}
function generateImage() {
const quotePreview = document.getElementById('quote-preview');
html2canvas(quotePreview, {
scale: 2,
logging: false,
useCORS: true,
allowTaint: true
}).then(canvas => {
const link = document.createElement('a');
link.download = `offerte-${document.getElementById('quote-number').value || 'Q-2023-001'}.png`;
link.href = canvas.toDataURL('image/png');
link.click();
});
}
});
</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=jitware/offerte-programma" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |