diff --git a/Web/app.py b/Web/app.py index a90c332..9d628e6 100755 --- a/Web/app.py +++ b/Web/app.py @@ -3157,7 +3157,7 @@ def library_loans_admin(): 'damage_text': (damage_reports[0].get('description', '') if damage_reports else ''), 'available': bool(item_doc.get('Verfuegbar', False)), 'last_updated': fmt_dt(item_doc.get('LastUpdated')), - 'acquisition_costs': fmt_money(item_doc.get('Anschaffungskosten')) + 'acquisition_costs': item_doc.get('Anschaffungskosten', "") }) return render_template( diff --git a/Web/templates/library_borrowings_admin.html b/Web/templates/library_borrowings_admin.html index 4fdb2b2..d3ae9ed 100644 --- a/Web/templates/library_borrowings_admin.html +++ b/Web/templates/library_borrowings_admin.html @@ -520,7 +520,16 @@ window.openDamageReportPrompt = openDamageReportPrompt; function openDamageInvoiceModal(row, description) { - if (!damageInvoiceModal || !damageInvoiceForm) { + const modal = document.getElementById('damage-invoice-modal'); + const form = document.getElementById('damage-invoice-form'); + const inputItem = document.getElementById('damage-invoice-item'); + const inputBorrower = document.getElementById('damage-invoice-borrower'); + const inputCode = document.getElementById('damage-invoice-code'); + const inputAmount = document.getElementById('damage-invoice-amount'); + const inputReason = document.getElementById('damage-invoice-reason'); + + if (!modal || !form) { + console.error("Modal oder Formular nicht gefunden."); return; } @@ -530,25 +539,29 @@ const itemCode = row.dataset.itemCode || ''; const itemCost = row.dataset.itemCost || ''; - document.getElementById("damage-invoice-amount").value = "{{ item.acquisition_costs }}"; + form.action = "{{ url_for('admin_create_invoice', borrow_id='__BORROW_ID__') }}".replace('__BORROW_ID__', borrowId); - damageInvoiceForm.action = "{{ url_for('admin_create_invoice', borrow_id='__BORROW_ID__') }}".replace('__BORROW_ID__', borrowId); - damageInvoiceItem.value = itemName; - damageInvoiceBorrower.value = borrower; - damageInvoiceCode.value = itemCode; - damageInvoiceAmount.value = String(itemCost).replace(' EUR', '').trim(); - damageInvoiceReason.value = description || `Schaden gemeldet für ${itemName}`; - damageInvoiceModal.style.display = 'block'; - damageInvoiceAmount.focus(); + inputItem.value = itemName; + inputBorrower.value = borrower; + inputCode.value = itemCode; + + inputAmount.value = String(itemCost).replace(' EUR', '').trim(); + + inputReason.value = description || `Schaden gemeldet für ${itemName}`; + + modal.style.display = 'block'; + inputAmount.focus(); + } + + function closeDamageInvoiceModal() { + const modal = document.getElementById('damage-invoice-modal'); + if (modal) { + modal.style.display = 'none'; + } } window.openDamageInvoiceModal = openDamageInvoiceModal; - - function closeDamageInvoiceModal() { - if (damageInvoiceModal) { - damageInvoiceModal.style.display = 'none'; - } - } + window.closeDamageInvoiceModal = closeDamageInvoiceModal; if (damageInvoiceModal) { damageInvoiceModal.addEventListener('click', function(event) {