OpenNIT

Quelltext des aktuellen Standes

Fassung 1.1.1

show.php

16 KB
<?php
$this->layout('layouts/main', [
    'page_title'    => $page_title,
    'current_route' => $current_route,
    'full_width'    => true,
]);

$statusConfig = [
    'available'   => ['Verfügbar',    'status-pill--success'],
    'lent'        => ['Ausgeliehen',  'status-pill--danger'],
    'reserved'    => ['Reserviert',   'status-pill--warning'],
    'maintenance' => ['In Wartung',   'status-pill--purple'],
    'retired'     => ['Ausgemustert', 'status-pill--neutral'],
];
[$slabel, $spill] = $statusConfig[$device['status']] ?? ['Unbekannt','status-pill--neutral'];

$lendingStatusCfg = [
    'pending'  => ['Anfrage offen', 'status-pill--info'],
    'reserved' => ['Reserviert',    'status-pill--warning'],
    'active'   => ['Aktiv',         'status-pill--success'],
    'returned' => ['Zurück',        'status-pill--neutral'],
    'cancelled'=> ['Storniert',     'status-pill--danger'],
];
?>
<style>
a { text-decoration: none; }
a:hover { text-decoration: none; }
.lds-wrap { padding: 0; }

/* Layout */
.lds-layout { display:grid; grid-template-columns:1fr 300px; gap:1.75rem; align-items:start; }
/* min-width:0 erlaubt den Grid-Spalten zu schrumpfen, damit die breite
   Historientabelle innerhalb ihres .table-wrapper scrollt statt die ganze
   Seite horizontal zu überlaufen. */
.lds-main { min-width:0; }
.lds-aside { min-width:0; }

/* Accessories */
.lds-acc-list { display:flex; flex-direction:column; gap:0.5rem; }
.lds-acc-item { display:flex; align-items:center; gap:0.75rem; padding:0.6rem 0.75rem; background:var(--gray-50); border-radius:0.25rem; }
.lds-acc-icon { color:var(--amber-600); flex-shrink:0; }
.lds-acc-name { font-size:0.88rem; font-weight:600; color:var(--gray-700); }
.lds-acc-desc { font-size:0.78rem; color:var(--gray-400); margin-top:0.1rem; }

/* History table */
.detail-card .data-table a { color:var(--amber-600); text-decoration:none; font-weight:600; }
.detail-card .data-table a:hover { color: var(--amber-700); }

/* Info list */
.lds-info-list { display:flex; flex-direction:column; gap:0.75rem; }
.lds-info-row { display:flex; flex-direction:column; gap:0.15rem; }
.lds-info-label { font-size:0.72rem; font-weight:700; text-transform:uppercase; letter-spacing:0.05em; color:var(--gray-400); }
.lds-info-value { font-size:0.88rem; color:var(--gray-700); }

/* Description */
.lds-description { font-size:0.88rem; color:var(--gray-600); line-height:1.6; white-space:pre-line; }

.lds-head-group { display:flex; align-items:center; gap:1rem; min-width:0; flex-wrap:wrap; }
.lds-head-group h1 { overflow-wrap:anywhere; }

@media(max-width:960px) {
    .lds-layout { grid-template-columns:1fr; }
}
</style>

