{extends "ordering.tpl"}

{block "content"}
   {$deliveryType = $body->getDeliveryType()}
   <div class="cart-summary-message">
      <div class="alert alert-info">
         {t}Překontrolujte si košík a odešlete objednávku.{/t}
      </div>
   </div>
   <div class="orderview-row">
      <div class="column">
         <p class="title-default">{t}Kontaktní údaje{/t}</p>
         <ul>
            <li>{$body.invoice.name} {$body.invoice.surname}</li>
            <li>{$body.invoice.email}</li>
            <li>{$body.invoice.phone}</li>
         </ul>
      </div>

      {if $body.invoice.street}
         <div class="column">
            <p class="title-default">
               {if $body.delivery.name or ($deliveryType && $deliveryType->isInPerson())}
                  {t}Fakturační adresa{/t}
               {else}
                  {t}Dodací adresa{/t}
               {/if}
            </p>
            <ul>
               <li>{$body.invoice.street}</li>
               {if $body.invoice.custom_address}
                  <li>{$body.invoice.custom_address}</li>
               {/if}
               <li>{$body.invoice.zip} {$body.invoice.city}</li>
               {if $body.invoice.state}
                  <li>{$body.invoice.state}</li>
               {/if}
               {if $cfg.Order.Countries|count > 1}
                  <li>{$cfg.Order.Countries[$body.invoice.country]}</li>
               {/if}
            </ul>
         </div>
      {/if}

      {if $body.delivery.name}
         <div class="column">
            <p class="title-default">{if $delivery.class == "BalikNaPostu"}{t}Zboží doručíme na poštu{/t}{else}{t}Dodací adresa{/t}{/if}</p>
            <ul>
               {if $delivery.class == "BalikNaPostu"}
                  <li>{$delivery->printDeliveryInfo() nofilter}</li>
               {else}
                  <li>{$body.delivery.name} {$body.delivery.surname}</li>
               {/if}
               {if $body.delivery.firm}
                  <li>{$body.delivery.firm}</li>
               {/if}
               <li>{$body.delivery.street}</li>
               {if $body.delivery.custom_address}
                  <li>{$body.delivery.custom_address}</li>
               {/if}
               <li>{$body.delivery.zip} {$body.delivery.city}</li>
               {if $body.delivery.state}
                  <li>{$body.invoice.state}</li>
               {/if}
               {if $cfg.Order.Countries|count > 1}
                  <li>{$cfg.Order.Countries[$body.delivery.country]}</li>
               {/if}
               {if $body.delivery.phone}
                  <li>{$body.delivery.phone}</li>
               {/if}
            </ul>
         </div>
      {/if}

      {if $body.invoice.firm}
         <div class="column">
            <p class="title-default">{t}Firemní údaje{/t}</p>
            <ul>
               <li>{$body.invoice.firm}</li>
               <li>{t}IČO{/t}: {$body.invoice.ico}</li>
               {if $body.invoice.dic}
                  <li>{t}DIČ{/t}: {$body.invoice.dic}</li>
               {/if}
            </ul>
         </div>
      {/if}
   </div>

   {block "ordering-summary-note"}
      {if $body.note}
         <div class="cart-summary-note">
            <p class="title-default">{t}Poznámka k objednávce{/t}</p>
            <p>{$body.note|escape:'htmlall'|nl2br nofilter}</p>
         </div>
      {/if}
   {/block}

   {if $body.register}
      <p>{t ucet=$body.invoice.email escape=false}K objednávce Vám vytvoříme nový uživatelský účet
            <strong>{ucet}</strong>{/t}</p>
      <hr>
   {/if}
   <div class="cart-summary-overview">
      {if $deliveryType}
         <div>
            <div class="cart-summary-overview-header">
               <p class="title-default">{t}Doprava a platba{/t}</p>
               {* todo delivery date*}
               {* <p>Předpokládané doručení 9.2.</p>*}
            </div>

            {$delivery = $deliveryType->getDelivery()}
            <div class="cart-box-row cart-box-row-summary delivery-item delivery-item-{$delivery.class|lower}">
               <label class="delivery-content">
                  {if $delivery.photo}
                     <span class="img">{photo photo=$delivery.photo}</span>
                  {/if}
                  <span class="title">{$delivery.name}</span>

                  {block "summary-delivery-price"}
                     <span class="price">
                        {$deliveryPrice = $view->getDeliveryPrice($deliveryType.id_delivery)}
                        {if $delivery.exception}
                           {* nic *}
                        {elseif $deliveryPrice.value_with_vat->isPositive()}
                           {$deliveryPrice.value_with_vat|format_price}
                        {else}
                           {t}zdarma{/t}
                        {/if}
                     </span>
                  {/block}
               </label>
            </div>

            {$payment = $deliveryType->getPayment()}
            <div class="cart-box-row cart-box-row-summary payment-item payment-item-{$payment.class|lower}">
               <label class="delivery-content">
                  {if $payment}
                     {if $payment.photo}
                        <span class="img">{photo photo=$payment.photo}</span>
                     {/if}
                     <span class="name">{$payment->getName() nofilter}</span>
                  {else}
                     <span class="name">{$deliveryType->payment}</span>
                  {/if}

                  {block "summary-paymnent-price"}
                     <span class="price">
                        {$paymentPrice = $view->getPaymentPrice($deliveryType.id_payment)}
                        {if $paymentPrice != null}
                           {if $paymentPrice.value_with_vat->isPositive()}
                              {$paymentPrice.value_with_vat|format_price}
                           {else}
                              {t}zdarma{/t}
                           {/if}
                        {/if}
                     </span>
                  {/block}
               </label>
            </div>
         </div>
      {/if}
      <div>
         <div class="cart-summary-overview-header">
            <p class="title-default">{t}Produkty objednávky{/t}</p>
            <p>{$body.products|count}&nbsp{t}ks{/t}</p>
         </div>

         {include "ordering/ordering.summary.products.tpl"}
      </div>
   </div>
{/block}

{block 'cart-footer'}
   <div class="cart-footer">
      {include "ordering/ordering.pricebox.tpl" transport=1}
   </div>
{/block}

{block 'cart-btns'}
   {include "ordering/ordering.btns.tpl" submitName='SubmitOrder'}
{/block}

{block "js-dynamic-load" append}
   <script>
      {* prevent double form submit *}
      document.getElementById('cart').addEventListener('submit', (e) => {
         if (e.target.classList.contains('is-submitting')) {
            e.preventDefault();
            Sentry.captureMessage('Double form submit');
         }

         e.target.classList.add('is-submitting');
      });
   </script>
{/block}

