Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cfec33b362 | |||
| fb29fb91a9 | |||
| c3db2d9c6b | |||
| edc7b72a8f | |||
| cdf7b9c45d | |||
| 5ba0944faf | |||
| 37f514af15 | |||
| 152a3ab135 | |||
| c2c5054814 | |||
| e058bd5f46 | |||
| d58958db39 | |||
| 9452743660 |
+300
-225
@@ -27,6 +27,10 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from gridfs import GridFS
|
from gridfs import GridFS
|
||||||
|
import string
|
||||||
|
from reportlab.lib.pagesizes import A4
|
||||||
|
from reportlab.pdfgen import canvas
|
||||||
|
from reportlab.lib import colors
|
||||||
|
|
||||||
# Ensure imports work regardless of whether gunicorn starts in /app or /app/Web.
|
# Ensure imports work regardless of whether gunicorn starts in /app or /app/Web.
|
||||||
_CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
_CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||||
@@ -6212,180 +6216,8 @@ def bulk_delete_items():
|
|||||||
if client:
|
if client:
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
|
||||||
@app.route('/edit_item/<id>', methods=['POST'])
|
|
||||||
def edit_item(id):
|
|
||||||
"""
|
|
||||||
Route for editing an existing inventory item.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
id (str): ID of the item to edit
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
flask.Response: Redirect to admin homepage with status message
|
|
||||||
"""
|
|
||||||
if 'username' not in session:
|
|
||||||
flash('Nicht angemeldet.', 'error')
|
|
||||||
return redirect(url_for('login'))
|
|
||||||
|
|
||||||
current_permissions = us.get_effective_permissions(session['username'])
|
|
||||||
|
|
||||||
if not current_permissions['actions'].get('can_edit', False):
|
|
||||||
flash('Ihnen fehlen die nötigen Berechtigungen, um diese Aktion auszuführen.', 'error')
|
|
||||||
return redirect(url_for('home_admin'))
|
|
||||||
|
|
||||||
if not cfg.MODULES.is_enabled('inventory'):
|
|
||||||
flash('Bibliotheks-Modul ist deaktiviert.', 'error')
|
|
||||||
return redirect(url_for('library_view'))
|
|
||||||
|
|
||||||
fs = get_gridfs()
|
|
||||||
|
|
||||||
name = sanitize_form_value(request.form.get('name'))
|
|
||||||
ort = sanitize_form_value(request.form.get('ort'))
|
|
||||||
beschreibung = sanitize_form_value(request.form.get('beschreibung'))
|
|
||||||
|
|
||||||
filter1 = sanitize_form_value(request.form.getlist('filter'))
|
|
||||||
filter2 = sanitize_form_value(request.form.getlist('filter2'))
|
|
||||||
filter3 = sanitize_form_value(request.form.getlist('filter3'))
|
|
||||||
|
|
||||||
# Expand special "all values" selections for predefined filters.
|
|
||||||
filter1 = expand_filter_selection(filter1, 1)
|
|
||||||
filter2 = expand_filter_selection(filter2, 2)
|
|
||||||
|
|
||||||
anschaffungs_jahr = sanitize_form_value(request.form.get('anschaffungsjahr'))
|
|
||||||
anschaffungs_kosten = sanitize_form_value(request.form.get('anschaffungskosten'))
|
|
||||||
code_4 = sanitize_form_value(request.form.get('code_4'))
|
|
||||||
isbn_raw = sanitize_form_value(request.form.get('isbn', ''))
|
|
||||||
reservierbar = 'reservierbar' in request.form
|
|
||||||
|
|
||||||
item_isbn = ''
|
|
||||||
item_type = 'general'
|
|
||||||
if cfg.MODULES.is_enabled('library'):
|
|
||||||
item_isbn = normalize_and_validate_isbn(isbn_raw)
|
|
||||||
if isbn_raw and not item_isbn:
|
|
||||||
flash('Ungültige ISBN. Bitte ISBN-10 oder ISBN-13 verwenden.', 'error')
|
|
||||||
return redirect(url_for('home_admin'))
|
|
||||||
if item_isbn:
|
|
||||||
item_type = 'book'
|
|
||||||
|
|
||||||
if code_4 and not it.is_code_unique(code_4, exclude_id=id):
|
|
||||||
flash('Der Code wird bereits verwendet. Bitte wählen Sie einen anderen Code.', 'error')
|
|
||||||
return redirect(url_for('home_admin'))
|
|
||||||
|
|
||||||
current_item = it.get_item(id)
|
|
||||||
if not current_item:
|
|
||||||
flash('Element nicht gefunden', 'error')
|
|
||||||
return redirect(url_for('home_admin'))
|
|
||||||
|
|
||||||
verfuegbar = current_item.get('Verfuegbar', True)
|
|
||||||
|
|
||||||
images_to_keep = request.form.getlist('existing_images')
|
|
||||||
|
|
||||||
original_images = current_item.get('Images', [])
|
|
||||||
|
|
||||||
images = [img for img in original_images if img in images_to_keep]
|
|
||||||
|
|
||||||
new_images = request.files.getlist('new_images')
|
|
||||||
|
|
||||||
for image in new_images:
|
|
||||||
if image and image.filename:
|
|
||||||
is_allowed, error_message = allowed_file(image.filename, image)
|
|
||||||
|
|
||||||
if is_allowed:
|
|
||||||
try:
|
|
||||||
secure_name = secure_filename(image.filename)
|
|
||||||
|
|
||||||
image.seek(0)
|
|
||||||
image_bytes = image.read()
|
|
||||||
|
|
||||||
if not image_bytes:
|
|
||||||
app.logger.error(f"Failed to read image in edit_item (0 bytes) for {secure_name}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
optimized_io = io.BytesIO()
|
|
||||||
with Image.open(io.BytesIO(image_bytes)) as img:
|
|
||||||
if img.mode not in ('RGB', 'RGBA'):
|
|
||||||
img = img.convert('RGBA')
|
|
||||||
|
|
||||||
max_width = 500
|
|
||||||
if img.width > max_width:
|
|
||||||
ratio = max_width / img.width
|
|
||||||
new_size = (max_width, int(img.height * ratio))
|
|
||||||
img = img.resize(new_size, Image.Resampling.LANCZOS)
|
|
||||||
|
|
||||||
img.save(optimized_io, format='WEBP', quality=85, optimize=True)
|
|
||||||
|
|
||||||
optimized_io.seek(0)
|
|
||||||
new_filename = f"{uuid.uuid4().hex}_{int(time.time())}.webp"
|
|
||||||
|
|
||||||
fs.put(
|
|
||||||
optimized_io,
|
|
||||||
filename=new_filename,
|
|
||||||
content_type='image/webp',
|
|
||||||
metadata={
|
|
||||||
'original_filename': secure_name,
|
|
||||||
'upload_context': 'edit_item',
|
|
||||||
'item_id': id
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
images.append(new_filename)
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
app.logger.error(f"Error processing new image in edit_item: {str(e)}")
|
|
||||||
else:
|
|
||||||
flash(error_message, 'error')
|
|
||||||
return redirect(url_for('home_admin'))
|
|
||||||
|
|
||||||
predefined_locations = it.get_predefined_locations()
|
|
||||||
if ort and ort not in predefined_locations:
|
|
||||||
it.add_predefined_location(ort)
|
|
||||||
|
|
||||||
result = it.update_item(
|
|
||||||
id=id,
|
|
||||||
name=name,
|
|
||||||
ort=ort,
|
|
||||||
beschreibung=beschreibung,
|
|
||||||
images=images,
|
|
||||||
verfuegbar=verfuegbar,
|
|
||||||
filter1=filter1,
|
|
||||||
filter2=filter2,
|
|
||||||
filter3=filter3,
|
|
||||||
ansch_jahr=anschaffungs_jahr,
|
|
||||||
ansch_kost=anschaffungs_kosten,
|
|
||||||
code_4=code_4,
|
|
||||||
reservierbar=reservierbar,
|
|
||||||
isbn=item_isbn,
|
|
||||||
item_type=item_type
|
|
||||||
)
|
|
||||||
|
|
||||||
if result:
|
|
||||||
flash('Element erfolgreich aktualisiert (und ggf. Gruppe synchronisiert)', 'success')
|
|
||||||
else:
|
|
||||||
flash('Fehler beim Aktualisieren des Elements', 'error')
|
|
||||||
|
|
||||||
return redirect(url_for('home_admin'))
|
|
||||||
|
|
||||||
def is_library_item(item):
|
|
||||||
"""
|
|
||||||
Prüft, ob ein Artikel ein Bibliotheks-Item ist.
|
|
||||||
- 'other', None oder Leerstring -> Inventarsystem (False)
|
|
||||||
- Jeder andere Medientyp ('Buch', 'CD', etc.) -> Bibliothek (True)
|
|
||||||
"""
|
|
||||||
if not item:
|
|
||||||
return False
|
|
||||||
item_type = item.get('ItemType', 'other')
|
|
||||||
if not item_type:
|
|
||||||
return False
|
|
||||||
return item_type.strip().lower() != 'other'
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/item_edit/<id>', methods=['GET', 'POST'])
|
@app.route('/item_edit/<id>', methods=['GET', 'POST'])
|
||||||
def item_edit(id):
|
def item_edit(id):
|
||||||
"""
|
|
||||||
Complete endpoint for editing items. Automatically detects whether the item
|
|
||||||
is a Library item (ItemType != 'other') or an Inventory item (ItemType == 'other').
|
|
||||||
"""
|
|
||||||
if 'username' not in session:
|
if 'username' not in session:
|
||||||
if request.method == 'POST' and request.is_json:
|
if request.method == 'POST' and request.is_json:
|
||||||
return jsonify({'success': False, 'message': 'Nicht angemeldet.'}), 401
|
return jsonify({'success': False, 'message': 'Nicht angemeldet.'}), 401
|
||||||
@@ -6410,18 +6242,17 @@ def item_edit(id):
|
|||||||
flash('Element in der Datenbank nicht gefunden.', 'error')
|
flash('Element in der Datenbank nicht gefunden.', 'error')
|
||||||
return redirect(url_for('home_admin'))
|
return redirect(url_for('home_admin'))
|
||||||
|
|
||||||
# Determine item type classification
|
# Bibliothek-Status ermitteln
|
||||||
library_module_active = cfg.MODULES.is_enabled('library')
|
library_module_active = cfg.MODULES.is_enabled('library')
|
||||||
is_lib_item = it.is_library_item(current_item)
|
is_lib_item = it.is_library_item(current_item)
|
||||||
show_library_features = library_module_active and is_lib_item
|
show_library_features = library_module_active and is_lib_item
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# GET METHOD: Render Form
|
# GET METHOD
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
current_item['_id'] = str(current_item['_id'])
|
current_item['_id'] = str(current_item['_id'])
|
||||||
|
|
||||||
# Format individual group codes for the textarea
|
|
||||||
base_code = current_item.get('Code_4', '')
|
base_code = current_item.get('Code_4', '')
|
||||||
individual_codes = []
|
individual_codes = []
|
||||||
if current_item.get('SeriesGroupId'):
|
if current_item.get('SeriesGroupId'):
|
||||||
@@ -6445,11 +6276,10 @@ def item_edit(id):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
# POST METHOD: Save Changes
|
# POST METHOD
|
||||||
# -------------------------------------------------------------------
|
# -------------------------------------------------------------------
|
||||||
redirect_target = request.referrer or url_for('home_admin')
|
redirect_target = request.referrer or url_for('home_admin')
|
||||||
|
|
||||||
# Common fields
|
|
||||||
name = sanitize_form_value(request.form.get('name'))
|
name = sanitize_form_value(request.form.get('name'))
|
||||||
ort = sanitize_form_value(request.form.get('ort'))
|
ort = sanitize_form_value(request.form.get('ort'))
|
||||||
beschreibung = sanitize_form_value(request.form.get('beschreibung'))
|
beschreibung = sanitize_form_value(request.form.get('beschreibung'))
|
||||||
@@ -6457,7 +6287,6 @@ def item_edit(id):
|
|||||||
anschaffungs_kosten = sanitize_form_value(request.form.get('anschaffungskosten'))
|
anschaffungs_kosten = sanitize_form_value(request.form.get('anschaffungskosten'))
|
||||||
reservierbar = 'reservierbar' in request.form
|
reservierbar = 'reservierbar' in request.form
|
||||||
|
|
||||||
# Barcodes
|
|
||||||
code_4 = sanitize_form_value(request.form.get('code_4'))
|
code_4 = sanitize_form_value(request.form.get('code_4'))
|
||||||
individual_codes_raw = request.form.get('individual_codes', '')
|
individual_codes_raw = request.form.get('individual_codes', '')
|
||||||
|
|
||||||
@@ -6469,7 +6298,6 @@ def item_edit(id):
|
|||||||
|
|
||||||
all_codes_to_check = [code_4] + individual_codes
|
all_codes_to_check = [code_4] + individual_codes
|
||||||
|
|
||||||
# Barcode uniqueness check
|
|
||||||
current_group_id = current_item.get('SeriesGroupId')
|
current_group_id = current_item.get('SeriesGroupId')
|
||||||
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
||||||
db_instance = client[cfg.MONGODB_DB]
|
db_instance = client[cfg.MONGODB_DB]
|
||||||
@@ -6492,29 +6320,27 @@ def item_edit(id):
|
|||||||
if has_code_error:
|
if has_code_error:
|
||||||
return redirect(redirect_target)
|
return redirect(redirect_target)
|
||||||
|
|
||||||
# Type-specific processing
|
|
||||||
if show_library_features:
|
if show_library_features:
|
||||||
# --- LIBRARY ITEM ---
|
# LIBRARY ITEM: Process ISBN/Medientyp/Category, preserve existing filters
|
||||||
isbn_raw = sanitize_form_value(request.form.get('isbn', ''))
|
isbn_raw = sanitize_form_value(request.form.get('isbn', ''))
|
||||||
item_isbn = normalize_and_validate_isbn(isbn_raw) if isbn_raw else ''
|
item_isbn = normalize_and_validate_isbn(isbn_raw) if isbn_raw else ''
|
||||||
item_type = sanitize_form_value(request.form.get('item_type_input', 'Buch'))
|
item_type = sanitize_form_value(request.form.get('item_type_input', current_item.get('ItemType', 'Buch')))
|
||||||
library_category = sanitize_form_value(request.form.get('library_category', ''))
|
library_category = sanitize_form_value(request.form.get('library_category', ''))
|
||||||
|
images = current_item.get('Images', [])
|
||||||
|
|
||||||
filter1 = current_item.get('Filter', [])
|
filter1 = current_item.get('Filter', [])
|
||||||
filter2 = current_item.get('Filter2', [])
|
filter2 = current_item.get('Filter2', [])
|
||||||
filter3 = current_item.get('Filter3', [])
|
filter3 = current_item.get('Filter3', [])
|
||||||
images = current_item.get('Images', [])
|
|
||||||
else:
|
else:
|
||||||
# --- INVENTORY ITEM ---
|
# NON-LIBRARY (INVENTORY) ITEM: Process Filter 1-3 from form
|
||||||
item_isbn = current_item.get('ISBN', '')
|
item_isbn = current_item.get('ISBN', '')
|
||||||
item_type = 'other' # Standard type for inventory items
|
item_type = 'other'
|
||||||
library_category = current_item.get('library_category', '')
|
library_category = current_item.get('library_category', '')
|
||||||
|
|
||||||
filter1 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter')), 1)
|
filter1 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter')), 1)
|
||||||
filter2 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter2')), 2)
|
filter2 = expand_filter_selection(sanitize_form_value(request.form.getlist('filter2')), 2)
|
||||||
filter3 = sanitize_form_value(request.form.getlist('filter3'))
|
filter3 = sanitize_form_value(request.form.getlist('filter3'))
|
||||||
|
|
||||||
# Manage images for Inventory Mode
|
|
||||||
images_to_keep = request.form.getlist('existing_images')
|
images_to_keep = request.form.getlist('existing_images')
|
||||||
original_images = current_item.get('Images', [])
|
original_images = current_item.get('Images', [])
|
||||||
images = [img for img in original_images if img in images_to_keep]
|
images = [img for img in original_images if img in images_to_keep]
|
||||||
@@ -6554,15 +6380,11 @@ def item_edit(id):
|
|||||||
images.append(new_filename)
|
images.append(new_filename)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.logger.error(f"Image error for item {id}: {e}")
|
app.logger.error(f"Image error for item {id}: {e}")
|
||||||
|
|
||||||
# Auto-add new location to predefined locations list if applicable
|
|
||||||
if ort and ort not in it.get_predefined_locations():
|
if ort and ort not in it.get_predefined_locations():
|
||||||
it.add_predefined_location(ort)
|
it.add_predefined_location(ort)
|
||||||
|
|
||||||
# Sync series/group barcode IDs
|
|
||||||
it.sync_group_codes(str(id), code_4, individual_codes)
|
it.sync_group_codes(str(id), code_4, individual_codes)
|
||||||
|
|
||||||
# Update item in database
|
|
||||||
success = it.update_item(
|
success = it.update_item(
|
||||||
id=str(id),
|
id=str(id),
|
||||||
name=name,
|
name=name,
|
||||||
@@ -6588,6 +6410,7 @@ def item_edit(id):
|
|||||||
flash('Fehler beim Aktualisieren des Artikels.', 'error')
|
flash('Fehler beim Aktualisieren des Artikels.', 'error')
|
||||||
|
|
||||||
return redirect(redirect_target)
|
return redirect(redirect_target)
|
||||||
|
|
||||||
@app.route('/update_group', methods=['POST'])
|
@app.route('/update_group', methods=['POST'])
|
||||||
def update_group():
|
def update_group():
|
||||||
|
|
||||||
@@ -7874,35 +7697,282 @@ def register():
|
|||||||
permission_page_options=PERMISSION_PAGE_OPTIONS
|
permission_page_options=PERMISSION_PAGE_OPTIONS
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def parse_csv_users(file_bytes):
|
||||||
|
"""
|
||||||
|
Liest CSV-Dateien extrem robust ein:
|
||||||
|
- Erkennt automatisch UTF-8, UTF-8-SIG und Latin-1 (für Excel-Umlaute).
|
||||||
|
- Erkennt automatisch das Trennzeichen (; oder , oder Tab).
|
||||||
|
- Erkennt Vor- und Nachname unabhängig von der Spaltenreihenfolge und Headernamen.
|
||||||
|
"""
|
||||||
|
# 1. Dekodierung mit Fallback für deutsche Excel-Dateien
|
||||||
|
try:
|
||||||
|
content = file_bytes.decode('utf-8-sig')
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
content = file_bytes.decode('latin-1')
|
||||||
|
|
||||||
|
lines = [line.strip() for line in content.splitlines() if line.strip()]
|
||||||
|
if not lines:
|
||||||
|
return []
|
||||||
|
|
||||||
|
# 2. Trennzeichen ermitteln (; , oder \t)
|
||||||
|
first_line = lines[0]
|
||||||
|
if first_line.count(';') >= first_line.count(','):
|
||||||
|
delimiter = ';'
|
||||||
|
elif first_line.count('\t') > first_line.count(','):
|
||||||
|
delimiter = '\t'
|
||||||
|
else:
|
||||||
|
delimiter = ','
|
||||||
|
|
||||||
|
stream = io.StringIO(content, newline=None)
|
||||||
|
reader = csv.DictReader(stream, delimiter=delimiter)
|
||||||
|
|
||||||
|
parsed_users = []
|
||||||
|
|
||||||
|
# 3. Auswertung mit DictReader (wenn Header vorhanden sind)
|
||||||
|
if reader.fieldnames:
|
||||||
|
for row in reader:
|
||||||
|
# Keys normalisieren (kleingeschrieben, ohne Leerzeichen)
|
||||||
|
cleaned_row = {str(k).strip().lower(): str(v).strip() for k, v in row.items() if k and v}
|
||||||
|
|
||||||
|
# Dynamisches Mapping für Vornamen
|
||||||
|
name = (
|
||||||
|
cleaned_row.get('vorname') or
|
||||||
|
cleaned_row.get('first_name') or
|
||||||
|
cleaned_row.get('firstname') or
|
||||||
|
cleaned_row.get('name') or ''
|
||||||
|
)
|
||||||
|
|
||||||
|
# Dynamisches Mapping für Nachnamen
|
||||||
|
last_name = (
|
||||||
|
cleaned_row.get('nachname') or
|
||||||
|
cleaned_row.get('last_name') or
|
||||||
|
cleaned_row.get('lastname') or
|
||||||
|
cleaned_row.get('surname') or
|
||||||
|
cleaned_row.get('familienname') or ''
|
||||||
|
)
|
||||||
|
|
||||||
|
# Falls Header nicht erkannt wurden, aber Werte vorhanden sind (z.B. CSV ohne Header)
|
||||||
|
if not name and not last_name:
|
||||||
|
vals = [str(v).strip() for v in row.values() if v]
|
||||||
|
if len(vals) >= 2:
|
||||||
|
name, last_name = vals[0], vals[1]
|
||||||
|
|
||||||
|
if name or last_name:
|
||||||
|
parsed_users.append({'name': name, 'last_name': last_name})
|
||||||
|
else:
|
||||||
|
# Fallback für dateien ohne Header
|
||||||
|
stream.seek(0)
|
||||||
|
raw_reader = csv.reader(stream, delimiter=delimiter)
|
||||||
|
for row in raw_reader:
|
||||||
|
clean_row = [str(cell).strip() for cell in row if str(cell).strip()]
|
||||||
|
if len(clean_row) >= 2:
|
||||||
|
# Header-Zeilen überspringen
|
||||||
|
if clean_row[0].lower() in ['vorname', 'first_name', 'name'] and clean_row[1].lower() in ['nachname', 'last_name']:
|
||||||
|
continue
|
||||||
|
parsed_users.append({'name': clean_row[0], 'last_name': clean_row[1]})
|
||||||
|
|
||||||
|
return parsed_users
|
||||||
|
|
||||||
|
def generate_compliant_password(length=16):
|
||||||
|
lowers = string.ascii_lowercase
|
||||||
|
uppers = string.ascii_uppercase
|
||||||
|
digits = string.digits
|
||||||
|
symbols = "!@#$%^&*()_+~|}{[]:;?><,.-="
|
||||||
|
|
||||||
|
# Ensure at least one character from each required category
|
||||||
|
pwd = [
|
||||||
|
secrets.choice(lowers),
|
||||||
|
secrets.choice(uppers),
|
||||||
|
secrets.choice(digits),
|
||||||
|
secrets.choice(symbols)
|
||||||
|
]
|
||||||
|
all_chars = lowers + uppers + digits + symbols
|
||||||
|
pwd += [secrets.choice(all_chars) for _ in range(length - 4)]
|
||||||
|
|
||||||
|
# Shuffle so guaranteed types aren't always at the start
|
||||||
|
secrets.SystemRandom().shuffle(pwd)
|
||||||
|
return "".join(pwd)
|
||||||
|
|
||||||
|
def generate_credentials_pdf(created_users):
|
||||||
|
"""
|
||||||
|
Creates a PDF in memory with 2 user credential cards per A4 page.
|
||||||
|
created_users: list of dicts [{'name': ..., 'last_name': ..., 'username': ..., 'password': ...}]
|
||||||
|
"""
|
||||||
|
buffer = io.BytesIO()
|
||||||
|
pdf = canvas.Canvas(buffer, pagesize=A4)
|
||||||
|
width, height = A4 # 595.27 x 841.89 points
|
||||||
|
card_height = height / 2.0 # Split page into 2 equal halves
|
||||||
|
|
||||||
|
for i, user in enumerate(created_users):
|
||||||
|
page_slot = i % 2 # 0 = Top half, 1 = Bottom half
|
||||||
|
|
||||||
|
# If starting a new page (except for the very first item)
|
||||||
|
if i > 0 and page_slot == 0:
|
||||||
|
pdf.showPage()
|
||||||
|
|
||||||
|
# Calculate Y offset for card position
|
||||||
|
y_offset = height - (page_slot + 1) * card_height
|
||||||
|
|
||||||
|
# Card Container Box
|
||||||
|
margin = 35
|
||||||
|
box_x = margin
|
||||||
|
box_y = y_offset + margin
|
||||||
|
box_w = width - (2 * margin)
|
||||||
|
box_h = card_height - (2 * margin)
|
||||||
|
|
||||||
|
# Outer Border
|
||||||
|
pdf.setStrokeColor(colors.HexColor('#CBD5E1'))
|
||||||
|
pdf.setLineWidth(1)
|
||||||
|
pdf.rect(box_x, box_y, box_w, box_h, fill=0)
|
||||||
|
|
||||||
|
# Header Banner inside Card
|
||||||
|
pdf.setFillColor(colors.HexColor('#1E293B'))
|
||||||
|
pdf.rect(box_x, box_y + box_h - 45, box_w, 45, fill=1, stroke=0)
|
||||||
|
|
||||||
|
# Header Title Text
|
||||||
|
pdf.setFillColor(colors.white)
|
||||||
|
pdf.setFont("Helvetica-Bold", 14)
|
||||||
|
pdf.drawString(box_x + 20, box_y + box_h - 28, "Zugangsdaten / Account Credentials")
|
||||||
|
|
||||||
|
# User Info Details
|
||||||
|
content_y = box_y + box_h - 80
|
||||||
|
|
||||||
|
# Name
|
||||||
|
pdf.setFillColor(colors.HexColor('#0F172A'))
|
||||||
|
pdf.setFont("Helvetica-Bold", 12)
|
||||||
|
pdf.drawString(box_x + 25, content_y, f"Name: {user['name']} {user['last_name']}")
|
||||||
|
|
||||||
|
# Username
|
||||||
|
content_y -= 35
|
||||||
|
pdf.setFont("Helvetica", 11)
|
||||||
|
pdf.setFillColor(colors.HexColor('#475569'))
|
||||||
|
pdf.drawString(box_x + 25, content_y, "Benutzername:")
|
||||||
|
pdf.setFont("Helvetica-Bold", 13)
|
||||||
|
pdf.setFillColor(colors.HexColor('#0F172A'))
|
||||||
|
pdf.drawString(box_x + 160, content_y, user['username'])
|
||||||
|
|
||||||
|
# Password
|
||||||
|
content_y -= 30
|
||||||
|
pdf.setFont("Helvetica", 11)
|
||||||
|
pdf.setFillColor(colors.HexColor('#475569'))
|
||||||
|
pdf.drawString(box_x + 25, content_y, "Passwort:")
|
||||||
|
pdf.setFont("Courier-Bold", 13)
|
||||||
|
pdf.setFillColor(colors.HexColor('#0F172A'))
|
||||||
|
pdf.drawString(box_x + 160, content_y, user['password'])
|
||||||
|
|
||||||
|
# Security Footer Note
|
||||||
|
content_y -= 45
|
||||||
|
pdf.setFont("Helvetica-Oblique", 9)
|
||||||
|
pdf.setFillColor(colors.HexColor('#64748B'))
|
||||||
|
pdf.drawString(box_x + 25, content_y, "Hinweis: Bitte ändern Sie Ihr Passwort nach der ersten Anmeldung.")
|
||||||
|
|
||||||
|
# Dashed Cut Line between top and bottom cards
|
||||||
|
if page_slot == 0 and i < len(created_users) - 1:
|
||||||
|
pdf.setDash(4, 4)
|
||||||
|
pdf.setStrokeColor(colors.HexColor('#94A3B8'))
|
||||||
|
pdf.line(0, card_height, width, card_height)
|
||||||
|
pdf.setDash() # Reset dash
|
||||||
|
|
||||||
|
pdf.save()
|
||||||
|
buffer.seek(0)
|
||||||
|
return buffer
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/register/csv', methods=['POST'])
|
||||||
|
def register_csv():
|
||||||
|
if 'username' not in session:
|
||||||
|
flash('Ihnen ist es nicht gestattet, diese Aktion auszuführen.', 'error')
|
||||||
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
|
file = request.files.get('csv_file')
|
||||||
|
if not file or not file.filename.endswith('.csv'):
|
||||||
|
flash('Bitte laden Sie eine gültige CSV-Datei hoch.', 'error')
|
||||||
|
return redirect(url_for('register'))
|
||||||
|
|
||||||
|
permission_preset = (request.form.get('permission_preset') or 'standard_user').strip()
|
||||||
|
|
||||||
|
# 1. CSV über die robuste Funktion einlesen
|
||||||
|
file_bytes = file.stream.read()
|
||||||
|
raw_users = parse_csv_users(file_bytes)
|
||||||
|
|
||||||
|
if not raw_users:
|
||||||
|
flash('Keine gültigen Benutzer in der CSV-Datei gefunden. Bitte prüfen Sie das Format.', 'error')
|
||||||
|
return redirect(url_for('register'))
|
||||||
|
|
||||||
|
created_users = []
|
||||||
|
|
||||||
|
for entry in raw_users:
|
||||||
|
name = entry['name']
|
||||||
|
last_name = entry['last_name']
|
||||||
|
|
||||||
|
if not name or not last_name:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Benutzernamen & Passwort generieren
|
||||||
|
username = us.build_unique_username_from_name(name, last_name)
|
||||||
|
password = generate_compliant_password(16)
|
||||||
|
|
||||||
|
# In DB speichern
|
||||||
|
success = us.add_user(
|
||||||
|
username=username,
|
||||||
|
password=password,
|
||||||
|
name=name,
|
||||||
|
last_name=last_name,
|
||||||
|
is_student=False,
|
||||||
|
student_card_id=None,
|
||||||
|
max_borrow_days=None,
|
||||||
|
permission_preset=permission_preset,
|
||||||
|
)
|
||||||
|
|
||||||
|
if success:
|
||||||
|
created_users.append({
|
||||||
|
'name': name,
|
||||||
|
'last_name': last_name,
|
||||||
|
'username': username,
|
||||||
|
'password': password
|
||||||
|
})
|
||||||
|
|
||||||
|
if not created_users:
|
||||||
|
flash('Fehler beim Erstellen der Benutzer aus der CSV.', 'error')
|
||||||
|
return redirect(url_for('register'))
|
||||||
|
|
||||||
|
# PDF mit Zugangsdaten generieren
|
||||||
|
pdf_buffer = generate_credentials_pdf(created_users)
|
||||||
|
|
||||||
|
return send_file(
|
||||||
|
pdf_buffer,
|
||||||
|
as_attachment=True,
|
||||||
|
download_name='benutzer_zugangsdaten.pdf',
|
||||||
|
mimetype='application/pdf'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/user_del', methods=['GET'])
|
@app.route('/user_del', methods=['GET'])
|
||||||
def user_del():
|
def user_del():
|
||||||
"""
|
"""
|
||||||
User deletion interface.
|
User deletion interface.
|
||||||
Displays a list of users that can be deleted by an administrator.
|
Displays a list of users that can be deleted by an administrator.
|
||||||
Prevents self-deletion by hiding the current user from the list.
|
Prevents self-deletion by hiding the current user from the list.
|
||||||
|
|
||||||
Returns:
|
|
||||||
flask.Response: Rendered template with user list or redirect
|
|
||||||
"""
|
"""
|
||||||
if 'username' not in session:
|
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 Adresse zu nutzen. Bitte melden Sie sich an!',
|
||||||
|
'error')
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
|
# Abruf aller User (falls get_all_users tenant_id unterstützt, kann diese hier übergeben werden)
|
||||||
all_users = us.get_all_users()
|
all_users = us.get_all_users()
|
||||||
|
|
||||||
users_list = []
|
users_list = []
|
||||||
for user in all_users:
|
for user in all_users:
|
||||||
username = None
|
username = user.get('Username')
|
||||||
for field in ['Username']:
|
|
||||||
if field in user:
|
|
||||||
username = user[field]
|
|
||||||
break
|
|
||||||
|
|
||||||
if username and username != session['username']:
|
if username and username != session.get('username'):
|
||||||
try:
|
try:
|
||||||
permissions_payload = us.get_effective_permissions(username)
|
permissions_payload = us.get_effective_permissions(username)
|
||||||
except Exception:
|
except Exception:
|
||||||
permissions_payload = us.build_default_permission_payload('standard_user')
|
permissions_payload = us.build_default_permission_payload('standard_user')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
name = us.get_name(username)
|
name = us.get_name(username)
|
||||||
last_name = us.get_last_name(username)
|
last_name = us.get_last_name(username)
|
||||||
@@ -7914,12 +7984,13 @@ def user_del():
|
|||||||
fullname = last_name
|
fullname = last_name
|
||||||
else:
|
else:
|
||||||
fullname = None
|
fullname = None
|
||||||
except:
|
except Exception:
|
||||||
name = ""
|
name = ""
|
||||||
last_name = ""
|
last_name = ""
|
||||||
fullname = None
|
fullname = None
|
||||||
|
|
||||||
users_list.append({
|
users_list.append({
|
||||||
'username': decrypt_text(username),
|
'username': username, # Username ist plain in DB, kein decrypt_text() notwendig
|
||||||
'admin': user.get('Admin', False),
|
'admin': user.get('Admin', False),
|
||||||
'fullname': fullname,
|
'fullname': fullname,
|
||||||
'name': name,
|
'name': name,
|
||||||
@@ -7941,14 +8012,11 @@ def user_del():
|
|||||||
def delete_user():
|
def delete_user():
|
||||||
"""
|
"""
|
||||||
Process user deletion request.
|
Process user deletion request.
|
||||||
Deletes a specified user from the system.
|
Deletes a specified user from the system directly via the tenant db.
|
||||||
Includes safety checks to prevent self-deletion.
|
Includes safety checks to prevent self-deletion.
|
||||||
|
|
||||||
Returns:
|
|
||||||
flask.Response: Redirect to the user deletion interface with status
|
|
||||||
"""
|
"""
|
||||||
if 'username' not in session:
|
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, diese Aktion auszuführen. Bitte melden Sie sich an!', 'error')
|
||||||
return redirect(url_for('login'))
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
username = request.form.get('username')
|
username = request.form.get('username')
|
||||||
@@ -7956,53 +8024,60 @@ def delete_user():
|
|||||||
flash('Kein Benutzer ausgewählt', 'error')
|
flash('Kein Benutzer ausgewählt', 'error')
|
||||||
return redirect(url_for('user_del'))
|
return redirect(url_for('user_del'))
|
||||||
|
|
||||||
# Prevent self-deletion
|
if username == session.get('username'):
|
||||||
if username == session['username']:
|
|
||||||
flash('Sie können Ihr eigenes Konto nicht löschen', 'error')
|
flash('Sie können Ihr eigenes Konto nicht löschen', 'error')
|
||||||
return redirect(url_for('user_del'))
|
return redirect(url_for('user_del'))
|
||||||
|
|
||||||
# Reset this user's borrowings and free items before deleting the user
|
|
||||||
try:
|
try:
|
||||||
client = MongoClient(MONGODB_HOST, MONGODB_PORT)
|
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
||||||
db = client[MONGODB_DB]
|
tenant_id = session.get('tenant_id')
|
||||||
|
db = us._get_tenant_db(client, tenant_id)
|
||||||
|
|
||||||
ausleihungen = db['ausleihungen']
|
ausleihungen = db['ausleihungen']
|
||||||
items_col = db['items']
|
items_col = db['items']
|
||||||
|
users_col = db['users'] # Direkter Zugriff auf die User-Collection
|
||||||
|
|
||||||
now = datetime.datetime.now()
|
now = datetime.datetime.now()
|
||||||
|
|
||||||
# Complete all active borrowings of this user
|
# 1. Aktive Ausleihen abschließen
|
||||||
ausleihungen.update_many(
|
ausleihungen.update_many(
|
||||||
{'User': username, 'Status': 'active'},
|
{'User': username, 'Status': 'active'},
|
||||||
{'$set': {'Status': 'completed', 'End': now, 'LastUpdated': now}}
|
{'$set': {'Status': 'completed', 'End': now, 'LastUpdated': now}}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cancel all planned borrowings of this user
|
# 2. Geplante Ausleihen stornieren
|
||||||
ausleihungen.update_many(
|
ausleihungen.update_many(
|
||||||
{'User': username, 'Status': 'planned'},
|
{'User': username, 'Status': 'planned'},
|
||||||
{'$set': {'Status': 'cancelled', 'LastUpdated': now}}
|
{'$set': {'Status': 'cancelled', 'LastUpdated': now}}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Free all items currently associated with this user
|
# 3. Inventar wieder verfügbar machen
|
||||||
items_col.update_many(
|
items_col.update_many(
|
||||||
{'User': username},
|
{'User': username},
|
||||||
{'$set': {'Verfuegbar': True, 'LastUpdated': now}, '$unset': {'User': ""}}
|
{'$set': {'Verfuegbar': True, 'LastUpdated': now}, '$unset': {'User': ""}}
|
||||||
)
|
)
|
||||||
|
|
||||||
client.close()
|
# 4. Den Benutzer direkt in der überprüften DB-Verbindung löschen
|
||||||
except Exception as e:
|
# Achte auf die exakte Großschreibung 'Username' (so wie in add_user definiert)
|
||||||
app.logger.error(f"Error resetting borrowings for user {encrypt_text(username)}: {e}")
|
delete_result = users_col.delete_one({'Username': username})
|
||||||
flash(f'Warnung: Ausleihungen/Reservierungen für {username} konnten nicht vollständig zurückgesetzt werden', 'warning')
|
|
||||||
|
|
||||||
# Delete the user
|
# 5. Explizite Erfolgskontrolle
|
||||||
try:
|
if delete_result.deleted_count > 0:
|
||||||
us.delete_user(username)
|
|
||||||
flash(f'Benutzer {username} erfolgreich gelöscht', 'success')
|
flash(f'Benutzer {username} erfolgreich gelöscht', 'success')
|
||||||
|
else:
|
||||||
|
# Fallback, falls der Nutzer nicht gefunden wurde (Fehlervermeidung)
|
||||||
|
flash(f'Löschen fehlgeschlagen: Benutzer {username} wurde in der Datenbank nicht gefunden.', 'error')
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
app.logger.error(f"Error deleting user {encrypt_text(username)}: {e}")
|
app.logger.error(f"Error resetting borrowings or deleting user {username}: {e}")
|
||||||
flash('Fehler beim Löschen des Benutzers', 'error')
|
flash('Kritischer Fehler beim Löschen des Benutzers', 'error')
|
||||||
|
finally:
|
||||||
|
# Garantiert, dass die DB-Verbindung geschlossen wird
|
||||||
|
if 'client' in locals():
|
||||||
|
client.close()
|
||||||
|
|
||||||
return redirect(url_for('user_del'))
|
return redirect(url_for('user_del'))
|
||||||
|
|
||||||
|
|
||||||
@app.route('/admin/borrowings')
|
@app.route('/admin/borrowings')
|
||||||
def admin_borrowings():
|
def admin_borrowings():
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -29,16 +29,20 @@ import Web.modules.inventarsystem.data_protection as dp
|
|||||||
|
|
||||||
def is_library_item(item):
|
def is_library_item(item):
|
||||||
"""
|
"""
|
||||||
Determines if an item belongs to the library system.
|
Ermittelt zuverlässig, ob ein Objekt zur Bibliothek gehört.
|
||||||
Returns False for 'other', None, or empty ItemType (Inventory item).
|
Gibt True zurück, wenn ItemType ein Medientyp ist (Buch, Schulbuch, CD, DVD etc.)
|
||||||
Returns True for any specific library type ('Buch', 'CD', 'DVD', etc.).
|
ODER wenn is_library explizit True ist.
|
||||||
"""
|
"""
|
||||||
if not item:
|
if not item:
|
||||||
return False
|
return False
|
||||||
item_type = item.get('ItemType', 'other')
|
|
||||||
if not item_type:
|
# 1. Prüfe zuerst den Medientyp (ItemType)
|
||||||
return False
|
item_type = str(item.get('ItemType', '') or '').strip().lower()
|
||||||
return str(item_type).strip().lower() != 'other'
|
if item_type and item_type not in ['other', 'general', 'none', 'null']:
|
||||||
|
return True
|
||||||
|
|
||||||
|
# 2. Falls ItemType 'other' ist, prüfe das is_library Flag
|
||||||
|
return bool(item.get('is_library', False))
|
||||||
|
|
||||||
def safe_decrypt_user(encrypted_user):
|
def safe_decrypt_user(encrypted_user):
|
||||||
"""
|
"""
|
||||||
@@ -264,7 +268,10 @@ def get_group_item_ids(id):
|
|||||||
|
|
||||||
|
|
||||||
def update_item(id, name, ort, beschreibung, images, verfuegbar, filter1, filter2, filter3,
|
def update_item(id, name, ort, beschreibung, images, verfuegbar, filter1, filter2, filter3,
|
||||||
ansch_jahr, ansch_kost, code_4, reservierbar, isbn=None, item_type='general'):
|
ansch_jahr, ansch_kost, code_4, reservierbar, isbn="", item_type='other', library_category=""):
|
||||||
|
"""
|
||||||
|
Aktualisiert ein Objekt in MongoDB und setzt is_library korrekt basierend auf dem Medientyp.
|
||||||
|
"""
|
||||||
try:
|
try:
|
||||||
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
client = MongoClient(cfg.MONGODB_HOST, cfg.MONGODB_PORT)
|
||||||
db = client[cfg.MONGODB_DB]
|
db = client[cfg.MONGODB_DB]
|
||||||
@@ -272,29 +279,35 @@ def update_item(id, name, ort, beschreibung, images, verfuegbar, filter1, filter
|
|||||||
|
|
||||||
old_item = items.find_one({'_id': ObjectId(id)})
|
old_item = items.find_one({'_id': ObjectId(id)})
|
||||||
if not old_item:
|
if not old_item:
|
||||||
|
client.close()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
series_group_id = old_item.get('SeriesGroupId')
|
series_group_id = old_item.get('SeriesGroupId')
|
||||||
|
|
||||||
|
# is_library automatisch anhand des neuen item_type bestimmen
|
||||||
|
is_lib = is_library_item({'ItemType': item_type})
|
||||||
|
|
||||||
shared_update = {
|
shared_update = {
|
||||||
'Name': name,
|
'Name': name,
|
||||||
'Ort': ort,
|
'Ort': ort,
|
||||||
'Beschreibung': beschreibung,
|
'Beschreibung': beschreibung,
|
||||||
'Images': images,
|
'Images': images if isinstance(images, list) else [],
|
||||||
'Filter': filter1,
|
'Filter': filter1 if isinstance(filter1, list) else [],
|
||||||
'Filter2': filter2,
|
'Filter2': filter2 if isinstance(filter2, list) else [],
|
||||||
'Filter3': filter3,
|
'Filter3': filter3 if isinstance(filter3, list) else [],
|
||||||
'Anschaffungsjahr': ansch_jahr,
|
'Anschaffungsjahr': ansch_jahr,
|
||||||
'Anschaffungskosten': ansch_kost,
|
'Anschaffungskosten': ansch_kost,
|
||||||
'Reservierbar': reservierbar,
|
'Reservierbar': bool(reservierbar),
|
||||||
'ISBN': isbn,
|
'ISBN': str(isbn) if isbn else '',
|
||||||
'ItemType': item_type,
|
'ItemType': item_type,
|
||||||
'Verfuegbar': verfuegbar,
|
'is_library': is_lib,
|
||||||
|
'library_category': library_category,
|
||||||
|
'Verfuegbar': bool(verfuegbar),
|
||||||
'LastUpdated': datetime.datetime.now()
|
'LastUpdated': datetime.datetime.now()
|
||||||
}
|
}
|
||||||
|
|
||||||
specific_update = shared_update.copy()
|
specific_update = shared_update.copy()
|
||||||
specific_update['Code_4'] = code_4
|
specific_update['Code_4'] = str(code_4) if code_4 else ''
|
||||||
|
|
||||||
items.update_one({'_id': ObjectId(id)}, {'$set': specific_update})
|
items.update_one({'_id': ObjectId(id)}, {'$set': specific_update})
|
||||||
|
|
||||||
|
|||||||
@@ -1,288 +0,0 @@
|
|||||||
<!--
|
|
||||||
Copyright 2025-2026 AIIrondev
|
|
||||||
|
|
||||||
Licensed under the Inventarsystem EULA (Endbenutzer-Lizenzvertrag).
|
|
||||||
See Legal/LICENSE for the full license text.
|
|
||||||
Unauthorized commercial use, SaaS hosting, or removal of branding is prohibited.
|
|
||||||
For commercial licensing inquiries: https://github.com/AIIrondev
|
|
||||||
-->
|
|
||||||
<!-- Edit Item Functions -->
|
|
||||||
<script>
|
|
||||||
// Function to check if a file is a video
|
|
||||||
function isVideoFile(filename) {
|
|
||||||
const videoExtensions = ['.mp4', '.mov', '.avi', '.mkv', '.webm', '.flv', '.m4v', '.3gp'];
|
|
||||||
const extension = filename.toLowerCase().substring(filename.lastIndexOf('.'));
|
|
||||||
return videoExtensions.includes(extension);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load location options for edit modal
|
|
||||||
function loadLocationOptions() {
|
|
||||||
fetch('/get_predefined_locations')
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
const ortSelect = document.getElementById('edit-location');
|
|
||||||
if (ortSelect) {
|
|
||||||
// Clear existing options except the first one
|
|
||||||
while (ortSelect.children.length > 1) {
|
|
||||||
ortSelect.removeChild(ortSelect.lastChild);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new options - data.locations contains the array
|
|
||||||
data.locations.forEach(location => {
|
|
||||||
const option = document.createElement('option');
|
|
||||||
option.value = location;
|
|
||||||
option.textContent = location;
|
|
||||||
ortSelect.appendChild(option);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error loading location options:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Edit modal functions
|
|
||||||
function openEditModal(itemId) {
|
|
||||||
if (typeof openEditModalFromServer === 'function') {
|
|
||||||
openEditModalFromServer(itemId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find the item data from allItems array
|
|
||||||
const item = allItems.find(i => i._id === itemId);
|
|
||||||
if (!item) {
|
|
||||||
console.error('Item not found:', itemId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate the edit form with current item data
|
|
||||||
document.getElementById('edit-item-id').value = item._id;
|
|
||||||
document.getElementById('edit-name').value = item.Name || '';
|
|
||||||
document.getElementById('edit-description').value = item.Beschreibung || '';
|
|
||||||
document.getElementById('edit-code4').value = item.Code_4 || '';
|
|
||||||
document.getElementById('edit-year').value = item.Anschaffungsjahr || '';
|
|
||||||
document.getElementById('edit-cost').value = item.Anschaffungskosten || '';
|
|
||||||
|
|
||||||
// Set reservable status (default to true if undefined)
|
|
||||||
const reservierbarCheckbox = document.getElementById('edit-reservierbar');
|
|
||||||
if (reservierbarCheckbox) {
|
|
||||||
reservierbarCheckbox.checked = item.Reservierbar !== false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load location options
|
|
||||||
loadLocationOptions();
|
|
||||||
|
|
||||||
// Set the current location
|
|
||||||
setTimeout(() => {
|
|
||||||
const locationSelect = document.getElementById('edit-location');
|
|
||||||
if (locationSelect && item.Ort) {
|
|
||||||
locationSelect.value = item.Ort;
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
// Handle filter arrays - set current values
|
|
||||||
const filter1Array = Array.isArray(item.Filter) ? item.Filter : (item.Filter ? [item.Filter] : []);
|
|
||||||
const filter2Array = Array.isArray(item.Filter2) ? item.Filter2 : (item.Filter2 ? [item.Filter2] : []);
|
|
||||||
const filter3Array = Array.isArray(item.Filter3) ? item.Filter3 : (item.Filter3 ? [item.Filter3] : []);
|
|
||||||
|
|
||||||
// Set filter dropdowns (up to 4 each)
|
|
||||||
for (let i = 1; i <= 4; i++) {
|
|
||||||
// Filter 1
|
|
||||||
const filter1Select = document.getElementById(`edit-filter1-${i}`);
|
|
||||||
if (filter1Select) {
|
|
||||||
filter1Select.value = filter1Array[i-1] || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter 2
|
|
||||||
const filter2Select = document.getElementById(`edit-filter2-${i}`);
|
|
||||||
if (filter2Select) {
|
|
||||||
filter2Select.value = filter2Array[i-1] || '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter 3
|
|
||||||
const filter3Select = document.getElementById(`edit-filter3-${i}`);
|
|
||||||
if (filter3Select) {
|
|
||||||
filter3Select.value = filter3Array[i-1] || '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Populate existing images
|
|
||||||
populateExistingImages(item.Images || []);
|
|
||||||
|
|
||||||
// Show the modal
|
|
||||||
document.getElementById('edit-modal').style.display = 'block';
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeEditModal() {
|
|
||||||
document.getElementById('edit-modal').style.display = 'none';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to add new location (for edit modal)
|
|
||||||
function addNewLocation(prefix) {
|
|
||||||
// Use different input IDs based on whether we're in edit mode
|
|
||||||
const inputId = prefix === 'edit' ? 'edit-new-location-input' : 'new-location-input';
|
|
||||||
const selectId = prefix === 'edit' ? 'edit-location' : 'ort';
|
|
||||||
|
|
||||||
const newLocationInput = document.getElementById(inputId);
|
|
||||||
const newLocation = newLocationInput.value.trim();
|
|
||||||
|
|
||||||
if (!newLocation) {
|
|
||||||
alert('Bitte geben Sie einen Ort ein.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add to dropdown
|
|
||||||
const ortSelect = document.getElementById(selectId);
|
|
||||||
const option = document.createElement('option');
|
|
||||||
option.value = newLocation;
|
|
||||||
option.textContent = newLocation;
|
|
||||||
ortSelect.appendChild(option);
|
|
||||||
ortSelect.value = newLocation;
|
|
||||||
|
|
||||||
// Hide the input field
|
|
||||||
document.getElementById(prefix + '-new-location-container').style.display = 'none';
|
|
||||||
newLocationInput.value = '';
|
|
||||||
|
|
||||||
// Save to server
|
|
||||||
fetch('/add_location_value', {
|
|
||||||
method: 'POST',
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/x-www-form-urlencoded',
|
|
||||||
},
|
|
||||||
body: 'value=' + encodeURIComponent(newLocation)
|
|
||||||
})
|
|
||||||
.then(response => response.json())
|
|
||||||
.then(data => {
|
|
||||||
if (!data.success) {
|
|
||||||
console.warn('Failed to save location to server:', data.error);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error saving location:', error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to cancel adding a new location
|
|
||||||
function cancelAddLocation(prefix) {
|
|
||||||
const containerId = prefix === 'edit' ? 'edit-new-location-container' : 'new-location-container';
|
|
||||||
const inputId = prefix === 'edit' ? 'edit-new-location-input' : 'new-location-input';
|
|
||||||
document.getElementById(containerId).style.display = 'none';
|
|
||||||
document.getElementById(inputId).value = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to populate existing images in edit modal
|
|
||||||
function populateExistingImages(images) {
|
|
||||||
const previewContainer = document.getElementById('edit-image-preview-container');
|
|
||||||
if (!previewContainer) return;
|
|
||||||
|
|
||||||
previewContainer.innerHTML = '';
|
|
||||||
|
|
||||||
if (!images || images.length === 0) {
|
|
||||||
previewContainer.innerHTML = '<p>Keine Bilder vorhanden</p>';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
images.forEach((imageName, index) => {
|
|
||||||
const preview = document.createElement('div');
|
|
||||||
preview.className = 'image-preview-item';
|
|
||||||
|
|
||||||
const isVideo = isVideoFile(imageName);
|
|
||||||
const mediaHtml = isVideo
|
|
||||||
? `<video src="/uploads/${imageName}" style="max-width: 150px; max-height: 150px; object-fit: cover;" controls preload="metadata"></video>`
|
|
||||||
: `<img src="/uploads/${imageName}" alt="Image ${index + 1}" style="max-width: 150px; max-height: 150px; object-fit: cover;">`;
|
|
||||||
|
|
||||||
preview.innerHTML = `
|
|
||||||
${mediaHtml}
|
|
||||||
<div class="image-controls">
|
|
||||||
<button type="button" onclick="removeExistingImage('${imageName}', this)" style="background: #dc3545; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer; margin-left: 10px;">Entfernen</button>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
previewContainer.appendChild(preview);
|
|
||||||
|
|
||||||
// Add hidden input for the image
|
|
||||||
const hiddenInput = document.createElement('input');
|
|
||||||
hiddenInput.type = 'hidden';
|
|
||||||
hiddenInput.name = 'existing_images';
|
|
||||||
hiddenInput.value = imageName;
|
|
||||||
previewContainer.appendChild(hiddenInput);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Function to remove an existing image
|
|
||||||
function removeExistingImage(imageName, button) {
|
|
||||||
try {
|
|
||||||
// First, determine context - are we in edit mode or main view?
|
|
||||||
const inEditMode = !!document.getElementById('edit-item-form');
|
|
||||||
|
|
||||||
// Always remove the preview element (works in both contexts)
|
|
||||||
const previewItem = button.closest('.image-preview-item');
|
|
||||||
if (previewItem) {
|
|
||||||
previewItem.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
// If we're in edit mode, handle form inputs
|
|
||||||
if (inEditMode) {
|
|
||||||
// Find and remove the corresponding hidden input in the edit form
|
|
||||||
const editForm = document.getElementById('edit-item-form');
|
|
||||||
|
|
||||||
if (editForm) {
|
|
||||||
// Remove from existing images
|
|
||||||
const existingInputs = editForm.querySelectorAll('input[name="existing_images"]');
|
|
||||||
existingInputs.forEach(input => {
|
|
||||||
if (input.value === imageName) {
|
|
||||||
input.remove();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Add to removed images
|
|
||||||
const removedInput = document.createElement('input');
|
|
||||||
removedInput.type = 'hidden';
|
|
||||||
removedInput.name = 'removed_images';
|
|
||||||
removedInput.value = imageName;
|
|
||||||
editForm.appendChild(removedInput);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// In main view, we may need different logic
|
|
||||||
console.log(`Image ${imageName} removed from display in main view`);
|
|
||||||
// Add any main view specific handling here
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error(`Error in removeExistingImage: ${error.message}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate file types for image uploads
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
// Check if we're in the edit item context
|
|
||||||
if (!document.getElementById('edit-item-form')) {
|
|
||||||
console.log('Edit item form not found, skipping edit item functions initialization');
|
|
||||||
return; // Exit early if we're not in the edit item context
|
|
||||||
}
|
|
||||||
|
|
||||||
const imageInput = document.getElementById('edit-new-images');
|
|
||||||
const previewContainer = document.getElementById('edit-image-preview-container');
|
|
||||||
|
|
||||||
if (imageInput) {
|
|
||||||
imageInput.addEventListener('change', function(e) {
|
|
||||||
// Validate file types before preview
|
|
||||||
const allowedTypes = ['image/jpeg', 'image/jpg', 'image/png', 'image/gif',
|
|
||||||
'video/mp4', 'video/quicktime', 'video/x-msvideo', 'video/x-matroska',
|
|
||||||
'video/webm', 'video/x-flv', 'video/mp4', 'video/3gpp'];
|
|
||||||
const files = this.files;
|
|
||||||
let hasInvalidFile = false;
|
|
||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
|
||||||
if (!allowedTypes.includes(files[i].type)) {
|
|
||||||
hasInvalidFile = true;
|
|
||||||
// Clear the file input to prevent submission
|
|
||||||
this.value = '';
|
|
||||||
alert('Fehler: Datei "' + files[i].name + '" hat ein nicht unterstütztes Format. Erlaubte Formate: JPG, JPEG, PNG, GIF, MP4, MOV, AVI, MKV, WEBM, FLV, M4V, 3GP');
|
|
||||||
return; // Stop processing
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Continue with regular preview handling...
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@@ -103,7 +103,7 @@
|
|||||||
background-color: #0056b3;
|
background-color: #0056b3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scanner Video Canvas */
|
/* Scanner Elements */
|
||||||
#code4-scanner video, #code4-scanner canvas,
|
#code4-scanner video, #code4-scanner canvas,
|
||||||
#isbn-scanner video, #isbn-scanner canvas {
|
#isbn-scanner video, #isbn-scanner canvas {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@@ -197,7 +197,7 @@
|
|||||||
<input type="hidden" name="item_id" value="{{ item._id }}">
|
<input type="hidden" name="item_id" value="{{ item._id }}">
|
||||||
|
|
||||||
{% if show_library_features %}
|
{% if show_library_features %}
|
||||||
<!-- ================= LIBRARY MODE FIELDS ================= -->
|
<!-- ================= LIBRARY SPECIFIC FIELDS ================= -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="isbn">ISBN / Barcode:</label>
|
<label for="isbn">ISBN / Barcode:</label>
|
||||||
<div class="isbn-input-group">
|
<div class="isbn-input-group">
|
||||||
@@ -209,9 +209,26 @@
|
|||||||
<small id="isbn-scan-status" style="display:block; color:#666; margin-top:6px;"></small>
|
<small id="isbn-scan-status" style="display:block; color:#666; margin-top:6px;"></small>
|
||||||
<div id="book-info-container"></div>
|
<div id="book-info-container"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="filter-inputs" style="margin-bottom: 20px;">
|
||||||
|
<h3>Medientyp</h3>
|
||||||
|
<div class="form-group">
|
||||||
|
<select name="item_type_input" id="item_type_input">
|
||||||
|
<option value="Buch" {% if item.ItemType == 'Buch' %}selected{% endif %}>Buch</option>
|
||||||
|
<option value="Schulbuch" {% if item.ItemType == 'Schulbuch' %}selected{% endif %}>Schulbuch</option>
|
||||||
|
<option value="CD" {% if item.ItemType == 'CD' %}selected{% endif %}>CD</option>
|
||||||
|
<option value="DVD" {% if item.ItemType == 'DVD' %}selected{% endif %}>DVD</option>
|
||||||
|
<option value="Sonstiges" {% if item.ItemType == 'Sonstiges' %}selected{% endif %}>Sonstiges</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<h3>Bibliotheks-Kategorie:</h3>
|
||||||
|
<div class="form-group">
|
||||||
|
<input type="text" name="library_category" id="library_category" value="{{ item.library_category|default('') }}" placeholder="z.B. Belletristik, Sachbücher, etc.">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<!-- ================= COMMON FIELDS ================= -->
|
<!-- ================= COMMON CORE FIELDS ================= -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="name">Name / Titel:</label>
|
<label for="name">Name / Titel:</label>
|
||||||
<input type="text" id="name" name="name" value="{{ item.Name|default('') }}" required>
|
<input type="text" id="name" name="name" value="{{ item.Name|default('') }}" required>
|
||||||
@@ -254,26 +271,8 @@
|
|||||||
<small style="display:block; color:#666; margin-top: 5px;">Der Basis-Code steht oben. Alle weiteren Gruppenmitglieder werden hier untereinander aufgeführt.</small>
|
<small style="display:block; color:#666; margin-top: 5px;">Der Basis-Code steht oben. Alle weiteren Gruppenmitglieder werden hier untereinander aufgeführt.</small>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if show_library_features %}
|
{% if not show_library_features %}
|
||||||
<!-- ================= LIBRARY CATEGORIZATION ================= -->
|
<!-- ================= SYSTEM FILTERS 1-3 (INVENTORY / OTHER ITEMS ONLY) ================= -->
|
||||||
<div class="filter-inputs">
|
|
||||||
<h3>Medientyp</h3>
|
|
||||||
<div class="form-group">
|
|
||||||
<select name="item_type_input" id="item_type_input">
|
|
||||||
<option value="Buch" {% if item.ItemType == 'Buch' %}selected{% endif %}>Buch</option>
|
|
||||||
<option value="Schulbuch" {% if item.ItemType == 'Schulbuch' %}selected{% endif %}>Schulbuch</option>
|
|
||||||
<option value="CD" {% if item.ItemType == 'CD' %}selected{% endif %}>CD</option>
|
|
||||||
<option value="DVD" {% if item.ItemType == 'DVD' %}selected{% endif %}>DVD</option>
|
|
||||||
<option value="Sonstiges" {% if item.ItemType == 'Sonstiges' %}selected{% endif %}>Sonstiges</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<h3>Kategorie / Fach:</h3>
|
|
||||||
<div class="form-group">
|
|
||||||
<input type="text" name="library_category" id="library_category" value="{{ item.library_category|default('') }}" placeholder="z.B. Belletristik, Sachbücher, etc.">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% else %}
|
|
||||||
<!-- ================= INVENTORY FILTERS (1-3) ================= -->
|
|
||||||
<div class="filter-inputs">
|
<div class="filter-inputs">
|
||||||
<h3>Unterrichtsfach (Filter 1):</h3>
|
<h3>Unterrichtsfach (Filter 1):</h3>
|
||||||
<div class="multi-filter">
|
<div class="multi-filter">
|
||||||
@@ -358,13 +357,11 @@
|
|||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2/dist/quagga.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/@ericblade/quagga2/dist/quagga.js"></script>
|
||||||
<script>
|
<script>
|
||||||
const libraryModuleEnabled = {{ 'true' if show_library_features else 'false' }};
|
|
||||||
let scannerRunning = false;
|
let scannerRunning = false;
|
||||||
let activeScannerCallback = null;
|
let activeScannerCallback = null;
|
||||||
let code4LastScanned = '';
|
let code4LastScanned = '';
|
||||||
let code4LastScannedAt = 0;
|
let code4LastScannedAt = 0;
|
||||||
|
|
||||||
// Load filter dropdown options and pre-select current item values
|
|
||||||
function loadAndSelectFilterValues(filterNumber) {
|
function loadAndSelectFilterValues(filterNumber) {
|
||||||
fetch(`/get_predefined_filter_values/${filterNumber}`)
|
fetch(`/get_predefined_filter_values/${filterNumber}`)
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
@@ -383,7 +380,6 @@
|
|||||||
select.appendChild(opt);
|
select.appendChild(opt);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add custom option if the item has a value not in predefined list
|
|
||||||
if (selectedValue && !Array.from(select.options).some(o => o.value === selectedValue)) {
|
if (selectedValue && !Array.from(select.options).some(o => o.value === selectedValue)) {
|
||||||
const customOpt = document.createElement('option');
|
const customOpt = document.createElement('option');
|
||||||
customOpt.value = selectedValue;
|
customOpt.value = selectedValue;
|
||||||
@@ -397,7 +393,6 @@
|
|||||||
.catch(err => console.error(`Error loading Filter ${filterNumber}:`, err));
|
.catch(err => console.error(`Error loading Filter ${filterNumber}:`, err));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load locations
|
|
||||||
function loadLocationOptions() {
|
function loadLocationOptions() {
|
||||||
fetch('/get_predefined_locations')
|
fetch('/get_predefined_locations')
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
@@ -420,7 +415,6 @@
|
|||||||
.catch(err => console.error('Error loading locations:', err));
|
.catch(err => console.error('Error loading locations:', err));
|
||||||
}
|
}
|
||||||
|
|
||||||
// New location handler
|
|
||||||
function addNewLocation() {
|
function addNewLocation() {
|
||||||
const input = document.getElementById('new-location-input');
|
const input = document.getElementById('new-location-input');
|
||||||
const val = input.value.trim();
|
const val = input.value.trim();
|
||||||
@@ -440,7 +434,6 @@
|
|||||||
document.getElementById('new-location-input').value = '';
|
document.getElementById('new-location-input').value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Quagga Barcode Scanner Engine
|
|
||||||
function runEngineInitialization(targetSelector, activeCallback, completionMsg, errorStatusSetter) {
|
function runEngineInitialization(targetSelector, activeCallback, completionMsg, errorStatusSetter) {
|
||||||
if (scannerRunning) { Quagga.stop(); scannerRunning = false; }
|
if (scannerRunning) { Quagga.stop(); scannerRunning = false; }
|
||||||
activeScannerCallback = activeCallback;
|
activeScannerCallback = activeCallback;
|
||||||
@@ -497,7 +490,8 @@
|
|||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
loadLocationOptions();
|
loadLocationOptions();
|
||||||
|
|
||||||
if (!libraryModuleEnabled) {
|
// Load Filter options if elements exist on page
|
||||||
|
if (document.getElementById('filter1-1')) {
|
||||||
loadAndSelectFilterValues(1);
|
loadAndSelectFilterValues(1);
|
||||||
loadAndSelectFilterValues(2);
|
loadAndSelectFilterValues(2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1951,11 +1951,6 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Edit new location container */
|
|
||||||
.edit-new-location-container {
|
|
||||||
display: none;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Modal dialog styling */
|
/* Modal dialog styling */
|
||||||
.modal-dialog-white {
|
.modal-dialog-white {
|
||||||
@@ -1969,11 +1964,6 @@
|
|||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Element text colors for better visibility */
|
|
||||||
.edit-button, .duplicate-button, .generate-qr-button {
|
|
||||||
color: var(--ui-title) !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Standardized button styles across the application */
|
/* Standardized button styles across the application */
|
||||||
.search-button, .scan-button, .filter-toggle, .clear-filter,
|
.search-button, .scan-button, .filter-toggle, .clear-filter,
|
||||||
.add-new-btn, .popup-close-button, .prev-image-button, .next-image-button,
|
.add-new-btn, .popup-close-button, .prev-image-button, .next-image-button,
|
||||||
@@ -2474,187 +2464,6 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Add the edit modal form -->
|
|
||||||
{% if current_permissions.actions.get('can_edit', False) %}
|
|
||||||
<div id="edit-modal" class="item-modal">
|
|
||||||
<div class="modal-content">
|
|
||||||
<span class="close-modal" onclick="closeEditModal()">×</span>
|
|
||||||
<h2>Objekt bearbeiten</h2>
|
|
||||||
<form id="edit-item-form" method="POST" enctype="multipart/form-data">
|
|
||||||
<input type="hidden" id="edit-item-id" name="id">
|
|
||||||
<div class="form-row">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-name">Name:</label>
|
|
||||||
<input type="text" id="edit-name" name="name" required>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-location">Ort:</label>
|
|
||||||
<select id="edit-location" name="ort" required>
|
|
||||||
<option value="">-- Bitte Ort auswählen --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
<button type="button" class="add-new-btn" id="edit-add-new-location-btn">
|
|
||||||
Neuen Ort hinzufügen
|
|
||||||
</button>
|
|
||||||
<div id="edit-new-location-container" class="edit-new-location-container">
|
|
||||||
<input type="text" id="edit-new-location-input" placeholder="Neuen Ort eingeben">
|
|
||||||
<button type="button" onclick="addNewLocation('edit')">Hinzufügen</button>
|
|
||||||
<button type="button" onclick="cancelAddLocation('edit')">Abbrechen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-description">Beschreibung:</label>
|
|
||||||
<textarea id="edit-description" name="beschreibung" required></textarea>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Updated filter inputs for edit form with dropdowns -->
|
|
||||||
<div class="filter-inputs">
|
|
||||||
<h3>Unterrichtsfach:</h3>
|
|
||||||
<div class="multi-filter">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter1-1">Wert 1:</label>
|
|
||||||
<select id="edit-filter1-1" name="filter" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Bitte auswählen --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter1-2">Wert 2:</label>
|
|
||||||
<select id="edit-filter1-2" name="filter" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Optional --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter1-3">Wert 3:</label>
|
|
||||||
<select id="edit-filter1-3" name="filter" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Optional --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter1-4">Wert 4:</label>
|
|
||||||
<select id="edit-filter1-4" name="filter" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Optional --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Jahrgangsstufe:</h3>
|
|
||||||
<div class="multi-filter">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter2-1">Wert 1:</label>
|
|
||||||
<select id="edit-filter2-1" name="filter2" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Bitte auswählen --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter2-2">Wert 2:</label>
|
|
||||||
<select id="edit-filter2-2" name="filter2" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Optional --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter2-3">Wert 3:</label>
|
|
||||||
<select id="edit-filter2-3" name="filter2" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Optional --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter2-4">Wert 4:</label>
|
|
||||||
<select id="edit-filter2-4" name="filter2" class="filter-dropdown-select">
|
|
||||||
<option value="">-- Optional --</option>
|
|
||||||
<!-- Options will be loaded by JavaScript -->
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<h3>Schlagwort:</h3>
|
|
||||||
<div class="multi-filter">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter3-1">Wert 1:</label>
|
|
||||||
<input type="text" id="edit-filter3-1" name="filter3">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter3-2">Wert 2:</label>
|
|
||||||
<input type="text" id="edit-filter3-2" name="filter3">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter3-3">Wert 3:</label>
|
|
||||||
<input type="text" id="edit-filter3-3" name="filter3">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-filter3-4">Wert 4:</label>
|
|
||||||
<input type="text" id="edit-filter3-4" name="filter3">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-year">Anschaffungsjahr:</label>
|
|
||||||
<input type="date" id="edit-year" name="anschaffungsjahr">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-cost">Anschaffungskosten (€):</label>
|
|
||||||
<input id="edit-cost" name="anschaffungskosten">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-code4">Code:</label>
|
|
||||||
<div style="display:flex; gap:8px; align-items:center; flex-wrap:wrap;">
|
|
||||||
<input id="edit-code4" name="code_4">
|
|
||||||
<button type="button" class="fetch-isbn-button" id="scan-edit-code-btn">Barcode scannen</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-reservierbar" style="display:inline-block; width:auto; margin-right:10px;">Reservierbar:</label>
|
|
||||||
<input type="checkbox" id="edit-reservierbar" name="reservierbar" style="width:auto;">
|
|
||||||
<small style="display:block; color:#666;">Wenn deaktiviert, kann der Artikel nicht im Voraus reserviert werden.</small>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- New section for managing images -->
|
|
||||||
<div class="form-group">
|
|
||||||
<label>Vorhandene Bilder:</label>
|
|
||||||
<div id="edit-existing-images" class="existing-images-container">
|
|
||||||
<!-- Existing images will be added here dynamically -->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-new-images">
|
|
||||||
<span>Neue Bilder/Videos hinzufügen:</span>
|
|
||||||
<span>(Bilder/Videos werden vom Original übernommen)</span>
|
|
||||||
</label>
|
|
||||||
<input type="file" id="edit-new-images" name="new_images" accept=".jpg, .jpeg, .png, .gif, .mp4, .mov, .avi, .mkv, .webm, .flv, .m4v, .3gp" multiple>
|
|
||||||
<div class="allowed-formats">Erlaubte Formate: JPG, JPEG, PNG, GIF, MP4, MOV, AVI, MKV, WEBM, FLV, M4V, 3GP</div>
|
|
||||||
<!-- Add image preview container -->
|
|
||||||
<div class="image-preview-container" id="edit-image-preview-container"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="edit-isbn">ISBN:</label>
|
|
||||||
<div class="isbn-input-group">
|
|
||||||
<input type="text" id="edit-isbn" name="isbn" placeholder="ISBN eingeben...">
|
|
||||||
<button type="button" class="fetch-isbn-button" id="scan-edit-isbn-btn">ISBN scannen</button>
|
|
||||||
<button type="button" class="fetch-isbn-button" onclick="fetchBookInfo('edit')">Buchinformationen abrufen</button>
|
|
||||||
</div>
|
|
||||||
<div id="edit-book-info-container" class="book-info-container"></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="form-actions">
|
|
||||||
<button type="submit" class="save-button">Speichern</button>
|
|
||||||
<button type="button" class="cancel-button" onclick="closeEditModal()">Abbrechen</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Schedule Appointment Modal -->
|
<!-- Schedule Appointment Modal -->
|
||||||
@@ -2889,58 +2698,6 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function scanIntoEditCode() {
|
|
||||||
const qrReader = document.getElementById('qr-reader');
|
|
||||||
const editCodeInput = document.getElementById('edit-code4');
|
|
||||||
const scanEditBtn = document.getElementById('scan-edit-code-btn');
|
|
||||||
if (!qrReader || !editCodeInput || !scanEditBtn) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle close if it's already running
|
|
||||||
if (isScanning && qrReader.style.display !== 'none') {
|
|
||||||
stopScanner();
|
|
||||||
scanEditBtn.textContent = 'Barcode scannen';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scanEditBtn.textContent = 'Scanner schließen';
|
|
||||||
|
|
||||||
// Start scanner with custom logic mapping to the Code input field
|
|
||||||
startScanner(function(decodedText) {
|
|
||||||
editCodeInput.value = decodedText;
|
|
||||||
validateCodeField(editCodeInput, document.getElementById('edit-item-id')?.value || null);
|
|
||||||
scanEditBtn.textContent = 'Barcode scannen';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function scanIntoEditIsbn() {
|
|
||||||
const qrReader = document.getElementById('qr-reader');
|
|
||||||
const editIsbnInput = document.getElementById('edit-isbn');
|
|
||||||
const scanIsbnBtn = document.getElementById('scan-edit-isbn-btn');
|
|
||||||
if (!qrReader || !editIsbnInput || !scanIsbnBtn) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Toggle close if it's already running
|
|
||||||
if (isScanning && qrReader.style.display !== 'none') {
|
|
||||||
stopScanner();
|
|
||||||
scanIsbnBtn.textContent = 'ISBN scannen';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scanIsbnBtn.textContent = 'Scanner schließen';
|
|
||||||
|
|
||||||
// Start scanner with custom logic mapping to the ISBN input field
|
|
||||||
startScanner(function(decodedText) {
|
|
||||||
editIsbnInput.value = decodedText;
|
|
||||||
scanIsbnBtn.textContent = 'ISBN scannen';
|
|
||||||
if (typeof fetchBookInfo === 'function') {
|
|
||||||
fetchBookInfo('edit');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function rebuildFilter3Options() {
|
function rebuildFilter3Options() {
|
||||||
if (!allItems) return;
|
if (!allItems) return;
|
||||||
|
|
||||||
@@ -3325,20 +3082,10 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
loadPredefinedFilterValues(2);
|
loadPredefinedFilterValues(2);
|
||||||
loadPredefinedFilterValues(3);
|
loadPredefinedFilterValues(3);
|
||||||
|
|
||||||
// Set up edit form submission
|
|
||||||
setupEditFormSubmission();
|
|
||||||
|
|
||||||
// Set up schedule form submission
|
// Set up schedule form submission
|
||||||
setupScheduleFormSubmission();
|
setupScheduleFormSubmission();
|
||||||
|
|
||||||
// Set up add new location buttons
|
|
||||||
const editAddLocationBtn = document.getElementById('edit-add-new-location-btn');
|
|
||||||
if (editAddLocationBtn) {
|
|
||||||
editAddLocationBtn.addEventListener('click', function() {
|
|
||||||
const container = document.getElementById('edit-new-location-container');
|
|
||||||
container.style.display = container.style.display === 'none' ? 'block' : 'none';
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find and attach event listener to all logout links
|
// Find and attach event listener to all logout links
|
||||||
const logoutLinks = document.querySelectorAll('a[href*="logout"]');
|
const logoutLinks = document.querySelectorAll('a[href*="logout"]');
|
||||||
@@ -3391,35 +3138,11 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
// Close modals when clicking outside
|
// Close modals when clicking outside
|
||||||
window.onclick = function(event) {
|
window.onclick = function(event) {
|
||||||
const itemModal = document.getElementById('item-modal');
|
const itemModal = document.getElementById('item-modal');
|
||||||
const editModal = document.getElementById('edit-modal');
|
|
||||||
|
|
||||||
if (event.target === itemModal) {
|
if (event.target === itemModal) {
|
||||||
itemModal.style.display = 'none';
|
itemModal.style.display = 'none';
|
||||||
}
|
}
|
||||||
if (event.target === editModal) {
|
|
||||||
editModal.style.display = 'none';
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set up code validation for edit form
|
|
||||||
const editCodeField = document.getElementById('edit-code4');
|
|
||||||
if (editCodeField) {
|
|
||||||
editCodeField.addEventListener('blur', function() {
|
|
||||||
const itemIdField = document.getElementById('edit-item-id');
|
|
||||||
const excludeId = itemIdField ? itemIdField.value : null;
|
|
||||||
validateCodeField(this, excludeId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const scanEditCodeBtn = document.getElementById('scan-edit-code-btn');
|
|
||||||
if (scanEditCodeBtn) {
|
|
||||||
scanEditCodeBtn.addEventListener('click', scanIntoEditCode);
|
|
||||||
}
|
|
||||||
|
|
||||||
const scanEditIsbnBtn = document.getElementById('scan-edit-isbn-btn');
|
|
||||||
if (scanEditIsbnBtn) {
|
|
||||||
scanEditIsbnBtn.addEventListener('click', scanIntoEditIsbn);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Function to load items from server
|
// Function to load items from server
|
||||||
@@ -4171,163 +3894,6 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function openEditModalForSelectedUnit(defaultItemId, selectId) {
|
|
||||||
let targetItemId = defaultItemId;
|
|
||||||
|
|
||||||
try {
|
|
||||||
const selectedUnit = selectId ? document.getElementById(selectId) : null;
|
|
||||||
if (selectedUnit && selectedUnit.value) {
|
|
||||||
targetItemId = selectedUnit.value;
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
// Keep default item id as fallback.
|
|
||||||
}
|
|
||||||
|
|
||||||
openEditModalFromServer(targetItemId);
|
|
||||||
}
|
|
||||||
|
|
||||||
function closeEditModal() {
|
|
||||||
const editModal = document.getElementById('edit-modal');
|
|
||||||
if (editModal) {
|
|
||||||
editModal.style.display = 'none';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function openEditModalFromServer(itemId) {
|
|
||||||
const editModal = document.getElementById('edit-modal');
|
|
||||||
if (!editModal) {
|
|
||||||
console.error('Edit modal nicht gefunden');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('DEBUG: openEditModal called with itemId:', itemId);
|
|
||||||
|
|
||||||
// Fetch the item data from the backend
|
|
||||||
fetch(`/get_item/${itemId}`)
|
|
||||||
.then(response => {
|
|
||||||
console.log('DEBUG: Response status:', response.status);
|
|
||||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
console.log('DEBUG: Fetched data:', data);
|
|
||||||
// Backend returns the item directly or wrapped in error/success
|
|
||||||
const item = data.error ? null : (data.item || data);
|
|
||||||
|
|
||||||
console.log('DEBUG: Parsed item:', item);
|
|
||||||
|
|
||||||
if (!item || !item._id) {
|
|
||||||
console.error('DEBUG: Item not found or invalid');
|
|
||||||
alert('Item nicht gefunden');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fill in the form fields with the item data
|
|
||||||
document.getElementById('edit-item-id').value = item._id || '';
|
|
||||||
document.getElementById('edit-name').value = item.Name || '';
|
|
||||||
document.getElementById('edit-location').value = item.Ort || '';
|
|
||||||
document.getElementById('edit-description').value = item.Beschreibung || '';
|
|
||||||
document.getElementById('edit-year').value = item.Anschaffungsjahr || '';
|
|
||||||
document.getElementById('edit-cost').value = item.Anschaffungskosten || '';
|
|
||||||
document.getElementById('edit-code4').value = item.Code_4 || '';
|
|
||||||
document.getElementById('edit-isbn').value = item.ISBN || '';
|
|
||||||
document.getElementById('edit-reservierbar').checked = item.Reservierbar !== false;
|
|
||||||
|
|
||||||
// Fill in filter 1 (Unterrichtsfach)
|
|
||||||
const filter1Array = Array.isArray(item.Filter) ? item.Filter : (item.Filter ? [item.Filter] : []);
|
|
||||||
document.getElementById('edit-filter1-1').value = filter1Array[0] || '';
|
|
||||||
document.getElementById('edit-filter1-2').value = filter1Array[1] || '';
|
|
||||||
document.getElementById('edit-filter1-3').value = filter1Array[2] || '';
|
|
||||||
document.getElementById('edit-filter1-4').value = filter1Array[3] || '';
|
|
||||||
|
|
||||||
// Fill in filter 2 (Jahrgangsstufe)
|
|
||||||
const filter2Array = Array.isArray(item.Filter2) ? item.Filter2 : (item.Filter2 ? [item.Filter2] : []);
|
|
||||||
document.getElementById('edit-filter2-1').value = filter2Array[0] || '';
|
|
||||||
document.getElementById('edit-filter2-2').value = filter2Array[1] || '';
|
|
||||||
document.getElementById('edit-filter2-3').value = filter2Array[2] || '';
|
|
||||||
document.getElementById('edit-filter2-4').value = filter2Array[3] || '';
|
|
||||||
|
|
||||||
// Fill in filter 3 (Schlagwort)
|
|
||||||
const filter3Array = Array.isArray(item.Filter3) ? item.Filter3 : (item.Filter3 ? [item.Filter3] : []);
|
|
||||||
document.getElementById('edit-filter3-1').value = filter3Array[0] || '';
|
|
||||||
document.getElementById('edit-filter3-2').value = filter3Array[1] || '';
|
|
||||||
document.getElementById('edit-filter3-3').value = filter3Array[2] || '';
|
|
||||||
document.getElementById('edit-filter3-4').value = filter3Array[3] || '';
|
|
||||||
|
|
||||||
// Display existing images
|
|
||||||
const existingImagesContainer = document.getElementById('edit-existing-images');
|
|
||||||
const editForm = document.getElementById('edit-item-form');
|
|
||||||
existingImagesContainer.innerHTML = '';
|
|
||||||
if (editForm) {
|
|
||||||
editForm.querySelectorAll('input[name="existing_images"], input[name="removed_images"]').forEach(input => input.remove());
|
|
||||||
}
|
|
||||||
if (item.Images && Array.isArray(item.Images)) {
|
|
||||||
item.Images.forEach((image, index) => {
|
|
||||||
const isVideo = isVideoFile(image);
|
|
||||||
const imageDiv = document.createElement('div');
|
|
||||||
imageDiv.className = 'existing-image-item';
|
|
||||||
imageDiv.style.marginBottom = '10px';
|
|
||||||
|
|
||||||
const thumbnailInfo = item.ThumbnailInfo && item.ThumbnailInfo[index];
|
|
||||||
const imageSrc = thumbnailInfo && thumbnailInfo.has_preview ?
|
|
||||||
thumbnailInfo.preview_url :
|
|
||||||
(image.startsWith('/uploads/') || image.startsWith('http') ?
|
|
||||||
image :
|
|
||||||
`{{ url_for('uploaded_file', filename='') }}${image}`);
|
|
||||||
|
|
||||||
const row = document.createElement('div');
|
|
||||||
row.style.display = 'flex';
|
|
||||||
row.style.gap = '8px';
|
|
||||||
row.style.alignItems = 'center';
|
|
||||||
|
|
||||||
if (isVideo) {
|
|
||||||
const video = document.createElement('video');
|
|
||||||
video.src = imageSrc;
|
|
||||||
video.style.maxWidth = '100px';
|
|
||||||
video.style.maxHeight = '100px';
|
|
||||||
video.style.objectFit = 'contain';
|
|
||||||
video.controls = true;
|
|
||||||
row.appendChild(video);
|
|
||||||
} else {
|
|
||||||
const img = document.createElement('img');
|
|
||||||
img.src = imageSrc;
|
|
||||||
img.style.maxWidth = '100px';
|
|
||||||
img.style.maxHeight = '100px';
|
|
||||||
img.style.objectFit = 'contain';
|
|
||||||
img.alt = `Existierendes Bild ${index + 1}`;
|
|
||||||
row.appendChild(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
const deleteButton = document.createElement('button');
|
|
||||||
deleteButton.type = 'button';
|
|
||||||
deleteButton.className = 'delete-image-button';
|
|
||||||
deleteButton.textContent = 'Löschen';
|
|
||||||
deleteButton.addEventListener('click', () => removeExistingImage(image, deleteButton));
|
|
||||||
row.appendChild(deleteButton);
|
|
||||||
|
|
||||||
imageDiv.appendChild(row);
|
|
||||||
existingImagesContainer.appendChild(imageDiv);
|
|
||||||
|
|
||||||
if (editForm) {
|
|
||||||
const hiddenInput = document.createElement('input');
|
|
||||||
hiddenInput.type = 'hidden';
|
|
||||||
hiddenInput.name = 'existing_images';
|
|
||||||
hiddenInput.value = image;
|
|
||||||
editForm.appendChild(hiddenInput);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display the modal
|
|
||||||
editModal.style.display = 'block';
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Fehler beim Laden des Items:', error);
|
|
||||||
alert('Fehler beim Laden des Items');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeHtml(value) {
|
function escapeHtml(value) {
|
||||||
return String(value ?? '').replace(/[&<>'"]/g, (char) => {
|
return String(value ?? '').replace(/[&<>'"]/g, (char) => {
|
||||||
const map = {
|
const map = {
|
||||||
@@ -4688,6 +4254,8 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
modal.style.display = 'block';
|
modal.style.display = 'block';
|
||||||
|
|
||||||
const closeButton = modal.querySelector('.close-modal');
|
const closeButton = modal.querySelector('.close-modal');
|
||||||
@@ -4924,6 +4492,13 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openEditModalForSelectedUnit(itemId, selectId) {
|
||||||
|
const select = document.getElementById(selectId);
|
||||||
|
const targetId = (select && select.value) ? select.value : itemId;
|
||||||
|
// Leitet auf die Bearbeiten-Seite weiter und übergibt die aktuelle URL für den Redirect nach dem Speichern
|
||||||
|
window.location.href = `/item_edit/${targetId}`;
|
||||||
|
}
|
||||||
|
|
||||||
function changeModalImage(direction) {
|
function changeModalImage(direction) {
|
||||||
const currentIndex = window.currentModalImageIndex;
|
const currentIndex = window.currentModalImageIndex;
|
||||||
const total = window.totalModalImages;
|
const total = window.totalModalImages;
|
||||||
@@ -5350,8 +4925,6 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load location options for edit modal
|
|
||||||
// Edit-related functions moved to edit_item_functions.html
|
|
||||||
|
|
||||||
// Schedule modal functions
|
// Schedule modal functions
|
||||||
function openScheduleModal(itemId) {
|
function openScheduleModal(itemId) {
|
||||||
@@ -5471,50 +5044,6 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup edit form submission
|
|
||||||
function setupEditFormSubmission() {
|
|
||||||
const editForm = document.getElementById('edit-item-form');
|
|
||||||
if (editForm) {
|
|
||||||
editForm.addEventListener('submit', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
const itemId = document.getElementById('edit-item-id').value;
|
|
||||||
const formData = new FormData(this);
|
|
||||||
|
|
||||||
fetch(`/edit_item/${itemId}`, {
|
|
||||||
method: 'POST',
|
|
||||||
body: formData
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
if (response.ok) {
|
|
||||||
closeEditModal();
|
|
||||||
// Reload items to show updated information
|
|
||||||
loadItems();
|
|
||||||
// Show success message
|
|
||||||
const successMsg = document.createElement('div');
|
|
||||||
successMsg.className = 'alert alert-success';
|
|
||||||
successMsg.textContent = 'Item wurde erfolgreich aktualisiert!';
|
|
||||||
successMsg.style.position = 'fixed';
|
|
||||||
successMsg.style.top = '20px';
|
|
||||||
successMsg.style.right = '20px';
|
|
||||||
successMsg.style.zIndex = '9999';
|
|
||||||
document.body.appendChild(successMsg);
|
|
||||||
setTimeout(() => {
|
|
||||||
if (successMsg.parentNode) {
|
|
||||||
successMsg.parentNode.removeChild(successMsg);
|
|
||||||
}
|
|
||||||
}, 3000);
|
|
||||||
} else {
|
|
||||||
alert('Fehler beim Aktualisieren des Items');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Error updating item:', error);
|
|
||||||
alert('Fehler beim Aktualisieren des Items');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Duplication function
|
// Duplication function
|
||||||
function duplicateItem(itemId) {
|
function duplicateItem(itemId) {
|
||||||
@@ -5690,9 +5219,6 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Include edit item functions -->
|
|
||||||
{% include "edit_item_functions.html" %}
|
|
||||||
|
|
||||||
<!-- Include reset item functions -->
|
<!-- Include reset item functions -->
|
||||||
{% include "reset_item_functions.html" %}
|
{% include "reset_item_functions.html" %}
|
||||||
|
|
||||||
@@ -5920,16 +5446,4 @@ document.addEventListener('DOMContentLoaded', ()=>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
{% if open_item %}
|
|
||||||
<script>
|
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
|
||||||
if (typeof openEditModalFromServer === 'function') {
|
|
||||||
setTimeout(function() {
|
|
||||||
openEditModalFromServer('{{ open_item }}');
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
+452
-324
@@ -6,7 +6,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header-section">
|
<div class="header-section">
|
||||||
<h1>Neuen Benutzer registrieren</h1>
|
<h1>Neuen Benutzer registrieren</h1>
|
||||||
<p class="subtitle">Erstellen Sie ein neues Benutzerkonto und legen Sie Zugriffsrechte fest</p>
|
<p class="subtitle">Erstellen Sie ein neues Benutzerkonto oder importieren Sie mehrere Benutzer per CSV</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flash-container">
|
<div class="flash-container">
|
||||||
@@ -23,7 +23,43 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
<!-- 1. CSV BULK IMPORT CARD -->
|
||||||
|
<div class="form-card" style="margin-bottom: 2rem; border-top: 4px solid #059669;">
|
||||||
|
<div class="card-header" style="margin-bottom: 1rem;">
|
||||||
|
<h2>Massenregistrierung via CSV</h2>
|
||||||
|
<p class="subtitle" style="color: #4b5563;">
|
||||||
|
Laden Sie eine CSV-Datei hoch (Format: <code>Vorname, Nachname</code>).
|
||||||
|
Benutzernamen und sichere Passwörter werden serverseitig generiert. Nach dem Upload erhalten Sie direkt ein PDF mit Zugangsdaten (2 pro Seite zum Ausschneiden).
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form method="POST" action="{{ url_for('register_csv') }}" enctype="multipart/form-data">
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="permission-preset-csv">Berechtigungs-Preset für alle CSV-Benutzer</label>
|
||||||
|
<select id="permission-preset-csv" name="permission_preset" class="form-select" style="margin-bottom: 1rem;">
|
||||||
|
{% for preset_key, preset in permission_presets.items() %}
|
||||||
|
<option value="{{ preset_key }}">{{ preset.label }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<label for="csv_file">CSV-Datei auswählen</label>
|
||||||
|
<div class="input-container">
|
||||||
|
<span class="input-icon">📄</span>
|
||||||
|
<input type="file" id="csv_file" name="csv_file" accept=".csv" required style="padding: 10px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group form-actions" style="margin-top: 1.5rem;">
|
||||||
|
<button type="submit" class="action-button" style="background-color: #059669; color: white;">
|
||||||
|
📥 CSV Importieren & Zugangsdaten-PDF Herunterladen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- 2. SINGLE USER REGISTRATION CARD -->
|
||||||
<div class="form-card">
|
<div class="form-card">
|
||||||
|
<h2>Einzelnen Benutzer registrieren</h2>
|
||||||
<form method="POST" action="{{ url_for('register') }}">
|
<form method="POST" action="{{ url_for('register') }}">
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -32,11 +68,13 @@
|
|||||||
<span class="input-icon">👤</span>
|
<span class="input-icon">👤</span>
|
||||||
<input type="text" id="name" name="name" placeholder="Geben Sie den Vornamen ein" required onchange="generateUsername()" oninput="generateUsername()">
|
<input type="text" id="name" name="name" placeholder="Geben Sie den Vornamen ein" required onchange="generateUsername()" oninput="generateUsername()">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label for="last-name">Nachname</label>
|
<label for="last-name">Nachname</label>
|
||||||
<div class="input-container">
|
<div class="input-container">
|
||||||
<span class="input-icon">👤</span>
|
<span class="input-icon">👤</span>
|
||||||
<input type="text" id="last-name" name="last-name" placeholder="Geben Sie den Nachnamen ein" required onchange="generateUsername()" oninput="generateUsername()">
|
<input type="text" id="last-name" name="last-name" placeholder="Geben Sie den Nachnamen ein" required onchange="generateUsername()" oninput="generateUsername()">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label for="username">Benutzername <span style="color: #9ca3af;">(Vorschau - wird serverseitig finalisiert)</span></label>
|
<label for="username">Benutzername <span style="color: #9ca3af;">(Vorschau - wird serverseitig finalisiert)</span></label>
|
||||||
<div class="input-container">
|
<div class="input-container">
|
||||||
<span class="input-icon">👤</span>
|
<span class="input-icon">👤</span>
|
||||||
@@ -61,16 +99,17 @@
|
|||||||
<div class="input-wrapper">
|
<div class="input-wrapper">
|
||||||
<div class="input-container">
|
<div class="input-container">
|
||||||
<span class="input-icon">🔒</span>
|
<span class="input-icon">🔒</span>
|
||||||
<!-- HTML5 Pattern blockiert unsichere Passwörter vor dem Absenden -->
|
|
||||||
<input
|
<input
|
||||||
|
type="password"
|
||||||
id="password"
|
id="password"
|
||||||
name="password"
|
name="password"
|
||||||
placeholder="Geben Sie ein sicheres Passwort ein"
|
placeholder="Geben Sie ein sicheres Passwort ein"
|
||||||
required
|
required
|
||||||
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{12,}">
|
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{12,}">
|
||||||
|
<button type="button" id="toggle-pw-btn" class="toggle-pw-btn" onclick="togglePasswordVisibility()" style="background:none; border:none; cursor:pointer; padding-right:10px;">👁️</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="pw-actions">
|
<div class="pw-actions" style="margin-top: 8px;">
|
||||||
<button type="button" class="btn-secondary" onclick="generateSecurePassword()">Passwort generieren</button>
|
<button type="button" class="btn-secondary" onclick="generateSecurePassword()">Passwort generieren</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -120,323 +159,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
|
||||||
:root {
|
|
||||||
--primary-color: #3498db;
|
|
||||||
--primary-dark: #2980b9;
|
|
||||||
--success-color: #2ecc71;
|
|
||||||
--error-color: #e74c3c;
|
|
||||||
--text-color: var(--ui-text);
|
|
||||||
--light-bg: #f9f9f9;
|
|
||||||
--border-radius: 8px;
|
|
||||||
--shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
|
||||||
--transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
||||||
background-color: var(--light-bg);
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
color: var(--text-color);
|
|
||||||
line-height: 1.6;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
max-width: 800px;
|
|
||||||
margin: 2rem auto;
|
|
||||||
padding: 0 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-section {
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
padding-bottom: 1.5rem;
|
|
||||||
border-bottom: 1px solid #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-section h1 {
|
|
||||||
font-size: 2.5rem;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
color: var(--primary-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.subtitle {
|
|
||||||
font-size: 1.1rem;
|
|
||||||
color: #777;
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
background-color: var(--ui-surface);
|
|
||||||
padding: 2rem;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
box-shadow: var(--shadow);
|
|
||||||
margin-bottom: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-card {
|
|
||||||
max-width: 500px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group {
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-group label {
|
|
||||||
display: block;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
font-weight: 500;
|
|
||||||
color: var(--primary-dark);
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-container {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-icon {
|
|
||||||
position: absolute;
|
|
||||||
left: 1rem;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
color: #aaa;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="text"],
|
|
||||||
input[type="password"],
|
|
||||||
.form-select {
|
|
||||||
width: 100%;
|
|
||||||
padding: 0.8rem 1rem 0.8rem 3rem;
|
|
||||||
border: 1px solid #ddd;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
font-size: 1rem;
|
|
||||||
transition: var(--transition);
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type="text"]:focus,
|
|
||||||
input[type="password"]:focus,
|
|
||||||
.form-select:focus {
|
|
||||||
border-color: var(--primary-color);
|
|
||||||
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-select {
|
|
||||||
padding-left: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
input::placeholder {
|
|
||||||
color: #aaa;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-actions {
|
|
||||||
margin-top: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-button {
|
|
||||||
background-color: var(--primary-color);
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
padding: 0.8rem 1.5rem;
|
|
||||||
border-radius: 30px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-weight: 600;
|
|
||||||
transition: var(--transition);
|
|
||||||
width: 100%;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.action-button:hover {
|
|
||||||
background-color: var(--primary-dark);
|
|
||||||
transform: translateY(-2px);
|
|
||||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.register-button {
|
|
||||||
background-color: var(--success-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.register-button:hover {
|
|
||||||
background-color: #27ae60;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flash-container {
|
|
||||||
margin-bottom: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flash {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
padding: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
border-radius: var(--border-radius);
|
|
||||||
animation: fadeIn 0.3s ease-in-out;
|
|
||||||
}
|
|
||||||
|
|
||||||
.flash-icon {
|
|
||||||
margin-right: 0.8rem;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
width: 24px;
|
|
||||||
height: 24px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background-color: rgba(255, 255, 255, 0.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
.flash.success {
|
|
||||||
background-color: #d4edda;
|
|
||||||
color: #155724;
|
|
||||||
border-left: 4px solid var(--success-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
.flash.error {
|
|
||||||
background-color: #f8d7da;
|
|
||||||
color: #721c24;
|
|
||||||
border-left: 4px solid var(--error-color);
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from { opacity: 0; transform: translateY(-10px); }
|
|
||||||
to { opacity: 1; transform: translateY(0); }
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.container {
|
|
||||||
padding: 0 1rem;
|
|
||||||
margin: 1rem auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.content {
|
|
||||||
padding: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.header-section h1 {
|
|
||||||
font-size: 2rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.password-rules {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
border: 1px solid #e5e7eb;
|
|
||||||
border-radius: 8px;
|
|
||||||
background: var(--ui-surface-soft);
|
|
||||||
}
|
|
||||||
|
|
||||||
.password-rules-title {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #1f2937;
|
|
||||||
font-size: 0.92rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.password-rules ul {
|
|
||||||
list-style: none;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pw-rule {
|
|
||||||
position: relative;
|
|
||||||
padding-left: 22px;
|
|
||||||
margin: 5px 0;
|
|
||||||
color: #b91c1c;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pw-rule::before {
|
|
||||||
content: '✗';
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pw-rule.ok {
|
|
||||||
color: #166534;
|
|
||||||
}
|
|
||||||
|
|
||||||
.pw-rule.ok::before {
|
|
||||||
content: '✓';
|
|
||||||
}
|
|
||||||
|
|
||||||
.anonymize-hint {
|
|
||||||
margin-top: 10px;
|
|
||||||
margin-bottom: 0;
|
|
||||||
background: #f0f9ff;
|
|
||||||
border: 1px solid #bae6fd;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 10px 12px;
|
|
||||||
color: #0c4a6e;
|
|
||||||
font-size: 0.92rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.permission-panels {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
|
||||||
gap: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.permission-panel {
|
|
||||||
border: 1px solid #d1d5db;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 10px;
|
|
||||||
background: var(--ui-surface-soft);
|
|
||||||
}
|
|
||||||
|
|
||||||
.permission-panel h4 {
|
|
||||||
margin: 0 0 8px;
|
|
||||||
font-size: 1rem;
|
|
||||||
color: #1f2937;
|
|
||||||
}
|
|
||||||
|
|
||||||
.permission-check {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
margin: 4px 0;
|
|
||||||
color: #1f2937;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Neue Styles für die Passwort-Erweiterungen */
|
|
||||||
.pw-actions {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
margin-top: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary {
|
|
||||||
padding: 8px 12px;
|
|
||||||
border: 1px solid #d1d5db;
|
|
||||||
background-color: #f3f4f6;
|
|
||||||
border-radius: 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
font-size: 0.9em;
|
|
||||||
transition: background-color 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-secondary:hover {
|
|
||||||
background-color: #e5e7eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-wrapper {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.input-wrapper .input-container {
|
|
||||||
flex-grow: 1;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Hilfsfunktion: Umlaute auflösen und Sonderzeichen entfernen
|
// Hilfsfunktion: Umlaute auflösen und Sonderzeichen entfernen
|
||||||
function cleanNameForUsername(text) {
|
function cleanNameForUsername(text) {
|
||||||
@@ -504,9 +226,10 @@ function generateSecurePassword() {
|
|||||||
const pwField = document.getElementById('password');
|
const pwField = document.getElementById('password');
|
||||||
pwField.value = password;
|
pwField.value = password;
|
||||||
|
|
||||||
// Automatisch sichtbar machen, damit der User es kopieren kann
|
// Automatisch sichtbar machen
|
||||||
pwField.type = 'text';
|
pwField.type = 'text';
|
||||||
document.getElementById('toggle-pw-btn').textContent = '🙈';
|
const toggleBtn = document.getElementById('toggle-pw-btn');
|
||||||
|
if (toggleBtn) toggleBtn.textContent = '🙈';
|
||||||
|
|
||||||
updatePasswordRules();
|
updatePasswordRules();
|
||||||
}
|
}
|
||||||
@@ -517,10 +240,10 @@ function togglePasswordVisibility() {
|
|||||||
const toggleBtn = document.getElementById('toggle-pw-btn');
|
const toggleBtn = document.getElementById('toggle-pw-btn');
|
||||||
if (pwField.type === "password") {
|
if (pwField.type === "password") {
|
||||||
pwField.type = "text";
|
pwField.type = "text";
|
||||||
toggleBtn.textContent = '🙈';
|
if (toggleBtn) toggleBtn.textContent = '🙈';
|
||||||
} else {
|
} else {
|
||||||
pwField.type = "password";
|
pwField.type = "password";
|
||||||
toggleBtn.textContent = '👁️';
|
if (toggleBtn) toggleBtn.textContent = '👁️';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -592,4 +315,409 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--primary-color: #3498db;
|
||||||
|
--primary-dark: #2980b9;
|
||||||
|
--success-color: #2ecc71;
|
||||||
|
--success-dark: #27ae60;
|
||||||
|
--csv-color: #059669;
|
||||||
|
--csv-dark: #047857;
|
||||||
|
--error-color: #e74c3c;
|
||||||
|
--text-color: var(--ui-text, #1f2937);
|
||||||
|
--light-bg: #f9f9f9;
|
||||||
|
--border-radius: 8px;
|
||||||
|
--shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
|
||||||
|
--transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||||
|
background-color: var(--light-bg);
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: var(--text-color);
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
margin: 2rem auto;
|
||||||
|
padding: 0 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-section {
|
||||||
|
text-align: center;
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
padding-bottom: 1.5rem;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-section h1 {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: var(--primary-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.subtitle {
|
||||||
|
font-size: 1.05rem;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
background-color: var(--ui-surface, #ffffff);
|
||||||
|
padding: 2rem;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
box-shadow: var(--shadow);
|
||||||
|
margin-bottom: 2rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Karten-Layout für Einzel- & Massenregistrierung */
|
||||||
|
.form-card {
|
||||||
|
max-width: 620px;
|
||||||
|
margin: 0 auto 2.5rem auto;
|
||||||
|
padding: 1.5rem;
|
||||||
|
background: var(--ui-surface-soft, #f9fafb);
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-card:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-card h2 {
|
||||||
|
font-size: 1.4rem;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
color: #111827;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 1.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group label {
|
||||||
|
display: block;
|
||||||
|
margin-bottom: 0.4rem;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #374151;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-container {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-icon {
|
||||||
|
position: absolute;
|
||||||
|
left: 1rem;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
color: #9ca3af;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Eingabefelder & Selects */
|
||||||
|
input[type="text"],
|
||||||
|
input[type="password"],
|
||||||
|
input[type="file"],
|
||||||
|
.form-select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 0.75rem 1rem 0.75rem 2.8rem;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
font-size: 0.95rem;
|
||||||
|
background-color: #ffffff;
|
||||||
|
transition: var(--transition);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"]:focus,
|
||||||
|
input[type="password"]:focus,
|
||||||
|
input[type="file"]:focus,
|
||||||
|
.form-select:focus {
|
||||||
|
border-color: var(--primary-color);
|
||||||
|
box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-select {
|
||||||
|
padding-left: 1rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Stylings für den CSV-Datei-Upload */
|
||||||
|
input[type="file"] {
|
||||||
|
padding-left: 2.8rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="file"]::file-selector-button {
|
||||||
|
padding: 0.35rem 0.75rem;
|
||||||
|
border-radius: 4px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
background: #f3f4f6;
|
||||||
|
color: #374151;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="file"]::file-selector-button:hover {
|
||||||
|
background: #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::placeholder {
|
||||||
|
color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
background: #e0f2fe;
|
||||||
|
color: #0369a1;
|
||||||
|
padding: 2px 6px;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Buttons */
|
||||||
|
.form-actions {
|
||||||
|
margin-top: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button {
|
||||||
|
background-color: var(--primary-color);
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
padding: 0.8rem 1.5rem;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 600;
|
||||||
|
transition: var(--transition);
|
||||||
|
width: 100%;
|
||||||
|
font-size: 1rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-button:hover {
|
||||||
|
background-color: var(--primary-dark);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.register-button {
|
||||||
|
background-color: var(--success-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.register-button:hover {
|
||||||
|
background-color: var(--success-dark);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Toggle-Button für Passwort-Auge */
|
||||||
|
.input-wrapper {
|
||||||
|
position: relative;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-pw-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 0.75rem;
|
||||||
|
top: 50%;
|
||||||
|
transform: translateY(-50%);
|
||||||
|
background: none;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 1.1rem;
|
||||||
|
padding: 4px;
|
||||||
|
z-index: 2;
|
||||||
|
opacity: 0.7;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toggle-pw-btn:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Passwort-Regeln Box */
|
||||||
|
.password-rules {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
border: 1px solid #e5e7eb;
|
||||||
|
border-radius: 8px;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.password-rules-title {
|
||||||
|
margin: 0 0 6px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #1f2937;
|
||||||
|
font-size: 0.88rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.password-rules ul {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pw-rule {
|
||||||
|
position: relative;
|
||||||
|
padding-left: 20px;
|
||||||
|
margin: 4px 0;
|
||||||
|
color: #dc2626;
|
||||||
|
font-size: 0.85rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pw-rule::before {
|
||||||
|
content: '✗';
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pw-rule.ok {
|
||||||
|
color: #166534;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pw-rule.ok::before {
|
||||||
|
content: '✓';
|
||||||
|
}
|
||||||
|
|
||||||
|
.pw-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
margin-top: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
padding: 6px 12px;
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
background-color: #ffffff;
|
||||||
|
color: #374151;
|
||||||
|
border-radius: 6px;
|
||||||
|
cursor: pointer;
|
||||||
|
font-size: 0.88rem;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: var(--transition);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover {
|
||||||
|
background-color: #f3f4f6;
|
||||||
|
border-color: #9ca3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hinweise & Rechte-Panels */
|
||||||
|
.anonymize-hint {
|
||||||
|
margin-top: 8px;
|
||||||
|
margin-bottom: 0;
|
||||||
|
background: #f0f9ff;
|
||||||
|
border: 1px solid #bae6fd;
|
||||||
|
border-radius: 6px;
|
||||||
|
padding: 8px 12px;
|
||||||
|
color: #0369a1;
|
||||||
|
font-size: 0.88rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-panels {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-panel {
|
||||||
|
border: 1px solid #d1d5db;
|
||||||
|
border-radius: 8px;
|
||||||
|
padding: 12px;
|
||||||
|
background: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-panel h4 {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
font-size: 0.95rem;
|
||||||
|
color: #1f2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
.permission-check {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin: 6px 0;
|
||||||
|
color: #374151;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Flash Nachrichten */
|
||||||
|
.flash-container {
|
||||||
|
margin-bottom: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flash {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0.9rem 1rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
border-radius: var(--border-radius);
|
||||||
|
animation: fadeIn 0.3s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flash-icon {
|
||||||
|
margin-right: 0.8rem;
|
||||||
|
font-size: 1rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 22px;
|
||||||
|
height: 22px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: rgba(255, 255, 255, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flash.success {
|
||||||
|
background-color: #d1fae5;
|
||||||
|
color: #065f46;
|
||||||
|
border-left: 4px solid var(--csv-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.flash.error {
|
||||||
|
background-color: #fee2e2;
|
||||||
|
color: #991b1b;
|
||||||
|
border-left: 4px solid var(--error-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from { opacity: 0; transform: translateY(-8px); }
|
||||||
|
to { opacity: 1; transform: translateY(0); }
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.container {
|
||||||
|
padding: 0 0.75rem;
|
||||||
|
margin: 1rem auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-card {
|
||||||
|
padding: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-section h1 {
|
||||||
|
font-size: 1.8rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -954,8 +954,10 @@
|
|||||||
<label for="anschaffungskosten">Anschaffungskosten (€)</label>
|
<label for="anschaffungskosten">Anschaffungskosten (€)</label>
|
||||||
<input id="anschaffungskosten" name="anschaffungskosten">
|
<input id="anschaffungskosten" name="anschaffungskosten">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- Image upload (hidden for library mode) -->
|
<!-- Image upload (hidden for library mode) -->
|
||||||
<div class="form-group" {% if show_library_features %}style="display:none;"{% endif %}>
|
<div class="form-group">
|
||||||
<label for="images">Bilder/Videos:</label>
|
<label for="images">Bilder/Videos:</label>
|
||||||
<input type="file" id="images" name="images" accept=".jpg, .jpeg, .png, .gif, .mp4, .mov, .avi, .mkv, .webm, .flv, .m4v, .3gp" multiple>
|
<input type="file" id="images" name="images" accept=".jpg, .jpeg, .png, .gif, .mp4, .mov, .avi, .mkv, .webm, .flv, .m4v, .3gp" multiple>
|
||||||
<div class="allowed-formats">Erlaubte Formate: JPG, JPEG, PNG, GIF, MP4, MOV, AVI, MKV, WEBM, FLV, M4V, 3GP</div>
|
<div class="allowed-formats">Erlaubte Formate: JPG, JPEG, PNG, GIF, MP4, MOV, AVI, MKV, WEBM, FLV, M4V, 3GP</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user