{% extends "base.html" %}
<!-- Load Internationalization utils-->
{% load i18n %}
{% load rules %}

{% block title %}{% trans 'Delivery Route Sheet' %} {% endblock %}

{% block content %}

{% has_perm 'sous_chef.edit' request.user as can_edit_data %}
{% include 'kitchen_count_steps.html' with step='delivery_sheet' %}

<div class="ui secondary pointing fluid menu">
    <h1 class="ui header">Route Sheet for: {{route.name}}</h1>
    <div class="right menu">
      <div class="ui item"><h3><i class="calendar icon"></i>{{ delivery_date }}</h3></div>
    </div>
</div>

<div class="ui basic segment no-print">
    <a href="javascript:window.print()" class="ui labeled icon right basic pink big button" title="{% trans 'Print the route sheet.' %}">
        <i class="print icon"></i>{% trans 'Route Sheet' %}
    </a>
</div>

<div class="ui row"></div>

<table class="ui three column very basic celled table">
  <thead>
   <tr class="top aligned">
    <th class="three wide">{% trans 'Dish' %}</th>
    <th class="one wide">{% trans 'Regular' %}</th>
    <th class="one wide">{% trans 'Large' %}</th>
   </tr>
  </thead>
  <tbody>
    {% for obj in summary_lines %}
      <tr>
        <td><strong>{{obj.component_group}}</strong></td>
        <td class="center aligned">{{obj.rqty}}</td>
        <td class="center aligned">{{obj.lqty}}</td>
      </tr>
    {% endfor %}
  </tbody>
</table>

<table class="ui very compact celled  table">
  <thead>
   <tr class="top center aligned">
    <th class="three wide">{% trans 'Client' %}</th>
    <th class="six wide">{% trans 'Note' %}</th>
    <th class="one wide">{% trans 'Item' %}</th>
    <th class="one wide">{% trans 'Qty' %}</th>
    <th class="one wide">{% trans 'Bill' %}</th>
   </tr>
  </thead>
  <tbody>
    {% for obj in detail_lines %}
      <tr>
        <td>
          <strong>{{obj.firstname}} {{obj.lastname}}</strong><br>
          {{obj.street}}<br>
          {% if obj.apartment %}
            {% trans 'Apt' %} {{obj.apartment}}<br>
          {% endif %}
          {{obj.phone}}
        </td>
        <td class="left aligned">{{obj.delivery_note}}</td>
        <td>
          {% for item in obj.delivery_items %}
            {{item.component_group}} {% if item.remark %}{{item.remark}}{% endif %}<br>
          {% endfor %}
        </td>
        <td class="center aligned">
          {% for item in obj.delivery_items %}
            {{item.total_quantity}}<br>
          {% endfor %}
        </td>
        <td class="center aligned">
          <div class="ui toggle checkbox no-print">
            <input name="include_a_bill" type="checkbox" {% if obj.include_a_bill %}checked="checked"{% endif %} data-url="{% url 'order:update_client_bill' obj.order_id %}" {% if not can_edit_data %}disabled="disabled"{% endif %}>
            <label></label>
          </div>
          <div class="print-only">
            {% if obj.include_a_bill %}
              {% trans 'Yes' %}
            {% else %}
              {% trans 'No' %}
            {% endif %}
          </div>
        </td>
      </tr>
    {% endfor %}
  </tbody>
</table>

<div class="actions">
  <a href="{% url 'delivery:routes' %}?delivery_date={{ delivery_date.isoformat }}" class="ui big labeled {% if orders == 0 %} disabled {% endif %} icon button" title="{% trans 'View routes list' %}">
    <i class="chevron left icon"></i>{% trans 'View routes' %}
  </a>
</div>
{% endblock %}
