Files
product-slip/slips/templates/slips/products.html
2026-10-14 12:06:12 +03:30

100 lines
4.8 KiB
HTML

{% extends 'slips/base.html' %}
{% load static %}
{% block title %}Products — Label Printer{% endblock %}
{% block nav_products_active %}active{% endblock %}
{% block content %}
<div class="page-grid">
<!-- Add / Edit Product -->
<section class="card glass-card">
<div class="card-header">
<h2 class="card-title" id="product-form-title" data-i18n="add_product">+ Add New Product</h2>
<span class="card-badge badge-accent">📦</span>
</div>
<form id="product-form" class="form-stack">
<input type="hidden" id="edit-id" value="">
<div class="form-group">
<label for="prod-code" data-i18n="product_code">Product Code</label>
<input type="text" id="prod-code" required placeholder="ICJ/000">
</div>
<div class="form-group">
<label for="prod-desc" data-i18n="description">Description</label>
<input type="text" id="prod-desc" required placeholder="DIGITAL INK ...">
</div>
<div class="form-group">
<label for="prod-weight" data-i18n="default_weight">Default Weight</label>
<input type="number" id="prod-weight" value="5" step="1" min="1" required>
</div>
<div class="form-group">
<label class="checkbox-label">
<input type="checkbox" id="prod-requires-dates" checked>
<span data-i18n="requires_dates">Requires Date / Next Control</span>
</label>
</div>
<div class="form-actions-inline">
<button type="submit" class="btn btn-accent" id="product-save-btn" data-i18n="save">Save</button>
<button type="button" class="btn btn-ghost" id="product-cancel-btn" style="display:none;" onclick="cancelEdit()" data-i18n="cancel">Cancel</button>
</div>
</form>
</section>
<!-- Product List -->
<section class="card glass-card">
<div class="card-header">
<h2 class="card-title" data-i18n="products">Products</h2>
<div class="card-actions">
<button type="button" class="btn btn-ghost btn-sm" onclick="backupProducts()" data-i18n="backup">Backup</button>
<button type="button" class="btn btn-ghost btn-sm" onclick="document.getElementById('restore-file').click()" data-i18n="restore">Restore</button>
<input type="file" id="restore-file" accept="application/json,.json" hidden onchange="restoreProducts(this)">
<span class="card-badge badge-muted" id="product-count">{{ products|length }}</span>
</div>
</div>
<div class="table-wrap">
<table class="data-table" id="products-table">
<thead>
<tr>
<th data-i18n="product_code">Code</th>
<th data-i18n="description">Description</th>
<th data-i18n="default_weight">Weight</th>
<th data-i18n="requires_dates_short">Dates</th>
<th></th>
</tr>
</thead>
<tbody id="products-body">
{% for p in products %}
<tr id="product-row-{{ p.id }}">
<td class="mono">{{ p.code }}</td>
<td>{{ p.description }}</td>
<td class="mono">{{ p.default_net_weight }}</td>
<td>{{ p.requires_dates|yesno:"✓,—" }}</td>
<td>
<button type="button" class="btn btn-ghost btn-sm"
data-id="{{ p.id }}"
data-code="{{ p.code }}"
data-desc="{{ p.description }}"
data-weight="{{ p.default_net_weight }}"
data-requires-dates="{{ p.requires_dates|yesno:'true,false' }}"
onclick="editProduct(this)"
data-i18n="edit">Edit</button>
<button type="button" class="btn btn-ghost btn-sm btn-danger"
onclick="deleteProduct({{ p.id }})"
data-i18n="remove">Remove</button>
</td>
</tr>
{% empty %}
<tr><td colspan="5" class="empty-state" data-i18n="no_products">No products yet</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</section>
</div>
<div id="toast" class="toast"></div>
{% endblock %}
{% block extra_scripts %}
<script src="{% static 'slips/js/products.js' %}"></script>
{% endblock %}