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

{block "focus-title"}{t}Dostupnost na prodejnách{/t}{/block}

{block "focus-content"}
   <div>
       {get_sellers groupBy='data/city' assign='sellersGrouped' products=[$product.id => $product.variationId]}

       {foreach $sellersGrouped as $city => $sellers}
           {$city_instore = false}
           {foreach $sellers as $seller}
               {if $seller.in_store > 0}
                   {$city_instore = true}
                   {break}
               {/if}
           {/foreach}
         <a href="" class="delivery-inperson-city" data-opener="[data-in-person-{$city|strip_accent}]">
            <span>{$city}{if $city_instore}<span class="in_store_dot"></span>{/if}</span>
            <span>{$sellers|count} {t plural="prodejny" plural5="prodejen" count=$sellers|count}prodejna{/t}</span>
         </a>
         <div class="delivery-inperson-list" data-in-person-{$city|strip_accent} style="display: none;">
            <table data-availability-table>
               {foreach $sellers as $key => $seller}
                  {get_store_delivery_time id_store=$key id_product=$product.id id_variation=$product.variationId assign='addDays'}
                  <tr>
                     <td class="name"><a href="{path('shop_seller_seller_detail', ['id_seller' => $seller.id])}" target="_blank">{$seller.title}</a></td>
                     <td class="availability">
                        {if $product.variationId}
                           {if $seller.in_store > 0}
                              <span class="delivery-0">{t}Skladem na prodejně{/t}</span>
                           {else}
                              {t}k vyzvednutí{/t}&nbsp;{$smarty.now|add_days:$addDays|format_date_locale_pretty:'d. L.':null:true}
                           {/if}
                        {/if}
                     </td>
                     <td class="delivery delivery-{if $seller.in_store > 0}0{/if}">
                        {if $seller.in_store > 0}
                           {t}skladem{/t}
                        {else}
                           {t}připravíme{/t}
                        {/if}
                     </td>
                  </tr>
               {/foreach}
            </table>
         </div>
      {/foreach}
   </div>
{/block}
