{extends_parent}

{block "form-personal-data-address-title"}{/block}

{block 'delivery-place'}
{if $deliveryType}
   {$delivery = $deliveryType->getDelivery()}
   {if $delivery->getType() == Delivery::TYPE_POINT}
   <p class="h4">{t}Adresa dodání{/t}</p>
   <div class="cart-delivery-place">
      <p><strong>{$delivery->getName()}</strong></p>
   </div>
   {/if}
{/if}
{/block}

{block "form-different-delivery"}
   {ifmodule USER_ADDRESSES}
   {if !$deliveryType || $deliveryType->getDelivery()->requiresDeliveryAddress()}
      {get_addresses assign="user_addresses"}
      {$cartData = $body->getData()}

      {if $user_addresses}
         {$inputData = ['updateCart' => true]}
         {render_component name="Cart:HiddenAddressInput" data=$inputData assign="addressInput"}
         {$addressInput nofilter}

         {$selectData = ['selectedId' => $cartData.user_address_id, 'allowAddNew' => $dbcfg.edit_user_addresses]}
         {render_component name="Cart:UserAddressSelect" data=$selectData assign="addressSelect"}
         {$addressSelect nofilter}

         {if $dbcfg.edit_user_addresses}
            <div class="opener-content" id="different-address-content"
                 style="display:{if $cartData.user_address_id == 0}block{else}none{/if}">
               {block 'form-delivery-address'}
                  <div class="row">
                     <div class="{$column_class}">
                        <div class="form-group required">
                           <label for="name">{t}Jméno{/t}</label>
                           <input type="text" name="cart_data[new_address][name]" id="name" class="form-control"
                                  value="{$cartData.new_address.name}" autocomplete="off"
                                  data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="3">
                        </div>
                     </div>
                     <div class="{$column_class}">
                        <div class="form-group required">
                           <label for="surname">{t}Příjmení{/t}</label>
                           <input type="text" name="cart_data[new_address][surname]" id="surname" class="form-control"
                                  value="{$cartData.new_address.surname}" autocomplete="off"
                                  data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="3">
                        </div>
                     </div>

                     <div class="{$column_class}">
                        <div class="form-group">
                           <label for="phone">{t}Telefon{/t}</label>
                           <input type="text" name="cart_data[new_address][phone]" id="phone" class="form-control" value="{$cartData.new_address.phone}" autocomplete="off" data-bv-phone="true"
                              {if !($deliveryType and $deliveryType->isInPerson()) || $inpersonRequireAddress}
                              data-bv-phone-country="cart_data[new_address][country]"
                              {else}
                              data-bv-phone-country="{$ctrl.active_country}"
                              {/if}>
                        </div>
                     </div>
                     <div class="{$column_class}">
                        {block "delivery-street"}
                           <div class="form-group required">
                              <label for="street">{t}Ulice a č.p.{/t}</label>
                              <input type="text" name="cart_data[new_address][street]" id="street" class="form-control smartform-instance-delivery smartform-address-street-and-number"
                                     value="{$cartData.new_address.street}"{if $dbcfg.smartform == "Y" or $dbcfg.here_autocomplete == "Y"} autocomplete="off"{/if} data-field-delivery-street
                                     data-bv-notempty="true" data-bv-regexp="true" pattern=".*\S+\s+[0-9]+.*|.*\S+[0-9]+\s+.*"
                                     data-bv-regexp-message="{t}Doplňte prosím číslo popisné{/t}">
                           </div>
                        {/block}
                     </div>
                     <div class="{$column_class}">
                        <div class="zip-group">
                           <div class="form-group required">
                              <label for="city">{t}Město{/t}</label>
                              <input type="text" name="cart_data[new_address][city]" id="city" class="form-control smartform-instance-delivery smartform-address-city"
                                     value="{$cartData.new_address.city}"{if $dbcfg.smartform == "Y" or $dbcfg.here_autocomplete == "Y"} autocomplete="off"{/if} data-field-delivery-city
                                     data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2">
                           </div>
                           <div class="form-group required">
                              <label for="zip">{t}PSČ{/t}</label>
                              <input type="text" name="cart_data[new_address][zip]" id="zip" class="form-control smartform-instance-delivery smartform-address-zip" value="{$cartData.new_address.zip}"
                                 {if $dbcfg.smartform == "Y" or $dbcfg.here_autocomplete == "Y"} autocomplete="off"{/if} data-field-delivery-zip data-bv-notempty="true" data-bv-zipcode="true"
                                     data-bv-zipcode-country="cart_data[new_address][country]">
                           </div>
                        </div>
                     </div>
                     {block "form-delivery-country"}
                        <div class="{$column_class}">
                           <div class="form-group required">
                              <label for="country">{t}Stát{/t}
                                 {if $tpl_vars.delivery_country_picker}
                                    <a href="/{$body.steps.delivery.url}" class="cart-country-link">{t}Jiný stát?{/t}</a>
                                 {/if}
                              </label>
                              <select class="form-control" id="country" name="cart_data[new_address][country]" autocomplete="off"
                                      {if $cfg.Order.Countries|count == 1 || $tpl_vars.delivery_country_picker}readonly{/if}>
                                 {html_options options=$cfg.Order.Countries selected=$cartData.new_address.country|default:$ctrl.active_country}
                              </select>
                           </div>
                        </div>
                     {/block}

                     <div class="col-xxs-12">
                        <div class="form-group">
                           <label for="firm">{t}Upřesnění adresy (areál,...){/t}</label>
                           <input type="text" name="cart_data[new_address][firm]" id="firm" class="form-control"
                                  value="{$cartData.new_address.firm}" autocomplete="off"
                                  data-bv-stringlength="true" data-bv-stringlength-min="3">
                        </div>
                     </div>

                     <div class="col-xxs-12">
                        <div class="form-group">
                           <label for="cart_data[new_address][save]" class="custom-control custom-checkbox">
                              <input class="custom-control-input" type="checkbox" name="cart_data[new_address][save]"
                                     id="cart_data[new_address][save]" value="1">
                              <span class="custom-control-indicator"></span>
                              {t}Uložit mezi adresy{/t}
                           </label>
                        </div>
                     </div>
                  </div>
               {/block}
            </div>
         {/if}
      {elseif $dbcfg.edit_user_addresses or !$ctrl.logged}
         {$smarty.block.parent}
      {/if}

   {/if}
   {elsemodule}
   {$smarty.block.parent}
   {/ifmodule}
{/block}
