Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 78c215b234 | |||
| 9e77b4604d | |||
| c06473644a | |||
| 6c855ed9d9 | |||
| b09a6f7720 | |||
| 8c5185bd8c | |||
| 0b30f8463f | |||
| 671a9e8e85 | |||
| 3d9e5c470a | |||
| e636242542 | |||
| d61aeebb8f | |||
| 375e9c46eb | |||
| 8dc773d202 |
@@ -1,6 +1,6 @@
|
||||
# Inventarsystem
|
||||
|
||||
[](https://github.com/AIIrondev/legendary-octo-garbanzo/actions/workflows/release-docker.yml)
|
||||
[](https://git.invario-software.eu/Invario/Inventarsystem/actions/workflows/release-docker.yml)
|
||||
|
||||
[](https://wakatime.com/badge/user/30b8509f-5e17-4d16-b6b8-3ca0f3f936d3/project/8a380b7f-389f-4a7e-8877-0fe9e1a4c243)
|
||||
|
||||
|
||||
+25
-12
@@ -3326,9 +3326,6 @@ def library_loans_admin():
|
||||
|
||||
_ensure_audit_indexes_once()
|
||||
|
||||
# IMPORT HINZUGEFÜGT: Entschlüsselungs-Tool importieren
|
||||
from modules.inventarsystem.data_protection import decrypt_text
|
||||
|
||||
def fmt_dt(dt):
|
||||
try:
|
||||
return dt.strftime('%d.%m.%Y %H:%M') if dt else ''
|
||||
@@ -3385,6 +3382,7 @@ def library_loans_admin():
|
||||
'item_code': item_doc.get('Code_4', ''),
|
||||
'item_author': item_doc.get('Author', ''),
|
||||
'item_isbn': item_doc.get('ISBN', ''),
|
||||
'item_cost_raw': item_doc.get('Anschaffungskosten', ''),
|
||||
'user': decrypted_user,
|
||||
'status': record.get('Status', ''),
|
||||
'start': fmt_dt(record.get('Start')),
|
||||
@@ -9110,13 +9108,17 @@ def admin_add_invoice_correction(borrow_id):
|
||||
def library_item_invoices(item_id):
|
||||
"""Show all stored invoices for one specific library item."""
|
||||
if 'username' not in session:
|
||||
flash('Ihnen ist es nicht gestattet auf dieser Internetanwendung, die eben besuchte Adrrese zu nutzen, versuchen sie es erneut nach dem sie sich mit einem berechtigten Nutzer angemeldet haben!', 'error')
|
||||
flash(
|
||||
'Ihnen ist es nicht gestattet auf dieser Internetanwendung, die eben besuchte Adrrese zu nutzen, versuchen sie es erneut nach dem sie sich mit einem berechtigten Nutzer angemeldet haben!',
|
||||
'error')
|
||||
return redirect(url_for('login'))
|
||||
|
||||
if not cfg.MODULES.is_enabled('library'):
|
||||
flash('Bibliotheks-Modul ist deaktiviert.', 'error')
|
||||
return redirect(url_for('home_admin'))
|
||||
|
||||
current_permissions = us.get_effective_permissions(session['username'])
|
||||
|
||||
|
||||
if not current_permissions['pages'].get('library_loans_admin', False):
|
||||
flash('Ihnen fehlen die nötigen Berechtigungen, um diese Aktion auszuführen.', 'error')
|
||||
return redirect(url_for('library_view'))
|
||||
@@ -9137,9 +9139,12 @@ def library_item_invoices(item_id):
|
||||
flash('Bibliotheksmedium nicht gefunden.', 'error')
|
||||
return redirect(url_for('library_loans_admin'))
|
||||
|
||||
item_id_obj = item_doc.get('_id')
|
||||
item_id_str = str(item_id_obj)
|
||||
|
||||
borrow_docs = list(ausleihungen.find(
|
||||
{
|
||||
'Item': str(item_doc.get('_id')),
|
||||
'Item': {'$in': [item_id_str, item_id_obj]},
|
||||
'InvoiceData': {'$exists': True, '$ne': {}}
|
||||
},
|
||||
{
|
||||
@@ -9154,19 +9159,27 @@ def library_item_invoices(item_id):
|
||||
entries = []
|
||||
for borrow_doc in borrow_docs:
|
||||
invoice_data = borrow_doc.get('InvoiceData') or {}
|
||||
|
||||
created_at = invoice_data.get('created_at')
|
||||
created_at_display = created_at.strftime('%d.%m.%Y %H:%M') if isinstance(created_at, datetime.datetime) else (str(created_at) if created_at else '')
|
||||
created_at_display = created_at.strftime('%d.%m.%Y %H:%M') if isinstance(created_at,
|
||||
datetime.datetime) else (
|
||||
str(created_at) if created_at else '')
|
||||
|
||||
paid_at = invoice_data.get('paid_at')
|
||||
paid_at_display = paid_at.strftime('%d.%m.%Y %H:%M') if isinstance(paid_at, datetime.datetime) else (str(paid_at) if paid_at else '')
|
||||
paid_at_display = paid_at.strftime('%d.%m.%Y %H:%M') if isinstance(paid_at, datetime.datetime) else (
|
||||
str(paid_at) if paid_at else '')
|
||||
|
||||
entries.append({
|
||||
'borrow_id': str(borrow_doc.get('_id')),
|
||||
'borrow_status': borrow_doc.get('Status', ''),
|
||||
'borrow_user': borrow_doc.get('User', ''),
|
||||
'borrow_start': borrow_doc.get('Start').strftime('%d.%m.%Y %H:%M') if isinstance(borrow_doc.get('Start'), datetime.datetime) else '',
|
||||
'borrow_end': borrow_doc.get('End').strftime('%d.%m.%Y %H:%M') if isinstance(borrow_doc.get('End'), datetime.datetime) else '',
|
||||
'borrow_start': borrow_doc.get('Start').strftime('%d.%m.%Y %H:%M') if isinstance(
|
||||
borrow_doc.get('Start'), datetime.datetime) else '',
|
||||
'borrow_end': borrow_doc.get('End').strftime('%d.%m.%Y %H:%M') if isinstance(borrow_doc.get('End'),
|
||||
datetime.datetime) else '',
|
||||
'invoice_number': invoice_data.get('invoice_number', ''),
|
||||
'invoice_amount': _format_money_value(invoice_data.get('amount')),
|
||||
'invoice_amount': _format_money_value(invoice_data.get('amount')) if hasattr(invoice_data,
|
||||
'get') else '0,00',
|
||||
'invoice_reason': invoice_data.get('damage_reason', ''),
|
||||
'invoice_created_at': created_at_display,
|
||||
'invoice_created_by': invoice_data.get('created_by', ''),
|
||||
@@ -9189,6 +9202,7 @@ def library_item_invoices(item_id):
|
||||
student_cards_module_enabled=cfg.MODULES.is_enabled('student_cards'),
|
||||
mail_module_enabled=cfg.MODULES.is_enabled('mail')
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
app.logger.error(f"Error loading invoice history for item {item_id}: {e}")
|
||||
flash('Fehler beim Laden der Rechnungshistorie.', 'error')
|
||||
@@ -9197,7 +9211,6 @@ def library_item_invoices(item_id):
|
||||
if client:
|
||||
client.close()
|
||||
|
||||
|
||||
@app.route('/admin_reset_user_password', methods=['POST'])
|
||||
def admin_reset_user_password():
|
||||
"""
|
||||
|
||||
@@ -1261,10 +1261,10 @@
|
||||
<li><a class="dropdown-item" href="{{ url_for('admin_school_settings') }}">Schulstammdaten</a></li>
|
||||
{% endif %}
|
||||
{% if current_permissions.pages.get('admin_borrowings', False) %}
|
||||
<li><a class="dropdown-item" href="{{ url_for('admin_borrowings') }}">Ausleihen</a></li>
|
||||
<li><a class="dropdown-item" href="{{ url_for('admin_borrowings') }}">Alle Ausleihen</a></li>
|
||||
{% endif %}
|
||||
{% if current_permissions.pages.get('admin_damaged_items', False) %}
|
||||
<li><a class="dropdown-item" href="{{ url_for('admin_damaged_items') }}">Defekte Items</a></li>
|
||||
<li><a class="dropdown-item" href="{{ url_for('admin_damaged_items') }}">Alle defekten Items</a></li>
|
||||
{% endif %}
|
||||
{% if current_permissions.actions.get('can_view_logs', False) and current_permissions.pages.get('admin_audit_dashboard', False) %}
|
||||
<li><a class="dropdown-item" href="{{ url_for('admin_audit_dashboard') }}">Audit Dashboard</a></li>
|
||||
@@ -1372,7 +1372,7 @@
|
||||
{% if 'username' in session and current_permissions.actions.get('can_manage_settings', False) %}
|
||||
<li><h6 class="dropdown-header">Bibliotheks-Verwaltung</h6></li>
|
||||
{% if current_permissions.pages.get('library_loans_admin', False) %}
|
||||
<li><a class="dropdown-item" href="{{ url_for('library_loans_admin') }}">Ausleihen / Defekte Items</a></li>
|
||||
<li><a class="dropdown-item" href="{{ url_for('library_loans_admin') }}">Alle Ausleihen/Alle Defekten Items</a></li>
|
||||
{% endif %}
|
||||
{% if student_cards_module_enabled %}
|
||||
{% if current_permissions.actions.get('can_manage_users', False) %}
|
||||
|
||||
@@ -407,14 +407,14 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="damage-invoice-modal" style="display:none; position:fixed; inset:0; background:rgba(15,23,42,0.72); z-index:9999; padding:20px; overflow:auto;">
|
||||
<div id="damage-invoice-modal" role="dialog" aria-modal="true" aria-labelledby="modal-title" style="display:none; position:fixed; inset:0; background:rgba(15,23,42,0.72); z-index:9999; padding:20px; overflow:auto;">
|
||||
<div style="max-width:760px; margin:40px auto; background: var(--ui-surface); border-radius:12px; padding:24px; box-shadow:0 20px 60px rgba(0,0,0,0.3);">
|
||||
<div style="display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom:18px;">
|
||||
<div>
|
||||
<h2 style="margin:0;">Rechnung erstellen</h2>
|
||||
<h2 id="modal-title" style="margin:0;">Rechnung erstellen</h2>
|
||||
<p style="margin:6px 0 0; color:#666;">Die Rechnung nutzt das bestehende Rechnungssystem und kann direkt nach der Schadensmeldung erstellt werden.</p>
|
||||
</div>
|
||||
<button type="button" class="btn btn-secondary" onclick="closeDamageInvoiceModal()">Schließen</button>
|
||||
<button type="button" class="btn btn-secondary" onclick="closeDamageInvoiceModal()" aria-label="Modal schließen">Schließen</button>
|
||||
</div>
|
||||
|
||||
<form id="damage-invoice-form" method="post" action="">
|
||||
@@ -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');
|
||||
@@ -494,41 +498,48 @@
|
||||
|
||||
const description = noteInput.trim() || 'Schaden erneut gemeldet';
|
||||
|
||||
// Visuelles Feedback: Button deaktivieren und Text ändern
|
||||
const originalText = button.textContent;
|
||||
button.disabled = true;
|
||||
button.textContent = 'Speichere...';
|
||||
|
||||
fetch(`/report_damage/${itemId}`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ description })
|
||||
})
|
||||
.then(response => response.json().then(data => ({ ok: response.ok, data })))
|
||||
.then(({ ok, data }) => {
|
||||
if (!ok || !data.success) {
|
||||
.then(async response => {
|
||||
// Robustes JSON-Parsing (verhindert Absturz, falls der Server kein JSON zurückgibt)
|
||||
const data = await response.json().catch(() => ({}));
|
||||
if (!response.ok || !data.success) {
|
||||
throw new Error(data.message || 'Fehler beim Speichern der Schadensmeldung.');
|
||||
}
|
||||
|
||||
return data;
|
||||
})
|
||||
.then(data => {
|
||||
if (confirm('Schaden gespeichert. Soll direkt eine Rechnung erstellt werden?')) {
|
||||
openDamageInvoiceModal(row, description);
|
||||
// Button wieder zurücksetzen, da die Seite nicht neu geladen wird
|
||||
button.disabled = false;
|
||||
button.textContent = originalText;
|
||||
return;
|
||||
}
|
||||
|
||||
// Bei "Abbrechen" im Confirm -> Neuladen der Tabelle
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(error => {
|
||||
alert(error.message || 'Fehler beim Speichern der Schadensmeldung.');
|
||||
alert(error.message || 'Ein unbekannter Fehler ist aufgetreten.');
|
||||
// Fehlerbehandlung: Button wieder aktiv schalten
|
||||
button.disabled = false;
|
||||
button.textContent = originalText;
|
||||
});
|
||||
}
|
||||
|
||||
window.openDamageReportPrompt = openDamageReportPrompt;
|
||||
|
||||
function openDamageInvoiceModal(row, description) {
|
||||
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) {
|
||||
if (!damageInvoiceModal || !damageInvoiceForm) {
|
||||
console.error("Modal oder Formular nicht gefunden.");
|
||||
return;
|
||||
}
|
||||
@@ -537,29 +548,47 @@
|
||||
const itemName = row.dataset.itemName || '';
|
||||
const borrower = row.dataset.userName || '';
|
||||
const itemCode = row.dataset.itemCode || '';
|
||||
|
||||
// KORREKTUR: Jetzt greifen wir auf das richtige dataset-Attribut zu
|
||||
const itemCost = row.dataset.itemCost || '';
|
||||
|
||||
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);
|
||||
|
||||
inputItem.value = itemName;
|
||||
inputBorrower.value = borrower;
|
||||
inputCode.value = itemCode;
|
||||
damageInvoiceItem.value = itemName;
|
||||
damageInvoiceBorrower.value = borrower;
|
||||
damageInvoiceCode.value = itemCode;
|
||||
|
||||
inputAmount.value = String(itemCost).replace(' EUR', '').trim();
|
||||
// Feld zunächst leeren, damit der Ersetzen-Button genutzt werden kann
|
||||
damageInvoiceAmount.value = '';
|
||||
|
||||
inputReason.value = description || `Schaden gemeldet für ${itemName}`;
|
||||
// Original-Preis im Button als data-Attribut hinterlegen
|
||||
if (damageInvoiceReplaceBtn) {
|
||||
damageInvoiceReplaceBtn.dataset.acquisition_costs = String(itemCost).replace(' EUR', '').trim();
|
||||
}
|
||||
|
||||
modal.style.display = 'block';
|
||||
inputAmount.focus();
|
||||
damageInvoiceReason.value = description || `Schaden gemeldet für ${itemName}`;
|
||||
|
||||
damageInvoiceModal.style.display = 'block';
|
||||
|
||||
// Accessibility: Fokus ins erste aktivierbare Feld setzen
|
||||
damageInvoiceAmount.focus();
|
||||
}
|
||||
|
||||
function closeDamageInvoiceModal() {
|
||||
const modal = document.getElementById('damage-invoice-modal');
|
||||
if (modal) {
|
||||
modal.style.display = 'none';
|
||||
if (damageInvoiceModal) {
|
||||
damageInvoiceModal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Event-Listener für den Ersetzen-Button
|
||||
if (damageInvoiceReplaceBtn) {
|
||||
damageInvoiceReplaceBtn.addEventListener('click', function() {
|
||||
if (this.dataset.acquisition_costs) {
|
||||
damageInvoiceAmount.value = this.dataset.acquisition_costs;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
window.openDamageInvoiceModal = openDamageInvoiceModal;
|
||||
window.closeDamageInvoiceModal = closeDamageInvoiceModal;
|
||||
|
||||
@@ -571,8 +600,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.closeDamageInvoiceModal = closeDamageInvoiceModal;
|
||||
|
||||
function applyFilters() {
|
||||
const search = (searchInput.value || '').trim().toLowerCase();
|
||||
const status = statusFilter.value;
|
||||
@@ -613,4 +640,4 @@
|
||||
applyFilters();
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
@@ -516,7 +516,7 @@
|
||||
</select>
|
||||
<input type="text" id="activeStudentCard" placeholder="Aktiver Ausweis (gescannt)">
|
||||
<input type="text" id="manualItemCode" placeholder="Manueller Mediencode (optional)" style="min-width:180px;">
|
||||
<button id="resetCardBtn" class="button" type="button">Ausweis löschen</button>
|
||||
<button id="resetCardBtn" class="button" type="button">Feld zurücksetzen</button>
|
||||
<button id="toggleScannerBtn" class="button" type="button">Scanner starten</button>
|
||||
<label style="display:flex; align-items:center; gap:8px; margin-left:6px;">
|
||||
<input type="checkbox" id="keyboardScannerToggle">
|
||||
|
||||
Reference in New Issue
Block a user