{% extends "base.html" %}
{% comment %}
Copyright (C) by BDE ENS Paris-Saclay
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}
{% load i18n crispy_forms_tags %}
{% load render_table from django_tables2 %}

{% block content %}
<div class="card bg-white mb-3">
  <h3 class="card-header text-center">
    {{ title }}
  </h3>
  <div class="card-body" id="form">
    <form method="post">
      {% csrf_token %}
      {{ form | crispy }}
      <button class="btn btn-primary" type="submit">{% trans "Submit"%}</button>
    </form>
    <div class="card-body">
    <h4>
      {% trans "Copy constructor" %}
      <a class="btn btn-secondary" href="{% url "food:basicfood_create" slug=slug %}">{% trans "New food" %}</a>
    </h4>
      <table class="table">
	<thead>
	  <tr>
	    <th class="orderable">
	      {% trans "Name" %}
	    </th>
	    <th class="orderable">
	      {% trans "Owner" %}
	    </th>
	    <th class="orderable">
	      {% trans "Expiry date" %}
	    </th>
	  </tr>
	</thead>
	<tbody>
	  {% for food in last_items %}
	    <tr>
		    <td><a href="{% url "food:basicfood_create" slug=slug %}?copy={{ food.pk }}">{{ food.name }}</a></td>
	      <td>{{ food.owner }}</td>
	      <td>{{ food.expiry_date }}</td>
	    </tr>
	  {% endfor %}
	</tbody>
      </table>
    </div>
  </div>
</div>
{% endblock %}
