Quelltext des aktuellen Standes
<?php $this->layout('layouts/main', ['page_title' => $page_title, 'current_route' => $current_route, 'full_width' => true]); ?>
<style>
a { text-decoration:none; }
.inv-wrap { padding:0; }
/* Anlege-Formular: alle Felder plus Button in einer Zeile, unten bündig ausgerichtet */
.mfr-form-grid { display:grid; grid-template-columns:1fr 1fr 1fr 1fr 1fr auto; gap:0.75rem; align-items:end; }
.mfr-form-grid .form-group { margin-bottom:0; }
/* Badges für die zugeordnete Garantie-API */
.wp-badge { display:inline-block; padding:0.15rem 0.55rem; border-radius:0.35rem; font-size:0.72rem; font-weight:700; letter-spacing:0.03em; white-space:nowrap; }
.wp-hp { background:var(--sky-100); color:var(--sky-700); }
.wp-hpe { background:var(--color-primary-soft); color:var(--color-primary); }
.wp-dell{ background:var(--green-100); color:var(--green-800); }
/* Inline-Bearbeitungszeile in der Herstellertabelle */
.mfr-edit-row { background:var(--sky-50); }
.mfr-edit-row td { padding:1rem; border-bottom:1px solid var(--gray-200); }
.mfr-edit-grid { display:flex; gap:0.6rem; flex-wrap:wrap; align-items:flex-end; }
.mfr-edit-grid .form-group { margin-bottom:0; }
@media(max-width:900px) {
.mfr-form-grid { grid-template-columns:1fr 1fr; }
}
@media(max-width:560px) {
.mfr-form-grid { grid-template-columns:1fr; }
}
</style>
<div class="inv-wrap">
<!-- Content Header -->
<div class="content-header">
<div>
<h1><?= $this->te('Hersteller') ?></h1>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="/"><?= $this->te('Home') ?></a></li>
<li class="breadcrumb-item"><a href="/inventory"><?= $this->te('Inventar') ?></a></li>
<li class="breadcrumb-item active"><?= $this->te('Hersteller') ?></li>
</ol>
</div>
<div class="content-header-actions">
<a href="/inventory/types" class="btn btn-default"><?= $this->te('Modelle') ?></a>
<a href="/inventory" class="btn btn-default"><?= $this->te('← Inventar') ?></a>
</div>
</div>
<div class="page-body">
<!-- Neuen Hersteller anlegen -->
<div class="detail-card">
<div class="detail-card-header">
<div class="detail-card-title"><?= $this->te('➕ Neuen Hersteller anlegen') ?></div>
</div>
<div class="detail-card-body">
<form method="POST" action="/inventory/manufacturers">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<div class="mfr-form-grid">
<div class="form-group">
<label><?= $this->te('Name') ?> <span class="text-danger">*</span></label>
<input type="text" name="name" class="form-control" placeholder="<?= $this->te('z.B. Dell') ?>" required maxlength="255">
</div>
<div class="form-group">
<label for="f-4d4b-warranty_provider"><?= $this->te('Garantie-API') ?></label>
<select id="f-4d4b-warranty_provider" name="warranty_provider" class="form-control">
<option value=""><?= $this->te('— keine —') ?></option>
<option value="hp"><?= $this->te('HP Inc. (Notebooks/Drucker)') ?></option>
<option value="hpe"><?= $this->te('HPE (Server/Switches)') ?></option>
<option value="dell"><?= $this->te('Dell') ?></option>
</select>
</div>
<div class="form-group">
<label><?= $this->te('Website') ?></label>
<input type="url" name="website" class="form-control" placeholder="https://…" maxlength="500">
</div>
<div class="form-group">
<label><?= $this->te('Support-URL') ?></label>
<input type="url" name="support_url" class="form-control" placeholder="https://support.…" maxlength="500">
</div>
<div class="form-group">
<label><?= $this->te('Notizen') ?></label>
<input type="text" name="notes" class="form-control" placeholder="<?= $this->te('Interne Notizen') ?>" maxlength="500">
</div>
<div>
<button type="submit" class="btn btn-primary"><?= $this->te('Anlegen') ?></button>
</div>
</div>
</form>
</div>
</div>
<!-- Herstellerliste -->
<div class="detail-card">
<div class="detail-card-header">
<div class="detail-card-title">📋 <?= $this->t('Hersteller') ?> (<?= count($manufacturers) ?>)</div>
</div>
<?php if (empty($manufacturers)): ?>
<div class="empty-state"><?= $this->te('Noch keine Hersteller vorhanden.') ?></div>
<?php else: ?>
<div style="overflow-x:auto;">
<table class="data-table">
<thead>
<tr>
<th scope="col"><?= $this->te('Name') ?></th>
<th scope="col"><?= $this->te('Garantie-API') ?></th>
<th scope="col"><?= $this->te('Website') ?></th>
<th scope="col"><?= $this->te('Support') ?></th>
<th scope="col"><?= $this->te('Notizen') ?></th>
<th scope="col"><?= $this->te('Modelle') ?></th>
<th scope="col"></th>
</tr>
</thead>
<tbody>
<?php foreach ($manufacturers as $m): ?>
<tr>
<td><strong><?= $this->e($m['name']) ?></strong></td>
<td>
<?php if ($m['warranty_provider'] === 'hp'): ?>
<span class="wp-badge wp-hp">HP Inc.</span>
<?php elseif ($m['warranty_provider'] === 'hpe'): ?>
<span class="wp-badge wp-hpe">HPE</span>
<?php elseif ($m['warranty_provider'] === 'dell'): ?>
<span class="wp-badge wp-dell"><?= $this->te('Dell') ?></span>
<?php else: ?>
<span style="color:var(--gray-300);">—</span>
<?php endif; ?>
</td>
<td style="font-size:0.82rem;">
<?php if ($m['website']): ?>
<a href="<?= $this->e($m['website']) ?>" target="_blank" rel="noopener" style="color:var(--color-primary);">↗ <?= $this->e(parse_url($m['website'], PHP_URL_HOST) ?: $m['website']) ?></a>
<?php else: ?>
<span style="color:var(--gray-300);">—</span>
<?php endif; ?>
</td>
<td style="font-size:0.82rem;">
<?php if (!empty($m['support_url'])): ?>
<a href="<?= $this->e($m['support_url']) ?>" target="_blank" rel="noopener" style="color:var(--cyan-600);">↗ <?= $this->e(parse_url($m['support_url'], PHP_URL_HOST) ?: $m['support_url']) ?></a>
<?php else: ?>
<span style="color:var(--gray-300);">—</span>
<?php endif; ?>
</td>
<td style="font-size:0.82rem;color:var(--gray-500);"><?= $m['notes'] ? $this->e(mb_substr($m['notes'], 0, 60)) : '—' ?></td>
<td style="font-size:0.82rem;"><?= (int)$m['type_count'] ?></td>
<td>
<div style="display:flex;gap:0.4rem;">
<button onclick="toggleEdit('mfr-<?= $m['id'] ?>')" class="btn btn-xs btn-default"><?= $this->te('Bearbeiten') ?></button>
<?php if ((int)$m['type_count'] === 0): ?>
<form method="POST" action="/inventory/manufacturers/<?= $m['id'] ?>/delete" style="margin:0;"
onsubmit="return confirm('Hersteller <?= addslashes($this->e($m['name'])) ?> löschen?')">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<button aria-label="<?= $this->te('Löschen') ?>" type="submit" class="btn btn-xs btn-danger">✕</button>
</form>
<?php endif; ?>
</div>
</td>
</tr>
<tr id="mfr-<?= $m['id'] ?>" style="display:none;" class="mfr-edit-row">
<td colspan="7">
<form method="POST" action="/inventory/manufacturers/<?= $m['id'] ?>">
<input type="hidden" name="_csrf" value="<?= $this->csrf() ?>">
<input type="hidden" name="_method" value="PUT">
<div class="mfr-edit-grid">
<div class="form-group" style="flex:1;min-width:140px;">
<label><?= $this->te('Name') ?> <span class="text-danger">*</span></label>
<input type="text" name="name" class="form-control" value="<?= $this->e($m['name']) ?>" required maxlength="255">
</div>
<div class="form-group" style="min-width:160px;">
<label><?= $this->te('Garantie-API') ?></label>
<select name="warranty_provider" class="form-control">
<option value=""<?= ($m['warranty_provider'] ?? '') === '' ? ' selected' : '' ?>><?= $this->te('— keine —') ?></option>
<option value="hp"<?= ($m['warranty_provider'] ?? '') === 'hp' ? ' selected' : '' ?>><?= $this->te('HP Inc. (Notebooks/Drucker)') ?></option>
<option value="hpe"<?= ($m['warranty_provider'] ?? '') === 'hpe' ? ' selected' : '' ?>><?= $this->te('HPE (Server/Switches)') ?></option>
<option value="dell"<?= ($m['warranty_provider'] ?? '') === 'dell' ? ' selected' : '' ?>><?= $this->te('Dell') ?></option>
</select>
</div>
<div class="form-group" style="flex:1.5;min-width:180px;">
<label><?= $this->te('Website') ?></label>
<input type="url" name="website" class="form-control" value="<?= $this->e($m['website'] ?? '') ?>" maxlength="500">
</div>
<div class="form-group" style="flex:1.5;min-width:180px;">
<label><?= $this->te('Support-URL') ?></label>
<input type="url" name="support_url" class="form-control" value="<?= $this->e($m['support_url'] ?? '') ?>" maxlength="500">
</div>
<div class="form-group" style="flex:2;min-width:180px;">
<label><?= $this->te('Notizen') ?></label>
<input type="text" name="notes" class="form-control" value="<?= $this->e($m['notes'] ?? '') ?>" maxlength="500">
</div>
<div style="display:flex;gap:0.4rem;align-items:flex-end;">
<button type="submit" class="btn btn-sm btn-primary"><?= $this->te('💾 Speichern') ?></button>
<button type="button" onclick="toggleEdit('mfr-<?= $m['id'] ?>')" class="btn btn-xs btn-default"><?= $this->te('Abbrechen') ?></button>
</div>
</div>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php endif; ?>
</div>
</div>
</div>
<script>
function toggleEdit(id) {
var row = document.getElementById(id);
row.style.display = row.style.display === 'none' ? '' : 'none';
}
</script>