envanter-dokuman/views/products/list.ejs

69 lines
2.3 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="page-head">
<h1>Ürünler</h1>
<div class="page-actions">
<a href="/api/products/new" class="btn btn-primary">+ Yeni Ürün</a>
</div>
</div>
<div class="low-stock-banner <%= lowStockCount > 0 ? '' : 'hidden' %>">
⚠️ <strong><%= lowStockCount %></strong> ürün düşük stok seviyesinde.
</div>
<div class="card">
<form method="GET" action="/api/products" class="filter-bar">
<input type="text" name="search" placeholder="Ürün adı veya ID ara..." value="<%= search %>">
<select name="category">
<option value="">Tüm Kategoriler</option>
<% categories.forEach(c => { %>
<option value="<%= c.id %>" <%= selectedCategory == c.id ? 'selected' : '' %>><%= c.name %></option>
<% }) %>
</select>
<button type="submit" class="btn">Filtrele</button>
<a href="/api/products" class="btn btn-ghost">Sıfırla</a>
</form>
</div>
<div class="card">
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>Ürün Adı</th>
<th>Kategori</th>
<th>Fiyat</th>
<th>Stok</th>
<th>Durum</th>
<th>İşlemler</th>
</tr>
</thead>
<tbody>
<% if (products.length === 0) { %>
<tr><td colspan="7" class="muted center">Ürün bulunamadı. Yeni ürün ekleyin.</td></tr>
<% } %>
<% products.forEach(p => { %>
<tr>
<td><%= p.id %></td>
<td><a href="/api/products/<%= p.id %>"><%= p.name %></a></td>
<td><%= p.categoryName %></td>
<td><%= p.unitPrice.toLocaleString('tr-TR') %> ₺</td>
<td class="<%= p.lowStock ? 'badge-err' : '' %>"><%= p.stock %></td>
<td>
<% if (p.lowStock) { %>
<span class="tag tag-warn">⚠️ Düşük</span>
<% } else { %>
<span class="tag tag-ok">✓ Yeterli</span>
<% } %>
</td>
<td class="actions">
<a href="/api/products/<%= p.id %>" class="btn btn-sm" title="Detay">Gör</a>
<a href="/api/products/<%= p.id %>/edit" class="btn btn-sm" title="Düzenle">✏️</a>
<button class="btn btn-sm btn-danger delete-product" data-id="<%= p.id %>" title="Sil">🗑️</button>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
<script src="/js/products.js"></script>