<!DOCTYPE html>
<html lang="fr">
  <head>
    <meta charset="UTF-8" />
    <title>
      {{ grouped_order.name }} - Liste des commandes
    </title>
    <style type="text/css">
      @page {
      {% if items|length > 6 %}
        size: letter landscape;
      {% else %}
        size: A4;
      {% endif %}
        margin: 2cm 1.5cm;
        @bottom-right{
          font-size: 10pt;
          font-family: sans-serif;
          content: "Liste générée par la Chariotte - chariotte.fr | Page " counter(page)"/" counter(pages);
        }
      }
      {% if items|length > 10 %} 
        .item_name {
          text-align:center;
          white-space:nowrap;
          -webkit-transform: rotate(-90deg);
          -moz-transform: rotate(-90deg);
          -ms-transform: rotate(-90deg);
          -o-transform: rotate(-90deg);
          transform: rotate(-90deg);
          font-size: 8pt;
        }

        .item_name div {
          margin:-10px -120% ;
          display:inline-block;
        }
        .item_name div:before{
            content:'';
            width:0;
            padding-top:110%;
            display:inline-block;
            vertical-align:middle;
        }
      {% endif %}

      body {
        font-family: sans-serif;
        font-size: 11pt;
      }

      table {
        border: 1px black solid;
        border-collapse: collapse;
        width: 100%;
      }

      th, td {
        vertical-align: center;
        padding: 3px 2px 2px 2px;
        border: 1px black solid;
        font-weight: normal;
        text-align: center;
      }

      th {
        page-break-inside: avoid;
        word-break: break-all;
        word-wrap: break-word;
        font-weight: bold;
      }

      h2 {
        margin-top: -1em;
        margin-bottom: 2em;
      }
    </style>
  </head>
  <body>
    <h2 style="text-align: center">
			{{ grouped_order.name }} - {{ grouped_order.delivery_date }}
    </h2>
    {% if items %}
    <table>
      <thead>
        <tr>
          <th style="text-align: center">Nom</th>
          {% for item in items %}
          <th class="item_name" style="font-weight: normal;">
            <div>{{ item.name }}</div>
          </th>
          {% endfor %}
          <th style="width: 2cm">Prix</th>
          <th style="font-size: 0.5em; width: 2em">OK</th>
        </tr>
      </thead>
      <tbody>
        <tr style="background-color: #bababa">
          <td style="text-align: left">Prix unitaire</td>
          {% for item in items %}
          <td>
            {{ item.price }} €
          </td>
          {% endfor %}
          <td></td>
          <td></td>
        </tr>
        <tr style="background-color: #bababa">
          <th style="text-align: left">TOTAL</th>
          {% for item in items %}
          <th>
            {{ item.ordered_nb }}
          </th>
          {% endfor %}
          <th>{{ grouped_order.total_price }} €</th>
          <th></th>
        </tr>
				{% for order, ordered_items in orders_dict.items %}
				<tr>
          <td>
            {{ order.author.last_name|upper }} {{ order.author.first_name }}
					</td>
          {% for ordered_item in ordered_items %}
          <td>
            {% if ordered_item > 0 %}
            {{ ordered_item }}
            {% endif %}
          </td>
          {% endfor %}
          <td>
            {{ order.price }} €
          </td>
          <td></td>
				</tr>
				{% endfor %}
      </tbody>
    </table>
    {% else %}
      Aucun produit n'a été commandé
    {% endif %}

  </body>
</html>
