{* @compiler:inline-only *}
<div class="seller-search">
   <div class="form-group">
      <input type="text" class="form-control" placeholder="{t}Zadejte město, PSČ nebo ulici{/t}" data-seller-search-input="reservation">
      <i class="fc icons_search"></i>
   </div>
</div>
<div class="product-reservation-sellers-list sellers-search-list" data-seller-list="reservation">
   {get_sellers groupBy='data/city' assign='sellersGrouped' products=[$body.product.id => $body.product.variationId]}

   {* filter out sellers with reservation_disabled=Y *}
   {foreach $sellersGrouped as $city => $sellers}
       {foreach $sellers as $sellerId => $seller}
           {if $seller.data.reservation_disabled == 'Y'}
              {$sellersGrouped[$city][$sellerId] = null}
              {$sellersGrouped[$city] = array_filter($sellersGrouped[$city])}
           {/if}
       {/foreach}
       {$sellersGrouped = array_filter($sellersGrouped)}
   {/foreach}

   <div>
      {foreach $sellersGrouped as $city => $sellers}
         {$city_instore = false}
         {foreach $sellers as $seller}
            {if $seller.in_store > 0}
               {$city_instore = true}
               {break}
            {/if}
         {/foreach}
         <div class="sellers-city">
            <button type="button" class="sellers-opener" data-opener="[data-{$city|replace:" ":"-"|strip_accent}]">
               <strong class="title">{$city}</strong>
               <span class="count{if $city_instore} has-pieces{/if}">{count($sellers)} {t count=count($sellers)}prodejna{/t}</span>
            </button>
            <div class="opener-content" data-{$city|replace:" ":"-"|strip_accent} style="display: none;">
               {foreach $sellers as $seller}
                  {block "sellers-item"}
                     <div class="sellers-item seller-row">
                        <div class="content">
                           <div>
                              <p class="name">{$seller.title}</p>
                              <span class="address">{$seller.city}, {$seller.street} {$seller.number}</span>
                           </div>
                           <div class="seller-delivery-wrapper">
                              {if $seller.in_store > 0}
                                 <p class="delivery delivery-0">{t}Skladem na prodejně{/t}</p>
                              {elseif $seller.in_store_main > 0 || $seller.in_store_other > 0}
                                  <p class="delivery delivery-1">{t}Není skladem na prodejně{/t}</p>
                              {else}
                                 <p class="delivery delivery-1">{t}Není skladem{/t}</p>
                              {/if}
                           </div>
                        </div>
                        <div class="seller-btn-wrapper">
                           {if $seller.in_store > 0}
                              <a href="{path('kupshop_reservation_reservation_focusreservationcreate', ['productId' => $body.product.id, 'variationId' => $body.product.variationId, 'sellerId' => $seller.id])}"
                                 data-ondemand="" class="btn-link">{t}Zvolit prodejnu{/t}</a>
                           {/if}
                        </div>
                     </div>
                  {/block}
               {/foreach}
            </div>
         </div>
      {/foreach}
   </div>

   <div class="seller-not-found" data-seller-not-found="reservation" style="display: none;">
      <p>{t}Nenalezena žádná prodejna.{/t}</p>
   </div>
</div>
