<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>{{ tran("{pumping_sheet}") }}, #{{ pump_order._full_number }}</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="container print-repeated" id="main">

        {% 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 text-right">
            <h3>{{ tran("{pumping_sheet}") }}, #{{ pump_order._full_number }}</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("{certification}") }}</b>
              <div style="white-space: pre-wrap">{{ setup.certification_text }}</div>
          </div>
          <div class="col-4">
              <b>{{ tran("{t_human}") }}</b><br>
              {{ pump_order._t_human }}
          </div>
        </div>

        <!-- Customer -->
        <div class="row border mb-2">
          <div class="col-4">
              <b>{{ tran("{Customer}") }}</b><br>
              {{ pump_order.customer_name }}<br>
              {{ pump_order.customer_address }}<br>
              {{ pump_order.customer_zip }} {{ pump_order.customer_city }}<br>
              {{ tran("{company_idnum}") }}: {{ pump_order.customer_company_idnum }},
              {{ tran("{Vat ID}") }}: {{ pump_order.customer_vat_idnum }}
          </div>
          <div class="col-4">
              <b>{{ tran("{ConstructionSite}") }}</b><br>
              {{ pump_order.construction_site_name }}<br>
              {{ pump_order.construction_site_address }}<br>
              {{ pump_order.construction_site_zip }} {{ pump_order.construction_site_city }}<br>
          </div>
          <div class="col-4">
              <b>{{ tran("{Pump}") }}</b><br>
              {{ tran("{pump_registration_number}") }}: {{ pump_order.pump_registration_number }}<br>
              {{ pump_order.pump_pump_type }}
              <div class="small">
                  <b>{{ tran("{Driver}") }}</b><br>
                 {{ pump_order.pump_driver }}
                 {{ pump_order.pump_driver_contact }}
              </div>
          </div>
        </div>

        {% set currency = setup.currency_symbol %}
        {% set has_price = (pump_order.pump_price_per_hour and pump_order.hours) or (pump_order.pump_price_per_km and pump_order.kms) or pump_order._surcharges %}
        {% if has_price %}
        <!-- pump prices -->
        <div class="mt-3">
            <table class="w-100 table table-bordered">
                <tr class="bold">
                    <td class="py-1">{{ tran("{item}") }}</td>
                    <td class="py-1">{{ tran("{amount}") }}</td>
                    <td class="py-1">{{ tran("{unit}") }}</td>
                    <td class="py-1 text-right">{{ tran("{price_per_unit}") }}</td>
                    <td class="py-1 text-right">{{ tran("{price_total}") }}</td>
                </tr>
                {% if pump_order.hours and pump_order.pump_price_per_hour %}
                <tr>
                    <td style="width:20%;" class="py-1">{{ tran("{hours}") }}:</td>
                    <td class="py-1">{{ pump_order._hours_str }}</td>
                    <td class="py-1">h</td>
                    <td class="py-1 text-right">{{ pump_order._pump_price_per_hour_str }}&nbsp;{{ currency }}</td>
                    <td class="py-1 text-right">{{ pump_order._price_hours_str }}&nbsp;{{ currency }}</td>
                </tr>
                {% endif %}
                {% if pump_order.kms and pump_order.pump_price_per_km %}
                <tr>
                    <td style="width:20%;" class="py-1">{{ tran("{kms}") }}:</td>
                    <td class="py-1">{{ pump_order._kms_str }}</td>
                    <td class="py-1">km</td>
                    <td class="py-1 text-right">{{ pump_order._pump_price_per_km_str }}&nbsp;{{ currency }}</td>
                    <td class="py-1 text-right">{{ pump_order._price_kms_str }}&nbsp;{{ currency }}</td>
                </tr>
                {% endif %}
                {% for surcharge in pump_order._surcharges %}
                <tr>
                    <td class="py-1">{{ tran("{Surcharge}") }} - {{ surcharge.name }}:</td>
                    {% if surcharge.price_type == 0 %}
                        <td class="py-1">1</td>
                        <td class="py-1">x</td>
                        <td class="py-1 text-right">{{ surcharge._price_total_calculated_amount_str }}&nbsp;{{ currency }}</td>
                    {% elif surcharge.price_type == 2 %}
                        <td class="py-1">{{ surcharge.amount }}</td>
                        <td class="py-1">{{ surcharge.unit_name }}</td>
                        <td class="py-1 text-right">{{ surcharge._price_amount_str }}&nbsp;{{ currency }}</td>
                    {% else %}
                        <td class="py-1">—</td>
                        <td class="py-1">—</td>
                        <td class="py-1">—</td>
                    {% endif %}
                    <td class="py-1 text-right">
                        {{ surcharge._price_total_calculated_amount_str }}&nbsp;{{ currency }}
                    </td>
                </tr>
                {% endfor %}
                <tr class="bold">
                    <td colspan="4" style="width:20%;" class="py-1">{{ tran("{total}") }}:</td>
                    <td class="py-1 text-right">{{ pump_order._price_total_str }}&nbsp;{{ currency }}</td>
                </tr>
            </table>
        </div>
        {% endif %}

        <!-- Data to be filled in by hand -->
        <table class="w-100 table table-bordered small mt-4">
            <tr>
                <td style="padding: 5px;">{{ tran("{amount}") }}</td>
                <td style="padding: 5px;">{{ tran("{paid_in_cash}") }}</td>
                <td colspan=2 style="padding: 5px;">{{ tran("{different_tariff_note}") }}</td>
            </tr>
            <tr>
                <td style="padding: 5px;"><br><br></td>
                <td style="padding: 5px;"></td>
                <td colspan=2 style="padding: 5px;"></td>
            </tr>
            <tr>
                <td style="padding: 5px;">{{ tran("{station_departure}") }}</td>
                <td style="padding: 5px;">{{ tran("{kms}") }}</td>
                <td style="padding: 5px;">{{ tran("{site_arrival}") }}</td>
                <td style="padding: 5px;">{{ tran("{hours}") }}</td>
            </tr>
            <tr>
                <td style="padding: 5px;"><br><br></td>
                <td style="padding: 5px;"></td>
                <td style="padding: 5px;"></td>
                <td style="padding: 5px;"></td>
            </tr>
            <tr>
                <td style="padding: 5px;">{{ tran("{station_arrival}") }}</td>
                <td style="padding: 5px;">{{ tran("{kms}") }}</td>
                <td style="padding: 5px;">{{ tran("{site_departure}") }}</td>
                <td style="padding: 5px;">&nbsp;</td>
            </tr>
            <tr>
                <td style="padding: 5px;"><br><br></td>
                <td style="padding: 5px;"></td>
                <td style="padding: 5px;"></td>
                <td style="padding: 5px;"></td>
            </tr>
            <tr>
                <td colspan=4 style="padding: 5px;">{{ tran("{surcharges_by_pricelists}") }}:</td>
            </tr>
            <tr>
                <td colspan=4 style="padding: 5px;">
                    {% for surcharge in pump_order._surcharges %}
                        <div class="row">
                            <div class="my-2 ml-3 d-flex col-1">
                                <div class="border mr-2 px-3 pt-2 pb-0">{{ surcharge.amount }}</div>
                                <div class="py-2 mr-2">
                                    {{ surcharge.unit_name or "x" }}
                                </div>
                            </div>
                            <div class="my-2 ml-3 py-2 col-6">
                                {{ surcharge.name }}
                            </div>
                        </div>
                    {% endfor %}
                </td>
            </tr>
        </table>

        <!-- naive separator -->
        <div class="mb-5">&nbsp;</div>

        <!-- Footer table -->
        <table class="w-100 table table-bordered">
          <tr>
            <td style="width:70%;">
                <div class="small"><b>{{ tran("{machine_operator}") }}</b></div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="border-top-dashed text-center small">{{ pump_order.car_driver }}</div>
            </td>
            <td rowspan="2" style="width:30%;">
                <div class="small"><b>{{ tran("{took_over}") }}</b></div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="mb-6">&nbsp;</div>
                <div class="border-top-dashed text-center small">{{ tran("{signature_hand}") }}</div>
            </td>
          </tr>
          <tr>
            <td class="small italic" style="white-space: pre-wrap">{{ setup.customer_consent_pump }}</td>
          </tr>
        </table>

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

    </div>

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

  </body>
</html>
