95 lines
7.3 KiB
HTML
95 lines
7.3 KiB
HTML
{% extends 'planner/base.html' %}{% load static %}
|
|
{% block title %}Bulk scan inventory · Tasknest{% endblock %}
|
|
{% block content %}
|
|
<link rel="stylesheet" href="{% static 'food/food.css' %}?v=20261026-location-3">
|
|
<main class="food-page inventory-scan-page">
|
|
<header class="food-heading">
|
|
<div><a href="{% url 'food:inventory' %}">← Kitchen inventory</a><h1>Bulk scan inventory</h1><p>Scan packages into a location, then review your session queue.</p></div>
|
|
</header>
|
|
{% if run %}
|
|
<section class="inventory-scan-location-panel" aria-labelledby="scan-current-location-title">
|
|
<div class="inventory-scan-location-summary">
|
|
<p class="inventory-kicker" id="scan-current-location-title">Current batch location</p>
|
|
<strong class="inventory-scan-location" data-scan-current-location aria-live="polite">{{ draft_batch.location.name }}</strong>
|
|
</div>
|
|
<form class="inventory-scan-location-form" data-scan-location-change
|
|
action="{% url 'food:inventory-scan-location' draft_batch.pk %}">
|
|
{% csrf_token %}
|
|
<label for="scan-current-location">Change location for this batch</label>
|
|
<div class="inventory-scan-location-actions">
|
|
<select id="scan-current-location" name="location_id" required>
|
|
{% for location in locations %}<option value="{{ location.pk }}" {% if location.pk == draft_batch.location_id %}selected{% endif %}>{{ location.name }}</option>{% endfor %}
|
|
</select>
|
|
<button class="button button--secondary" type="submit">Update current batch</button>
|
|
</div>
|
|
<p>Moves every scan in this unsaved batch. Previously saved batches stay in their locations. Use Save & next location to keep batches in different places.</p>
|
|
<p class="inventory-scan-error" data-scan-location-error role="alert" hidden></p>
|
|
</form>
|
|
</section>
|
|
{% endif %}
|
|
{% if not run %}
|
|
<section class="food-card inventory-scan-start">
|
|
<h2>Choose a starting location</h2>
|
|
<p>Choose where these packages will be stored before starting. Your session is saved as you scan, so you can return to it after navigating away.</p>
|
|
{% if start_error %}<p class="inventory-scan-error" role="alert">{{ start_error }}</p>{% endif %}
|
|
{% if locations %}
|
|
<form method="post" action="{% url 'food:inventory-scan-start' %}" class="inventory-scan-start-form">
|
|
{% csrf_token %}<label for="scan-start-location">Starting location</label>
|
|
<select id="scan-start-location" name="location_id" required>
|
|
<option value="" selected disabled>Choose a location</option>
|
|
{% for location in locations %}<option value="{{ location.pk }}">{{ location.name }}</option>{% endfor %}
|
|
</select>
|
|
<button class="button" type="submit">Start scanning</button>
|
|
</form>
|
|
{% else %}
|
|
<p>You need an inventory location before you can scan.</p><a class="button" href="{% url 'food:inventory-add' %}">Add an inventory location</a>
|
|
{% endif %}
|
|
</section>
|
|
{% else %}
|
|
<div class="inventory-scan-layout" data-inventory-scanner
|
|
data-run-id="{{ run.api_id }}"
|
|
data-batch-id="{{ draft_batch.pk }}"
|
|
data-current-location-id="{{ draft_batch.location_id }}"
|
|
data-location-url="{% url 'food:inventory-scan-location' draft_batch.pk %}"
|
|
data-create-url="{% url 'food:inventory-scan-create' run.api_id %}"
|
|
data-queue-url="{% url 'food:inventory-scan-queue' run.api_id %}"
|
|
data-submit-url="{% url 'food:inventory-scan-submit' draft_batch.pk %}"
|
|
data-zxing-url="{% static 'food/vendor/zxing-browser.min.js' %}">
|
|
<section class="inventory-scan-camera food-card" aria-label="Barcode scanner">
|
|
<div class="inventory-camera-label"><span class="inventory-camera-indicator" aria-hidden="true"></span><strong>Camera scanner</strong><span>Camera stays on while you confirm packages</span></div>
|
|
<div class="food-camera-frame"><video data-scanner-video autoplay muted playsinline aria-label="Camera preview"></video><div class="food-scan-guide" aria-hidden="true"></div></div>
|
|
<p data-scanner-status role="status" aria-live="polite">Camera is off. Start the camera or enter a barcode.</p>
|
|
<div class="food-actions"><button class="button" type="button" data-scanner-start>Start camera</button><button class="button button--secondary" type="button" data-scanner-stop hidden>Pause camera</button></div>
|
|
<form class="food-barcode-form inventory-scan-manual" data-scanner-form>
|
|
<label for="inventory-scanner-barcode">Enter barcode manually</label><div><input id="inventory-scanner-barcode" data-scanner-barcode name="barcode" inputmode="numeric" pattern="[0-9]{6,64}" autocomplete="off" required><button class="button button--secondary" type="submit">Add barcode</button></div>
|
|
</form>
|
|
<p class="food-attribution">Product data from <a href="https://world.openfoodfacts.org/" rel="noopener noreferrer">Open Food Facts</a>.</p>
|
|
</section>
|
|
<section class="inventory-scan-right">
|
|
<div class="inventory-scan-active-wrap" data-scan-active-wrap>
|
|
{% if active_item %}{% include 'food/partials/inventory_scan_active.html' with item=active_item locations=locations %}{% else %}
|
|
<article class="food-card inventory-scan-active inventory-scan-skeleton" data-scan-active hidden aria-live="polite"><p>Scan a product to begin.</p></article>
|
|
{% endif %}
|
|
</div>
|
|
<section class="food-card inventory-scan-queue" aria-labelledby="inventory-scan-queue-title">
|
|
<div class="inventory-scan-queue-heading"><div><p class="inventory-kicker">Current session</p><h2 id="inventory-scan-queue-title">Scan queue</h2></div><span data-scan-queue-count>{{ queued_count }} queued item{{ queued_count|pluralize }}</span></div>
|
|
<div id="inventory-scan-queue" data-scan-queue aria-live="polite" data-queue-url="{% url 'food:inventory-scan-queue' run.api_id %}">
|
|
{% include 'food/partials/inventory_scan_queue.html' with run=run batches=queue_batches %}
|
|
</div>
|
|
</section>
|
|
<section class="food-card inventory-scan-controls">
|
|
<p>The camera remains active as items move into the queue. Use the package controls to correct repeated scans or undo a count.</p>
|
|
<form data-scan-submit action="{% url 'food:inventory-scan-submit' draft_batch.pk %}">
|
|
{% csrf_token %}<label for="scan-next-location">Save this batch and scan next location</label>
|
|
<div class="inventory-scan-next-row"><select id="scan-next-location" name="next_location_id" aria-label="Next inventory location">{% for location in locations %}<option value="{{ location.pk }}" {% if location.pk == draft_batch.location_id %}selected{% endif %}>{{ location.name }}</option>{% endfor %}</select><button class="button button--secondary" type="button" data-scan-next disabled>Save & next location</button></div>
|
|
<button class="button inventory-scan-done" type="button" data-scan-done disabled>Done · process confirmed items</button>
|
|
</form>
|
|
<p class="inventory-scan-note">Processing runs in the background. Items without a confirmed product or valid package setup appear in Needs Review.</p>
|
|
</section>
|
|
</section>
|
|
</div>
|
|
{% endif %}
|
|
</main>
|
|
<script src="{% static 'food/scanner.js' %}?v=20261026-location-3" defer></script>
|
|
{% endblock %}
|