{% extends "client/base.html" %}
<!-- Load internationalisation utils-->
{% load i18n %}
{% load admin_urls %}
{% load static %}
{% load rules %}
{% load sous_chef_extras %}

{% block title %}

  {{client}} - {% trans "Food preferences" %}

{% endblock %}

{% block subcontent %}
{% has_perm 'sous_chef.edit' request.user as can_edit_data %}

<div class="ui segment">
    <h3 class="ui header">
        {% trans 'Meal information' %}
        <div class="sub header">{% trans "Meal information of the referent person" %}.</div>
    </h3>
    {% if can_edit_data %}
    <a class="ui right floated small button" href="{% url 'member:member_update_dietary_restriction' pk=client.id %}">
        <i class="icon edit"></i>{% trans "Edit" %}
    </a>
    {% endif %}
    <div class="ui divider"></div>


    <h3 class="ui header">
        {% trans 'Meal status' %}
    </h3>
    <div>
      <a class="ui yellow label">{{client.get_status_display}}</a>
    </div>

    <h3 class="ui header">
        {% trans 'Delivery type' %}
    </h3>
    <div>
      <a class="ui yellow label">
        {{client.get_delivery_type_display}}
      </a>
      {% if client.delivery_type == 'O' %}
      {% for day, day_display in delivery_days %}
      <a class="ui basic yellow label">{{ day_display }}</a>
      {% endfor %}
    </div>
    {% endif %}

    <h3 class="ui header">
        {% trans 'Meal defaults' %}
    </h3>
    <div>
      <table class="ui celled table">
        <thead>
          <tr>
            <th></th>
            {% for tuple__day__day_display in weekdays %}
            <th style="white-space:nowrap" class="two wide">
              {{ tuple__day__day_display.1|slice:":3" }}
              {% if client.delivery_type == 'O' and tuple__day__day_display in delivery_days %}<i class="help-text shipping icon yellow" data-content="{% trans 'Ongoing delivery' %}"></i>{% endif %}
            </th>
            {% endfor %}
          </tr>
        </thead>
        <tbody>
          {% trans "No information provided." as help_text %}
          {% with empty_text="<span class='help-text' data-content='"|add:help_text|add:"'>-</span>" %}

          {% for component, component_display in components %}
          <tr>
            <td style="white-space:nowrap">
              {{ component_display }}
            </td>
            {% for day, day_display in weekdays %}
            <td>
              {{ meals_default|get_item:day|get_item:component|default_if_none:empty_text }}{% if component == "main_dish" %}{% with size=meals_default|get_item:day|get_item:"size" %}{% with size_str=size_choices|get_item:size %}{% if size %}<span class="help-text" data-content="{{ size_str }}">{{ size }}</span>{% endif %}{% endwith %}{% endwith %}{% endif %}
            </td>
            {% endfor %}
          </tr>
          {% endfor %}
          {% endwith %}
        </tbody>
      </table>
    </div>

    <h3 class="ui header">
        {% trans 'Restrictions' %}
    </h3>
    {% for restricted_item in client.restrictions.all %}
    <div class="ui label">
        {{ restricted_item.name }}
        <i class="delete icon" data-id={{restriction.id}} data-model="restriction"></i>
    </div>
    {% empty %}
    <div class="ui row">
        <em>{% trans "Yipee! No restriction" %}.</em>
    </div>
    {% endfor %}

    <h3 class="ui header">
        {% trans 'Food preparation' %}
    </h3>
    {% for option in client.food_preparation %}
    <div class="ui label">
        {{ option.name }}
        <i class="delete icon" data-id={{option.id}} data-model="client_option"></i>
    </div>
    {% empty %}
    <div class="ui row">
        <em>{% trans "Nope! Nothing specific" %}.</em>
    </div>
    {% endfor %}

    <h3 class="ui header">
        {% trans 'Ingredients to avoid' %}
    </h3>
    {% for ingredient_to_avoid in client.ingredients_to_avoid.all %}
    <div class="ui label">
        {{ ingredient_to_avoid.name }}
        <i class="delete icon" data-id={{ingredient_to_avoid.id}} data-model="ingredient_to_avoid"></i>
    </div>
    {% empty %}
    <div class="ui row">
        <em>{% trans "Yeah! Likes everything" %}!</em>
    </div>
    {% endfor %}

    <h3 class="ui header">
        {% trans 'Dish(es) to avoid' %}
    </h3>
    {% for component_to_avoid in client.components_to_avoid.all %}
    <div class="ui label">
        {{ component_to_avoid.name }}
        <i class="delete icon" data-id={{component_to_avoid.id}} data-model="component_to_avoid"></i>
    </div>
    {% empty %}
    <div class="ui row">
        <em>{% trans "Yeah! Likes everything" %}!</em>
    </div>
    {% endfor %}
</div>

{% endblock %}
