<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <style>
      @import url('https://fonts.googleapis.com/css2?family=Source+Sans+Pro&display=swap');
      @font-face {
        font-family: "Source Sans Pro";
        src: url("/fonts/source-sans-pro-regular.woff2") format("woff2");
        font-weight: 400;
        font-style: normal;
        font-display: swap;
      }
      @font-face {
        font-family: "Source Sans Pro";
        src: url("/fonts/source-sans-pro-600.woff2") format("woff2");
        font-weight: 600;
        font-style: normal;
        font-display: swap;
      }

body { font-family: "Source Sans Pro", sans-serif; }
      *, *:before, *:after {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
      }

      .clearfix:after {
        content: "";
        display: table;
        clear: both;
      }

      a {
        color: #d900ff;
        text-decoration: none;
      }

      body {
        position: relative;
        width: 21cm;
        height: 29.7cm;
        margin: 0 auto;
        color: #555555;
        background: #FFFFFF;
        font-size: 14px;
        font-family: 'Source Sans Pro', sans-serif;
        padding-bottom: 45px;
      }

      header {
        padding: 10px 0;
        margin-bottom: 20px;
        border-bottom: 1px solid #AAAAAA;
      }

      #logo {
        float: left;
        margin-top: 8px;
        width: 200px;
      }

      #logo img {
        height: 70px;
      }

      #details {
        margin: 0 auto;
        margin-bottom: 50px;
        width: 100%;
      }

      #company {
        float: left;
        text-align: left;
        width: 36%;
      }

      #company div {
        font-size: 10px;
        line-height: 14px;
      }

      #client {
        padding-left: 6px;
        border-left: 2px solid #d900ff;
        float: left;
        width: 30%;
        overflow: hidden;
        text-align: left;
      }

      #destination {
        padding-left: 6px;
        border-left: 2px solid #d900ff;
        float: right;
        width: 30%;
        overflow: hidden;
        text-align: left;
      }

      #client .address {
        padding-top: 2px;
      }

      #client .to {
        color: #777777;
      }

      h2.name {
        font-size: 1.4em;
        font-weight: normal;
        margin: 0;
      }

      #invoice {
        float: right;
        text-align: right;
        width: 48%;
        overflow: hidden;
      }

      #invoice h1 {
        color: #d900ff;
        font-size: 2.4em;
        line-height: 1em;
        font-weight: normal;
        margin: 0 0 10px 0;
      }

      #invoice .date {
        font-size: 1.1em;
        color: #777777;
      }

      table {
        width: 100%;
        border-collapse: collapse;
        border-spacing: 0;
        margin-bottom: 20px;
      }

      table th,
      table td {
        padding: 20px;
        background: #EEEEEE;
        text-align: center;
        border-bottom: 1px solid #FFFFFF;
      }

      table th {
        white-space: nowrap;
        font-weight: normal;
      }

      table td {
        text-align: right;
      }

      table td h3 {
        color: #d900ff;
        font-size: 1.0em;
        font-weight: normal;
        margin: 0 0 0.2em 0;
      }

      table .desc {
        text-align: left;
        width: 30%;
      }

      table td.desc p {
        font-size: 0.6em;
      }

      table td.desc h2 {
        font-size: 0.8em;
      }

      table .cl, table .vat {
        background: #DDDDDD;
        width: 10%;
        text-align: left;
      }

      table .qty, table .unit {
        width: 10%;
        text-align: left;
      }

      table .total {
        background: #d900ff;
        color: #FFFFFF;
        width: 15%;
        text-align: right;
      }

      table td.unit,
      table td.vat,
      table td.qty,
      table td.cl,
      table td.discount,
      table td.total {
        font-size: 1.0em;
      }

      table th.unit,
      table th.vat,
      table th.qty,
      table th.cl,
      table th.discount,
      table th.total {
        font-size: 0.6em;
      }

      table tbody tr:last-child td {
        border: none;
      }

      #notices{
        padding-left: 6px;
        border-left: 2px solid #d900ff;
      }

      #notices .notice {
        font-size: 0.8em;
      }

      footer {
        color: #777777;
        width: 100%;
        height: 30px;
        position: fixed; 
        bottom: 0;
        border-top: 1px solid #AAAAAA;
        padding: 8px 0;
        text-align: center;
        background: #fff;
      }

      footer p {
        font-size: 1.4em;
      }
    </style>
  </head>

  <body>
    <header class="clearfix">
      <div id="logo">
        <img src="{{assets.logoUrl}}" />
        <h6>{{t.subtitle}}</h6>
      </div>

      <div id="invoice">
        <h1>{{ t.quote}}</h1>
         <div class="date">{{t.date}}: {{invoice.date_invoice}}</div>

        {{#if invoice.number}}
          <div class="date">{{t.ref_quote}}: {{invoice.number}}

            {{#if order.id_orders}}
              - {{t.ref_order}}: {{order.id_orders}}
            {{/if}}
            {{#if order.id_carts}}
              - {{t.ref_cart}}: {{order.id_carts}}
            {{/if}}
          </div>
        {{/if}}

        {{#if order.id_resellers}}
          <div class="date">{{t.reseller_id}}: {{order.id_resellers}}</div>
        {{/if}}
      </div>
    </header>

    <main>
      <div id="details" class="clearfix">
        <div id="company">
          <h2 class="name">{{config.header}}</h2>
          <div>{{config.address}}</div>
          <div>{{config.zip_code}} | {{config.city}} | {{config.country}}</div>
          <div>C.F. / Partita IVA: {{config.vat_number}}</div>
          <div>Codice Univoco: {{config.sdi_code}}</div>
          <div>PEC: {{config.pec}}</div>
          <div>Tel: {{config.phone}}</div>
          <div><a href="mailto:{{config.email}}">{{config.email}}</a></div>
          <div><a href="{{config.website}}">{{config.website}}</a></div>
        </div>

        <div id="destination">
          <div class="to">{{t.destination}}:</div>
          <h2 class="name">{{address.header}}</h2>

          {{#if address.co}}
            <div class="address">C/O {{address.co}}</div>
          {{/if}}

          {{#if address.ca}}
            <div class="address">C/A {{address.ca}}</div>
          {{/if}}

          <div class="address">{{address.address}}</div>
          <div class="address">{{address.zip_code}}</div>
          <div class="address">{{address.city}} {{address.state}}</div>
          <div class="address">{{t.tel}} {{address.phone_prefix}} {{address.phone}}</div>
        </div>

        <div id="client">
          <div class="to">{{t.customer}}:</div>
          <h2 class="name">{{invoiceData.header}}</h2>

          {{#if invoiceData.address}}
            <div class="address">{{invoiceData.address}}</div>
          {{/if}}

          {{#if invoiceData.zip_code}}
            <div class="address">{{invoiceData.zip_code}}, {{invoiceData.city}} {{invoiceData.state}}</div>
          {{/if}}

          {{#if invoiceData.fiscal_code}}
            <div class="address"><b>{{t.fiscal_code}}:</b> {{invoiceData.fiscal_code}}</div>
          {{/if}}

          {{#if invoiceData.sdi_code}}
            <div class="address"><b>SDI:</b> {{invoiceData.sdi_code}}</div>
          {{/if}}

          {{#if invoiceData.pec}}
            <div class="address"><b>PEC:</b> {{invoiceData.pec}}</div>
          {{/if}}

          {{#if invoiceData.vat_number}}
            <div class="address"><b>{{t.vat_number}}:</b> {{invoiceData.vat_number}}</div>
          {{/if}}

          {{#if order.email}}
            <div class="email">
              <a href="mailto:{{order.email}}">{{order.email}}</a>
            </div>
          {{/if}}
        </div>
      </div>

      <table border="0" cellspacing="0" cellpadding="0">
        <thead>
          <tr>
            <th class="desc">{{t.description}}</th>
            <th class="qty">{{t.quantity}}</th>
            <th class="unit">{{t.unit_price}}</th>
            <th class="cl">LT</th>
            <th class="discount">{{t.discount}}</th>
            <th class="total">{{t.total}} {{currency}}</th>
            <th class="vat">{{t.vat}} %</th>
          </tr>
        </thead>

        <tbody>
          {{#each products}}
            <tr>
              <td class="desc">
                <h3>{{this.title}}</h3>

                {{#if this.typology}}
                  <p><b>{{../t.typology}}:</b> {{this.typology}}</p>
                {{/if}}

                {{#if this.containerCapacity}}
                  <p><b>{{../t.format}}:</b> {{this.containerCapacity}}</p>
                {{/if}}

                {{#if this.alcoholGradation}}
                  <p><b>{{../t.alcohol_gradation}}:</b> {{this.alcoholGradation}}%</p>
                {{/if}}
              </td>

              <td class="qty">{{this.quantity}}</td>
              <td class="unit">{{formatNumber this.price_final_taxes_excluded}}</td>

              <td class="cl">
                {{#if this.liters}}
                  {{formatNumber this.liters}}
                {{else}}
                  {{#if this.containerCapacity}}
                    {{mul this.containerCapacity this.quantity}}
                  {{/if}}
                {{/if}}
              </td>

              <td class="discount">{{formatNumber this.discounts_product_percentage}}</td>
              <td class="total">
                {{#if (gt this.total_discount 0)}}
                  {{formatNumber this.total_price_taxes_excluded}}
                {{else}}
                  {{formatNumber this.total_price_final_taxes_excluded}}
                {{/if}}
              </td>
              <td class="vat">{{formatNumber this.tax}}</td>
            </tr>
          {{/each}}

 
          {{#each shippings}}
            <tr>           
              <td class="desc">
                <h2>{{../t.shipping}}</h2>
              </td>
              <td class="qty">1</td>
              <td class="unit">{{formatNumber this.price_final_taxes_excluded}}</td>
              <td class="cl"></td>
              <td class="discount"></td>
              <td class="total">{{ formatNumber this.price_final_taxes_excluded}}</td>
              <td class="vat">{{ formatNumber this.tax}}</td>
            </tr>
          {{/each}}
 

 
        </tbody>
      </table>

      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td colspan="2"></td>
          <td colspan="2">{{t.subtotal}}</td>
          <td colspan="2">{{currency}} {{formatNumber order.total_price_taxes_excluded}}</td>
          <td></td>
        </tr>

        {{#each vats}}
          <tr>
            <td colspan="2"></td>
            <td colspan="2">{{../t.aliquota}} {{@key}}%</td>
            <td colspan="2">{{formatNumber this.total_price_taxes_excluded}}</td>
            <td>{{../currency}} {{formatNumber this.total_taxes}}</td>
          </tr>
        {{/each}}

        <tr>
          <td colspan="2"></td>
          <td colspan="2">{{t.vat}}</td>
          <td colspan="2"></td>
          <td>{{currency}} {{formatNumber order.total_taxes}}</td>
        </tr>

        <tr>
          <td colspan="2"></td>
          <td colspan="2"></td>
          <td colspan="2"><b>{{t.total_to_pay}}</b></td>
          <td>{{currency}} {{formatNumber order.total_to_pay}}</td>
        </tr>
      </table>

      <div id="notices">
        <div class="notice">
          {{t.payment}}: <br>
          <br><b>{{t.payment_method}}:</b> {{t.bank_transfer}}
          <br><b>{{t.total_to_pay}}:</b> {{currency}} {{formatNumber order.total_to_pay}}
          <br><b>IBAN:</b> {{config.iban}}
          <br><b>SWIFT:</b> {{config.swift}}
          <br><b>{{t.bank}}:</b> {{config.bank}}
          <br><b>{{t.bank_account}}:</b> {{config.account}}
          <br><b>{{t.causal}}:</b> {{t.payment}} {{t.quote}} 
          {{#if invoice.number}}
            {{t.number}}: {{invoice.number}}
          {{/if}}
          {{#if order.id_orders}}
            - {{t.ref_order}}: {{order.id_orders}}
          {{/if}}
         </div>
      </div>
    </main>

    <footer>
      {{#if (eq order.total_to_pay 0)}}
        <p>{{t.free_operation}}</p>
      {{/if}}
    </footer>
  </body>
</html>