<div class="lds-wrap">
    <!-- Content Header -->
    <div class="content-header">
        <div class="lds-head-group">
            <?php if (!empty($device['image_path'])): ?>
                <img src="<?= $this->e($device['image_path']) ?>" alt="<?= $this->e($device['title']) ?>"
                     style="width:48px;height:48px;border-radius:0.25rem;object-fit:cover;border:1px solid var(--color-gray-300);">
            <?php else: ?>
                <div style="width:48px;height:48px;border-radius:0.25rem;background:var(--color-gray-200);display:flex;align-items:center;justify-content:center;">
                    <svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#adb5bd" stroke-width="1.5"><rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/></svg>
                </div>
            <?php endif; ?>
            <div>
                <h1 style="margin:0;"><?= $this->e($device['title']) ?></h1>
                <ol class="breadcrumb" style="margin:0;">
                    <li class="breadcrumb-item"><a href="/"><?= $this->te('Home') ?></a></li>
                    <li class="breadcrumb-item"><a href="/loans/devices"><?= $this->te('Leihgeräte') ?></a></li>
                    <li class="breadcrumb-item active"><?= $this->e($device['title']) ?></li>
                </ol>
            </div>
        </div>
        <div class="content-header-actions">
            <span class="status-pill <?= $spill ?>"><?= $slabel ?></span>
            <a href="/loans/devices" class="btn btn-default btn-sm">
                <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 5l-7 7 7 7"/></svg>
                <?= $this->te('Ger&auml;teliste') ?>
            </a>
            <?php if ($can_issue && in_array($device['status'], ['available','reserved'])): ?>
                <a href="/loans/issue/<?= $device['id'] ?>" class="btn btn-success btn-sm">
                    <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M5 12h14M12 5l7 7-7 7"/></svg>
                    <?= $this->te('Ausgeben') ?>
                </a>
            <?php endif; ?>
            <?php if ($can_manage): ?>
                <a href="/loans/devices/<?= $device['id'] ?>/edit" class="btn btn-default btn-sm">
                    <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z"/></svg>
                    <?= $this->te('Bearbeiten') ?>
                </a>
            <?php endif; ?>
        </div>
    </div>

    <!-- Body -->
    <div class="page-body lds-layout">
        <!-- Main -->
        <div class="lds-main">
            <!-- History -->
            <div class="detail-card">
                <div class="detail-card-header">
                    <span class="detail-card-title"><?= $this->te('Ausleihhistorie') ?></span>
                    <span style="font-size:0.78rem;color:var(--gray-400);"><?= count($history) ?> Eintr&auml;ge</span>
                </div>
                <?php if (empty($history)): ?>
                    <div style="padding:2rem;text-align:center;color:var(--gray-400);font-size:0.88rem;"><?= $this->te('Dieses Ger&auml;t wurde noch nie ausgeliehen.') ?></div>
                <?php else: ?>
                <div class="table-wrapper" style="border:none;border-radius:0;">
                    <table class="data-table">
                        <thead>
                            <tr>
                                <th scope="col"><?= $this->te('Zeitraum') ?></th>
                                <th scope="col"><?= $this->te('Ausleiher') ?></th>
                                <th scope="col"><?= $this->te('Zweck') ?></th>
                                <th scope="col"><?= $this->te('Ausgegeben von') ?></th>
                                <th scope="col"><?= $this->te('Zur&uuml;ck von') ?></th>
                                <th scope="col"><?= $this->te('Zubeh&ouml;r') ?></th>
                                <th scope="col"><?= $this->te('Unterschrift') ?></th>
                                <th scope="col"><?= $this->te('Status') ?></th>
                                <th scope="col"></th>
                            </tr>
                        </thead>
                        <tbody>
                            <?php foreach ($history as $h):
                                [$hl, $hc] = $lendingStatusCfg[$h['status']] ?? ['?','status-pill--neutral'];
                            ?>
                            <tr>
                                <td>
                                    <span style="font-weight:600;color:var(--gray-900);"><?= date('d.m.Y', strtotime($h['planned_start'])) ?></span>
                                    <span style="color:var(--gray-400);"> – </span>
                                    <?= date('d.m.Y', strtotime($h['planned_end'])) ?>
                                </td>
                                <td style="font-weight:600;"><?= $this->e($h['borrower_name']) ?></td>
                                <td style="color:var(--gray-500);"><?= $this->e($h['purpose'] ?? '–') ?></td>
                                <td><?= $this->e($h['issued_by_name'] ?? '–') ?></td>
                                <td><?= $this->e($h['returned_by_name'] ?? '–') ?></td>
                                <td style="color:var(--gray-500);font-size:0.78rem;">
                                    <?php if ($h['acc_out'] > 0): ?>
                                        <?= $h['acc_in'] ?>/<?= $h['acc_out'] ?> zur&uuml;ck
                                    <?php else: ?>
                                        –
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <?php if (!empty($h['signature_data'])): ?>
                                        <span title="Unterschrift erhalten am <?= $this->te('{zeitpunkt} Uhr', ['zeitpunkt' => date('d.m.Y H:i', strtotime($h['signature_obtained_at']))]) ?>"
                                              style="display:inline-flex;align-items:center;gap:0.3rem;font-size:0.78rem;font-weight:600;color:var(--green-700);">
                                            <svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M20 6L9 17l-5-5"/></svg>
                                            <?= $this->te('Vorhanden') ?>
                                        </span>
                                    <?php else: ?>
                                        <span style="color:var(--gray-300);">–</span>
                                    <?php endif; ?>
                                </td>
                                <td>
                                    <span class="status-pill <?= $hc ?>"><?= $hl ?></span>
                                </td>
                                <td>
                                    <a href="/loans/lendings/<?= $h['id'] ?>"><?= $this->te('Details') ?></a>
                                </td>
                            </tr>
                            <?php endforeach; ?>
                        </tbody>
                    </table>
                </div>
                <?php endif; ?>
            </div>
        </div>

        <!-- Sidebar -->
        <div class="lds-aside">
            <!-- Status & Info -->
            <div class="detail-card">
                <div class="detail-card-header"><span class="detail-card-title"><?= $this->te('Ger&auml;teinfo') ?></span></div>
                <div class="detail-card-body">
                    <div class="lds-info-list">
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Status') ?></span>
                            <span class="lds-info-value">
                                <span class="status-pill <?= $spill ?>"><?= $slabel ?></span>
                            </span>
                        </div>
                        <?php if ($device['type']): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Typ') ?></span>
                            <span class="lds-info-value"><?= $this->e($device['type']) ?></span>
                        </div>
                        <?php endif; ?>
                        <?php if ($device['serial_number']): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Seriennummer') ?></span>
                            <span class="lds-info-value" style="font-family:monospace;"><?= $this->e($device['serial_number']) ?></span>
                        </div>
                        <?php endif; ?>
                        <?php if (!empty($device['inventory_number'])): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Inventarnummer') ?></span>
                            <span class="lds-info-value" style="font-family:monospace;"><?= $this->e($device['inventory_number']) ?></span>
                        </div>
                        <?php endif; ?>
                        <?php if (!empty($device['storage_location'])): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Lagerort') ?></span>
                            <span class="lds-info-value"><?= $this->e($device['storage_location']) ?></span>
                        </div>
                        <?php endif; ?>
                        <?php if ($device['purchase_price'] !== null && $device['purchase_price'] !== ''): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Anschaffungswert') ?></span>
                            <span class="lds-info-value"><?= $this->e($this->money((float)$device['purchase_price'])) ?></span>
                        </div>
                        <?php endif; ?>
                        <?php if (!empty($device['purchase_date'])): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Kaufdatum') ?></span>
                            <span class="lds-info-value"><?= date('d.m.Y', strtotime((string)$device['purchase_date'])) ?></span>
                        </div>
                        <?php endif; ?>
                        <?php if ($device['created_by_name']): ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Angelegt von') ?></span>
                            <span class="lds-info-value"><?= $this->e($device['created_by_name']) ?></span>
                        </div>
                        <?php endif; ?>
                        <div class="lds-info-row">
                            <span class="lds-info-label"><?= $this->te('Erstellt am') ?></span>
                            <span class="lds-info-value"><?= date('d.m.Y', strtotime($device['created_at'])) ?></span>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Description -->
            <?php if (!empty($device['description'])): ?>
            <div class="detail-card">
                <div class="detail-card-header"><span class="detail-card-title"><?= $this->te('Beschreibung') ?></span></div>
                <div class="detail-card-body">
                    <p class="lds-description"><?= $this->e($device['description']) ?></p>
                </div>
            </div>
            <?php endif; ?>

            <!-- Accessories -->
            <div class="detail-card">
                <div class="detail-card-header">
                    <span class="detail-card-title"><?= $this->te('Zubeh&ouml;r') ?></span>
                    <span style="font-size:0.78rem;color:var(--gray-400);"><?= count($accessories) ?> Teile</span>
                </div>
                <div class="detail-card-body">
                    <?php if (empty($accessories)): ?>
                        <p style="font-size:0.85rem;color:var(--gray-400);text-align:center;padding:0.5rem 0;"><?= $this->te('Kein Zubeh&ouml;r hinterlegt.') ?></p>
                    <?php else: ?>
                        <div class="lds-acc-list">
                            <?php foreach ($accessories as $acc): ?>
                            <div class="lds-acc-item">
                                <svg class="lds-acc-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M20.24 12.24a6 6 0 00-8.49-8.49L5 10.5V19h8.5z"/><line x1="16" y1="8" x2="2" y2="22"/><line x1="17.5" y1="15" x2="9" y2="15"/></svg>
                                <div>
                                    <div class="lds-acc-name"><?= $this->e($acc['name']) ?></div>
                                    <?php if (!empty($acc['description'])): ?>
                                        <div class="lds-acc-desc"><?= $this->e($acc['description']) ?></div>
                                    <?php endif; ?>
                                </div>
                            </div>
                            <?php endforeach; ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>

            <!-- Notes -->
            <?php if (!empty($device['notes'])): ?>
            <div class="detail-card">
                <div class="detail-card-header"><span class="detail-card-title"><?= $this->te('Interne Notizen') ?></span></div>
                <div class="detail-card-body">
                    <p class="lds-description" style="color:var(--gray-500);"><?= $this->e($device['notes']) ?></p>
                </div>
            </div>
            <?php endif; ?>
        </div>
    </div>
</div>