{* @compiler:inline-only *}
{function cart_seller_row}
   <label for="seller{$seller.id}" class="seller-row custom-control custom-radio{if $seller.is_ordering_disabled == 'Y'} disabled{/if}">
      <input type="radio" name="{$deliveryPrefix}[seller_id]" value="{$seller.id}" id="seller{$seller.id}" class="custom-control-input"
             data-delivery-seller-input{if $info.id == $seller.id} checked{/if}>
      <span class="custom-control-indicator"></span>

      <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.availability == 2}
               <p class="delivery delivery-0">{t}Skladem na prodejně{/t}</p>
               <p class="small">{t date=$seller.deliveryDate|add_days:$addDays|format_date_locale_pretty:'d. L.':null:true}Můžeš mít ještě {date}{/t}</p>
            {else}
               <p class="delivery delivery-1">{t}Připravíme{/t}</p>
            {/if}
         </div>
      </div>
      <span class="btn-link">{t}Zvolit prodejnu{/t}</span>
   </label>
{/function}

{block 'customization'}
   {$groupBy = 'city'}
{/block}

<div class="delivery-class" data-delivery-class="odbernaprodejne">
   {if $object.cart_description}
      {$object.cart_description nofilter}
   {/if}

   {$info = $object->getInfo($object.zip)}
   {if !$info.id}
      {get_active_seller assign='active_seller'}
      {$info = $object->getInfo($active_seller.id)}
   {/if}

   {get_sellers cart=1 groupBy=$groupBy assign='grouped_sellers'}

   <div data-reload="sellerpoint" class="posta-info open">
      {if !$info.id}
         {get_active_seller assign='active_seller'}
         {$info = $object->getInfo($active_seller.id)}
      {/if}
      {if $info.id}
         {get_sellers cart=1 assign="sellersAll"}
         {$selectedSeller = $sellersAll[$info.id]}
         <input type="hidden" name="delivery_seller_valid" value="1">
         <div class="ordering-selected-seller">
            <div class="content content-first">

               <div>
                  <p class="name">{$info.name}</p>
                  <p class="address">{$selectedSeller.city}, {$selectedSeller.street} {$selectedSeller.number}</p>
               </div>
               <div class="seller-delivery-wrapper">
                  {if $selectedSeller.availability == 2}
                     <p class="delivery delivery-0">{t}Skladem na prodejně{/t}</p>
                     <p class="small">{t date=$selectedSeller.deliveryDate|add_days:$addDays|format_date_locale_pretty:'d. L.':null:true}Můžeš mít ještě {date}{/t}</p>
                  {else}
                     <p class="delivery delivery-1">{t}Připravíme{/t}</p>
                  {/if}
               </div>

               <div class="change-seller-wrapper">
                  <a href="[data-ordering-sellers]" data-opener="[data-ordering-sellers]">{t}Změnit prodejnu{/t}</a>
               </div>
            </div>

            {get_seller id=$info.id assign='selected_seller'}
            <div class="content">
               <div>
                  {if $selected_seller.data.display_opening_hours}
                     <p>{$selected_seller.data.display_opening_hours|nl2br nofilter}</p>
                  {else}
                     <table>
                        {$days = [
                        1 => "{t}Pondělí{/t}",
                        2 => "{t}Úterý{/t}",
                        3 => "{t}Středa{/t}",
                        4 => "{t}Čtvrtek{/t}",
                        5 => "{t}Pátek{/t}",
                        6 => "{t}Sobota{/t}",
                        7 => "{t}Neděle{/t}"
                        ]}
                        {for $i = 1 to 7}
                           <tr>
                              <td>{$days[$i]}:</td>
                              <td>
                                 {if $selected_seller.data['opening_hours'][$i][0]}
                                    {$selected_seller.data['opening_hours'][$i][0]} - {$selected_seller.data['opening_hours'][$i][1]}
                                 {else}
                                    {t}zavřeno{/t}
                                 {/if}
                              </td>
                           </tr>
                        {/for}
                     </table>
                  {/if}
               </div>
               <div>
                  <p>
                     {$selected_seller.phone}<br>
                     <a href="mailto:{$selected_seller.email}">{$selected_seller.email}</a>
                  </p>
               </div>
            </div>
         </div>
      {/if}
   </div>

   <div class="ordering-sellers" {if $info.id}style="display:none;"{/if} data-ordering-sellers="ordering">
      <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="ordering">
            <i class="fc icons_search"></i>
         </div>
      </div>
      <div class="sellers-list">
         <div class="sellers-list-inner sellers-search-list" data-seller-list="ordering">
            {foreach $grouped_sellers as $city => $sellers}
               {$city_instore = false}
               {foreach $sellers as $seller}
                  {if $seller.availability == 2}
                     {$city_instore = true}
                     {break}
                  {/if}
               {/foreach}

               {foreach $sellers as $seller}
                  {cart_seller_row}
               {/foreach}
            {/foreach}

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