<div class="row">
    <div class="col-md-12 mt-2">
        <div class="card">
            <div class="card-body">
                <a href="/warehouses/list" class="btn btn-secondary mb-3">
                    Zurück zur Übersicht
                </a>

                <table class="table table-bordered table-striped">
                    <thead>
                        <!-- Section title row -->
                        <tr style="background-color: #f8d7da; font-weight: 600; color: red; font-size: 18px;">
                            <th colspan="<%= warehouses.length + 6 %>" class="text-start">
                                <%= sectionTitle %>
                            </th>
                        </tr>

                        <!-- Column headers -->
                        <tr class="thead-dark">
                            <th>Produkt</th>
                            <th>Artikel-Nr</th>
                            <th>Seriennummer</th>
                            <th>Lieferant</th>
                            <% warehouses.forEach(w=> { %>
                                <th>
                                    <%= w.warehouse_name %>
                                </th>
                                <% }) %>
                                    <th>Executed By</th>
                        </tr>
                    </thead>


                    <tbody>
                        <% if (serialRows.length> 0) { %>
                            <% serialRows.forEach(row=> { %>
                                <tr>
                                    <td>
                                        <%= row.product_name %>
                                    </td>
                                    <td>
                                        <%= row.part_number %>
                                    </td>
                                    <td>
                                        <%= row.serial_number || '' %>
                                    </td>
                                    <td>
                                        <%= row.supplier || '' %>
                                    </td>

                                    <% warehouses.forEach(w=> { %>
                                        <td>
                                            <span
                                                class="<%= row[w.warehouse_name] == 1 ? 'text-danger font-weight-bold' : '' %>">
                                                <%= row[w.warehouse_name] %>
                                            </span>
                                        </td>
                                        <% }) %>

                                            <td>
                                                <%= row.executed_by || '' %>
                                            </td>
                                </tr>
                                <% }) %>
                                    <% } else { %>
                                        <tr>
                                            <td colspan="<%= warehouses.length + 6 %>" class="text-center">Keine Daten
                                                gefunden</td>
                                        </tr>
                                        <% } %>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>