<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{{ tran("{Production by orders}") }}</title>

    <!-- Note: To work in reverse proxy, we cannot use an absolute path beginning with / -->
    <link href="{{ url_prefix }}/static/style.css" rel="stylesheet"/>
    <link href="{{ url_prefix }}/static/vendor/bootstrap.min.css" rel="stylesheet" />
  </head>

  <body>

    <div class="w-100 p-4 print-repeated">

        {% include 'printouts/_logo.html' %}

        <!-- Head -->
        <div class="row mb-2 mt-3">

        <div class="col-6">
          <b>{{ setup.company_name }}</b>
          <div class="small">
              {{ setup.company_address }}<br>
              {{ setup.company_zip }}
              {{ setup.company_city }}<br>
              {{ tran("{company_idnum}") }}: {{ setup.company_idnum }}
              {{ tran("{Vat ID}") }}: {{ setup.company_vat_idnum }}<br>
              {{ setup.company_legal }}
          </div>
        </div>

        <div class="col-6">
            <h3 class="text-right">{{ tran("{Production by orders}") }}</h3>
        </div>

        </div>

        <!-- Production facility -->
        <div class="row border mb-2">
          <div class="col-4">
              <b>{{ tran("{facility}") }}</b>
              <div class="small">
                  {{ setup.facility_name }}<br>
                  {{ setup.facility_address }}<br>
                  {{ setup.facility_zip }}
                  {{ setup.facility_city }}<br>
                  {{ setup.facility_code }}
              </div>
          </div>
          <div class="col-4">
              <b>{{ tran("{produced total}") }}</b><br>
              {{ total_production }}&nbsp;m³
          </div>
          <div class="col-4">
              <table>
                  <tr>
                      <td class="text-right"><b>{{ tran("{since}") }}:</b></td>
                      <td class="px-2">{{ datetime_since }}</td>
                  </tr>
                  <tr>
                      <td class="text-right"><b>{{ tran("{until}") }}:</b></td>
                      <td class="px-2">{{ datetime_until }}</td>
                  </tr>
                  <tr>
                      <td class="text-right"><b>{{ tran("{Customer}") }}:</b></td>
                      <td class="px-2">{{ customer }}</td>
                  </tr>
                  <tr>
                      <td class="text-right"><b>{{ tran("{ConstructionSite}") }}:</b></td>
                      <td class="px-2">{{ site }}</td>
                  </tr>
                  <tr>
                      <td class="text-right"><b>{{ tran("{Recipe}") }}:</b></td>
                      <td class="px-2">{{ recipe }}</td>
                  </tr>
              </table>
          </div>
        </div>

        <!-- batches -->
        <table class="mb-4 small table table-bordered table-striped">
            <thead class="bold">
                <td>{{ tran("{t_human}") }}</td>
                <td>{{ tran("{Customer}") }}</td>
                <td>{{ tran("{ConstructionSite}") }}</td>
                <td>{{ tran("{registration_number}") }}</td>
                <td>{{ tran("{Recipe}") }}</td>
                <td>m³</td>
                <td>{{ tran("{sequence}") }}</td>
                <td>m³ {{ tran("{tot.}") }}</td>
                {% for name in material_names %}
                    <td class="text-right">{{ name }}</td>
                {% endfor %}
            </thead>
            {% for batch in batches %}
            <tr>
                <td>{{ batch._production_start_t_human }}</td>
                <td>{{ batch._delivery_order.customer }}</td>
                <td>{{ batch._delivery_order.construction_site }}</td>
                <td>{{ batch._delivery.car_registration_number }}</td>
                <td>{{ batch._delivery_order.r_name }}</td>
                <td>{{ batch.volume }}</td>
                <td>{{ batch._batch_sequence_str }}</td>
                <td>{{ batch._delivery_order.volume }}</td>
                {% for name in material_names %}
                    <td class="text-right">{{ consumption_by_batch_and_material[(batch.id, "_{}_str".format(name))] }}</td>
                {% endfor %}
            </tr>
            {% endfor %}
        </table>

      <div class="row printout-mini">
          <div class="col-5">{{ tran("{ORIGINAL}") }}</div>
          <div class="col-7 text-right">{{ tran("{asterix_footer}") }} {{ datetime_now }}</div>
      </div>

    </div>

    {% include 'printouts/_control_buttons.html' %}

  </body>
</html>
