Files
Django_TasksApp/main/recipes/templates/recipes/stock_preview.html
T
2026-10-12 09:37:04 +02:00

13 lines
4.7 KiB
HTML

{% extends 'planner/base.html' %}{% load static %}
{% block title %}Review stock · {{ recipe.title }} · Tasknest{% endblock %}
{% block page_class %}recipes-page-content{% endblock %}
{% block content %}<link rel="stylesheet" href="{% static 'recipes/recipes.css' %}?v=4">
<div class="recipes-layout recipes-layout--form recipes-stock-preview">
<header class="recipes-form-header"><a href="{% url 'recipes:detail' recipe.api_id %}">← Back to {{ recipe.title }}</a><h1>Review inventory use</h1><p>Stock changes only after you confirm below.</p></header>
{% if error %}<p class="recipes-form-error" role="alert">{{ error }}</p>{% endif %}
<section class="recipes-panel"><h2>Recipe amounts</h2><form method="get" class="recipes-preview-options"><label>Servings<input type="number" name="servings" min="0.01" max="99999.99" step="0.01" value="{{ analysis.servings|floatformat:-2 }}"></label><label class="recipes-checkbox"><input type="checkbox" name="optional" value="1"{% if analysis.include_optional %} checked{% endif %}> Include optional ingredients</label><div class="recipes-preview-choices">{% for line in analysis.lines %}{% if line.substitutions %}<label>{{ line.name }} alternative<select name="sub_{{ line.ingredient.pk }}"><option value="">Original ingredient</option>{% for alternative in line.substitutions %}<option value="{{ alternative.pk }}"{% if line.selected_substitution == alternative.pk|stringformat:'s' %} selected{% endif %}>{{ alternative.name }} · {{ alternative.quantity|floatformat:-3 }} {{ alternative.unit }}</option>{% endfor %}</select></label>{% endif %}{% endfor %}</div><button type="submit" class="recipes-outline-button">Update preview</button></form></section>
<section class="recipes-panel"><h2>Ingredient checks</h2><ul class="recipes-ingredient-list">{% for line in analysis.lines %}<li><span>{{ line.name }}{% if line.source %}<small>From {{ line.source }}</small>{% endif %}<small class="recipes-stock-label recipes-stock-label--{{ line.status }}">{{ line.status|capfirst }}{% if line.reason %}: {{ line.reason }}{% endif %}</small>{% if line.ingredient.pk %}<small><a href="{% url 'recipes:substitution-add' line.ingredient.recipe.api_id line.ingredient.pk %}">Add a substitute</a></small>{% endif %}</span><strong>{{ line.quantity|floatformat:-3 }} {{ line.unit }}</strong></li>{% empty %}<li>No ingredients added yet.</li>{% endfor %}</ul><p><a href="{% url 'recipes:edit' recipe.api_id %}">Edit ingredient quantities and product matches</a></p></section>
<section class="recipes-panel"><h2>Package deductions</h2>{% if analysis.issues %}<ul class="recipes-preview-issues">{% for issue in analysis.issues %}<li>{{ issue }}</li>{% endfor %}</ul>{% endif %}{% for group in analysis.groups %}<div class="recipes-preview-group"><h3>{{ group.product.product_name }} <span class="recipes-stock-label recipes-stock-label--{{ group.status }}">{{ group.status|capfirst }}</span></h3><p>{{ group.stock_amount|floatformat:-3 }} {{ group.unit }} needed{% if group.plan %} · {{ group.plan.total|floatformat:-3 }} {{ group.unit }} available{% if group.plan.shortage %} · {{ group.plan.shortage|floatformat:-3 }} {{ group.unit }} missing{% endif %}{% endif %}</p>{% if group.plan %}{% for deduction in group.plan.deductions %}<div class="recipes-package"><div class="recipes-package__heading"><strong>Package {{ deduction.package.api_id|stringformat:'s'|slice:':8' }}</strong><span>{{ deduction.before|floatformat:-3 }} → {{ deduction.after|floatformat:-3 }} {{ deduction.unit }}</span></div><small>Use {{ deduction.amount|floatformat:-3 }} {{ deduction.unit }}{% if deduction.package.best_before %} · Best before {{ deduction.package.best_before }}{% endif %}</small><div class="recipes-fill" role="progressbar" aria-label="Package remaining after use" aria-valuenow="{{ deduction.after_percent }}" aria-valuemin="0" aria-valuemax="100"><span style="width:{{ deduction.after_percent }}%"></span></div></div>{% empty %}<p class="recipes-muted">No compatible packages.</p>{% endfor %}{% endif %}</div>{% empty %}<p class="recipes-muted">Match ingredients to inventory products to see a package plan.</p>{% endfor %}</section>
<section class="recipes-panel recipes-preview-confirm"><h2>Confirm inventory use</h2>{% if confirmation %}<p>This deducts the listed amounts from Kitchen Inventory. It does not log food in your diary.</p><form method="post" action="{% url 'recipes:stock-confirm' recipe.api_id %}">{% csrf_token %}<input type="hidden" name="confirmation" value="{{ confirmation }}"><button class="button" type="submit">Confirm and deduct stock</button></form>{% else %}<p>Resolve missing stock or unknown matches, then update the preview before confirming.</p>{% endif %}</section>
</div>{% endblock %}