Implementation of a extra button to add the complete replacement for the Bibliotheks item
Release Inventarsystem / release-docker (push) Successful in 2m14s

This commit is contained in:
2026-08-18 20:37:04 +02:00
parent 375e9c46eb
commit d61aeebb8f
+23 -5
View File
@@ -432,7 +432,10 @@
<input id="damage-invoice-code" type="text" readonly style="width:100%; padding:10px; border:1px solid #ddd; border-radius:6px; background: var(--ui-surface-soft);">
</div>
<div>
<label for="damage-invoice-amount" style="display:block; font-weight:700; margin-bottom:6px;">Preis</label>
<div style="display:flex; justify-content:space-between; align-items:center; margin-bottom:6px;">
<label for="damage-invoice-amount" style="font-weight:700; margin:0;">Preis</label>
<button type="button" id="damage-invoice-replace-btn" class="btn btn-outline-secondary btn-sm" style="padding: 2px 8px; font-size: 0.75rem;">Komplett ersetzen</button>
</div>
<input id="damage-invoice-amount" name="invoice_amount" type="text" required style="width:100%; padding:10px; border:1px solid #ddd; border-radius:6px;" placeholder="z.B. 12,50">
</div>
</div>
@@ -477,6 +480,7 @@
const damageInvoiceCode = document.getElementById('damage-invoice-code');
const damageInvoiceAmount = document.getElementById('damage-invoice-amount');
const damageInvoiceReason = document.getElementById('damage-invoice-reason');
const damageInvoiceReplaceBtn = document.getElementById('damage-invoice-replace-btn');
function openDamageReportPrompt(button) {
const row = button.closest('.loan-row');
@@ -527,6 +531,7 @@
const inputCode = document.getElementById('damage-invoice-code');
const inputAmount = document.getElementById('damage-invoice-amount');
const inputReason = document.getElementById('damage-invoice-reason');
const replaceBtn = document.getElementById('damage-invoice-replace-btn');
if (!modal || !form) {
console.error("Modal oder Formular nicht gefunden.");
@@ -545,7 +550,13 @@
inputBorrower.value = borrower;
inputCode.value = itemCode;
inputAmount.value = String(itemCost).replace(' EUR', '').trim();
// Feld zunächst leeren, damit der Ersetzen-Button genutzt werden kann
inputAmount.value = '';
// Original-Preis im Button als data-Attribut hinterlegen
if (replaceBtn) {
replaceBtn.dataset.price = String(itemCost).replace(' EUR', '').trim();
}
inputReason.value = description || `Schaden gemeldet für ${itemName}`;
@@ -560,6 +571,15 @@
}
}
// Event-Listener für den Ersetzen-Button
if (damageInvoiceReplaceBtn) {
damageInvoiceReplaceBtn.addEventListener('click', function() {
if (this.dataset.price) {
damageInvoiceAmount.value = this.dataset.price;
}
});
}
window.openDamageInvoiceModal = openDamageInvoiceModal;
window.closeDamageInvoiceModal = closeDamageInvoiceModal;
@@ -571,8 +591,6 @@
});
}
window.closeDamageInvoiceModal = closeDamageInvoiceModal;
function applyFilters() {
const search = (searchInput.value || '').trim().toLowerCase();
const status = statusFilter.value;
@@ -613,4 +631,4 @@
applyFilters();
})();
</script>
{% endblock %}
{% endblock %}