<!doctype html>
<html lang="en">
<head>
  <%- include('partials/head', { title }) %>
</head>
<body class="print-body">
<main class="print-sheet">
  <header class="print-header">
    <img src="/images/logo.png" alt="GAPTECH Solutions Ltd">
    <div><p class="kicker">Request #<%= request.id %></p><h1 class="capitalize"><%= prettyType(request.request_type) %></h1><p class="muted">Submitted by <%= owner?.full_name || 'Unknown' %> on <%= fmtDate(request.submitted_at) %> · Status: <strong><%= requestStatusLabel(request) %></strong></p></div>
  </header>
  <section>
    <h2>Request details</h2>
    <dl class="detail-list"><% detailEntries(request.details).forEach(([label, value]) => { %><div><dt><%= label %></dt><dd><%= value %></dd></div><% }) %></dl>
  </section>
  <% const items = Array.isArray(request.details?.items) ? request.details.items : []; %>
  <% if (items.length && request.request_type === 'petty_cash') { %>
    <section><h2>Expense breakdown</h2><table><thead><tr><th>Item / service</th><th>Amount (KES)</th></tr></thead><tbody><% items.forEach((item) => { %><tr><td><%= item.description || '—' %></td><td><%= money(item.amount) %></td></tr><% }) %><tr><th>Total</th><th><%= money(request.details.amount_requested) %></th></tr></tbody></table></section>
  <% } else if (items.length) { %>
    <section><h2>Items</h2><table><% const modelSpec = (item) => [item.model, item.model_spec].filter(Boolean).join(' · '); const anyModelSpec = items.some((item) => modelSpec(item)); %><thead><tr><th>Stock type</th><% if (anyModelSpec) { %><th>Model / spec</th><% } %><th>Quantity</th><th>Issued units (serial number · IMEI → vehicle)</th></tr></thead><tbody><% items.forEach((item) => { %><tr><td><%= item.stock_type || item.description || '—' %></td><% if (anyModelSpec) { %><td><%= modelSpec(item) || '—' %></td><% } %><td><%= item.quantity || 0 %> <%= item.unit || 'Pcs' %></td><td class="pick-number"><% const lineLabels = issuedLineLabels(item); %><% if (lineLabels.length) { %><% lineLabels.forEach((label) => { %><div><%= label %></div><% }) %><% } else { %>—<% } %></td></tr><% }) %></tbody></table></section>
  <% } %>
  <footer class="print-footer"><span>GAPTECH Solutions Ltd · Fleet Management Systems &amp; IT Solutions</span><span>Printed <%= fmtDate(new Date()) %></span></footer>
  <button class="button primary no-print" type="button" onclick="window.print()">Print</button>
</main>
</body>
</html>
