{extends "focus/focus.base.tpl"}

{block "focus-title"}
    {t}Kdy zboží obdržím?{/t}
{/block}

{block "focus-content"}
    {if !$product}
        {$product = $body.product}
    {/if}
    {get_delivery_dates product=$product assign='deliveries'}
    {function deliveryRowItem}
        {if $show_images}
           <td class="img">
               {if $delivery.photo}
                   {photo photo=$delivery.photo}
               {/if}
           </td>
        {/if}
       <td class="name">{$delivery.name}</td>
       <td class="date">{$delivery.date|format_date_locale_pretty:'d. L.':null:true}</td>
       <td class="price">
           {if $delivery.price.value_with_vat->asFloat() > 0}
               {$delivery.price.value_with_vat|format_price}
           {else}
               {t}zdarma{/t}
           {/if}
       </td>
    {/function}

    {if $deliveries|count}
        {if !$hide_availability}
           <p class="delivery delivery-{$product.deliveryTime}">
               {if $product.inStore > 1 and !$product->isVirtual() and !$hide_instore}
                  <span data-instore>{$product.inStore} {t}ks{/t}</span>{* todo unit *}
               {/if}
               {$product.deliveryTimeText}
           </p>
        {/if}

        {if !$product->isVirtual()}
           <table>
               {foreach $deliveries.list as $delivery}
                   {if $delivery->isInPerson()}
                       {$hasInperson = true}{continue}
                   {/if}
                  <tr>
                      {deliveryRowItem}
                  </tr>
               {/foreach}

               {if $hasInperson}
                   {foreach $deliveries.list as $delivery}
                       {if $delivery->isInPerson()}
                          <tr class="inperson">
                              {deliveryRowItem}
                          </tr>
                       {/if}
                   {/foreach}
               {/if}
           </table>
        {/if}

        <p>{t}Termíny doručení jsou závislé na aktuální situaci a kapacitách přepravních společností.{/t}</p>
    {/if}
{/block}
