{block 'login-block'}
   {if $ctrl.logged}
      <p class="logged-as">{t}Jste přihlášený jako uživatel {/t}{$ctrl.name} {$ctrl.surname} ({$ctrl.login}).</p>
      <input type="hidden" name="invoice[email]" value="{$ctrl.login}">
   {/if}
{/block}

<div class="cart-user-form-wrapper">
   {if !$ctrl.logged}
      {block 'form-header'}
         <div class="signinrow">
            {block "order-user-email"}
               <div class="form-group form-group-legend form-group-user-email required">
                  <label for="iemail" class="title-default">{t}Začněte zadáním e-mailu{/t}</label>
                  <input type="email" name="invoice[email]" id="iemail" value="{$body.invoice.email}"
                         class="form-control smartform-instance-invoice smartform-email"
                         data-bv-notempty="true" data-bv-emailaddress="true"
                         data-bv-emailaddress-message="{t}Zadejte platnou e-mailovou adresu{/t}"
                         data-cart="noreload" required>
                  <div class="cart-user-mailcheck">
                     <div id="email-text"></div>
                  </div>
                  <p>{t}Máte u nás účet?{/t} <a href="{url s=login}" class="cart-signin" data-wpj-modal="{$modal_login}" data-wpj-modal-type="side">{t}Přihlaste se{/t}</a></p>
               </div>
            {/block}
         </div>
      {/block}
   {/if}

   {block "form-personal-data-address-wrapper"}
      <div class="row personal-data">
         <div class="col-xxs-12">
            <p class="title-default">{t}Fakturační údaje{/t}</p>
         </div>

         <div class="col-xxs-12">
            {block 'firm-address-checkbox'}
               <div class="form-group">
                  <label for="firm-address" class="custom-control custom-checkbox-lg">
                     <input type="hidden" name="firm_address" value="0">
                     <input type="checkbox" name="firm_address" id="firm-address" class="custom-control-input"
                            data-opener="[data-firm-address]" {$body.invoice.firm|checked}>
                     <span class="custom-control-indicator"></span>
                     {t}Nakupuji na firmu (IČ, DIČ){/t}
                     <span class="clear-alt-address" style="display: none;">{t}smazat{/t}</span>
                  </label>
               </div>
            {/block}
            <div class="opener-content" style="display:{if $body.invoice.firm}block{else}none{/if}"
                 data-firm-address>
               {block 'firm-address'}
                  <p class="title-default">{t}Firemní údaje{/t}</p>
                  <div class="row">
                     <div class="{$column_class}">
                        <div class="form-group required">
                           <label for="ifirm">{t}Název firmy{/t}</label>
                           <input type="text" name="invoice[firm]" id="ifirm" class="form-control smartform-company-name" value="{$body.invoice.firm}"
                                  autocomplete="off"
                                  data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="3" {if $tpl_vars.disallowEditB2B}readonly{/if}>
                        </div>
                     </div>
                     <div class="{$column_class}">
                        <div class="form-group required">
                           <label for="iico">{t}IČO{/t}</label>
                           <input type="number" name="invoice[ico]" id="iico" class="form-control disable-spinner smartform-company-registration-number"
                                  value="{$body.invoice.ico}" autocomplete="off"
                                  data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="8"
                                  data-bv-stringlength-max="10" {if $tpl_vars.disallowEditB2B}readonly{/if}>
                        </div>
                     </div>
                     <div class="{$column_class}">
                        <div class="form-group">
                           <label for="idic">{t}DIČ{/t}</label>
                           <input type="text" name="invoice[dic]" id="idic" class="form-control smartform-company-vat-number" value="{$body.invoice.dic}"
                                  autocomplete="off"
                                  data-bv-vat="true" data-bv-vat-country="invoice[country]" {if $tpl_vars.disallowEditB2B}readonly{/if}>
                        </div>
                     </div>
                  </div>
               {/block}

               {block 'firm-invoice-address'}
                  {* mam osobni odber (nevyzaduje zadani adresy), chci fakturu na firmu *}
                  {if $deliveryType and $deliveryType->isInPerson() and !$inpersonRequireAddress}
                     <div class="row">
                        <div class="{$column_class}">
                           <div class="form-group required">
                              <label for="istreet">{t}Ulice a č.p.{/t}</label>
                              <input type="text" name="invoice[street]" id="istreet" class="form-control"
                                     value="{$body.invoice.street}" autocomplete="off" data-field-invoice-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}"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                           </div>
                        </div>
                        <div class="col-lg-3 col-sm-6 col-xxs-12">
                           <div class="form-group required">
                              <label for="icity">{t}Město{/t}</label>
                              <input type="text" name="invoice[city]" id="icity" class="form-control"
                                     value="{$body.invoice.city}" autocomplete="off" data-field-invoice-city
                                     data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                           </div>
                        </div>
                        <div class="col-xl-2 col-lg-3 col-sm-6 col-xxs-12">
                           <div class="form-group required">
                              <label for="izip">{t}PSČ{/t}</label>
                              <input type="text" name="invoice[zip]" id="izip" class="form-control" value="{$body.invoice.zip}"
                                     autocomplete="off" data-bv-notempty="true" data-bv-zipcode="true" data-field-invoice-zip
                                     data-bv-zipcode-country="invoice[country]"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                           </div>
                        </div>

                        <div class="{$column_class}">
                           <div class="form-group required">
                              <label for="icountry">{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 c-select custom-select" id="icountry" name="invoice[country]"
                                      autocomplete="off" {if $cfg.Order.Countries|count == 1 || $tpl_vars.disallowEditB2B}readonly{/if}>
                                 {html_options options=$cfg.Order.Countries selected=$body.invoice.country|default:$ctrl.active_country}
                              </select>
                           </div>
                        </div>
                     </div>
                  {/if}
               {/block}
            </div>
         </div>

         <div class="{$column_class}">
            <div class="form-group required">
               <label for="iname">{t}Jméno{/t}</label>
               <input type="text" name="invoice[name]" id="iname" class="form-control" value="{$body.invoice.name}"
                      data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2">
            </div>
         </div>
         <div class="{$column_class}">
            <div class="form-group required">
               <label for="isurname">{t}Příjmení{/t}</label>
               <input type="text" name="invoice[surname]" id="isurname" class="form-control"
                      value="{$body.invoice.surname}"
                      data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2">
            </div>
         </div>
         <div class="{$column_class}">
            <div class="form-group required">
               <label for="iphone">{t}Telefon{/t}</label>
               <input type="text" name="invoice[phone]" id="iphone" class="form-control smartform-instance-invoice smartform-phone-number" value="{$body.invoice.phone}"
                      data-bv-notempty="true" data-bv-phone="true"
                  {if !($deliveryType and $deliveryType->isInPerson()) || $inpersonRequireAddress}
                  data-bv-phone-country="invoice[country]"
                  {else}
                  data-bv-phone-country="{$ctrl.active_country}"
                  {/if}>
            </div>
         </div>

         {block 'invoice-address'}
            {if (!$deliveryType || !$deliveryType->isInPerson()) || $inpersonRequireAddress}
               <div class="{$column_class}">
                  {block 'invoice-street'}
                     <div class="form-group required">
                        <label for="istreet">{t}Ulice a č.p.{/t}</label>
                        <input type="text" name="invoice[street]" id="istreet" class="form-control smartform-instance-invoice smartform-address-street-and-number"
                               value="{$body.invoice.street}" autocomplete="off" data-field-invoice-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}"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                     </div>
                  {/block}
               </div>
               <div class="{$column_class}">
                  <div class="zip-group">
                     <div class="form-group required">
                        <label for="icity">{t}Město{/t}</label>
                        <input type="text" name="invoice[city]" id="icity" class="form-control smartform-instance-invoice smartform-address-city" value="{$body.invoice.city}" autocomplete="off" data-field-invoice-city
                               data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                     </div>
                     <div class="form-group required">
                        <label for="izip">{t}PSČ{/t}</label>
                        <input type="text" name="invoice[zip]" id="izip" class="form-control smartform-instance-invoice smartform-address-zip" value="{$body.invoice.zip}" autocomplete="off" data-field-invoice-zip
                               data-bv-notempty="true" data-bv-zipcode="true" data-bv-zipcode-country="invoice[country]"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                     </div>
                  </div>
               </div>
               {block "invoice-country"}
                  <div class="{$column_class}">
                     <div class="form-group required">
                        <label for="icountry">{t}Stát{/t}</label>
                        {if $tpl_vars.delivery_country_picker}
                           <a href="/{$body.steps.delivery.url}" class="cart-country-link">{t}Jiný stát?{/t}</a>
                        {/if}
                        <select class="form-control" id="icountry" name="invoice[country]"
                                {if $cfg.Order.Countries|count == 1 || $tpl_vars.delivery_country_picker || $tpl_vars.disallowEditB2B}readonly{/if}>
                           {html_options options=$cfg.Order.Countries selected=$body.invoice.country|default:$ctrl.active_country}
                        </select>
                     </div>
                  </div>
               {/block}
            {/if}
         {/block}

         {block "invoice-custom-data"}
            <div class="col-xxs-12">
               <div class="form-group form-group-legend">
                  <label for="icustom_address">{t}Upřesnění adresy (areál,…){/t}</label>
                  <input type="text" name="invoice[custom_address]" id="icustom_address" class="form-control" value="{$body.invoice.custom_address}">
                  <span class="legend">{t}Nepovinné{/t}</span>
               </div>
            </div>
         {/block}
      </div>
   {/block}

   {block "user-registration"}
      {if !$ctrl.logged}
         <div class="row">
            <div class="col-xxs-12">
               <div class="form-group">
                  <label for="new-account" class="custom-control custom-checkbox-lg">
                     <input type="checkbox" name="new-account" id="new-account" class="custom-control-input"
                            data-opener="[data-password]" {if $body.register}checked{/if}>

                     <span class="custom-control-indicator"></span>
                     {t}Chci vytvořit účet{/t}
                     <span class="clear-alt-address" style="display: none;">{t}zrušit{/t}</span>
                  </label>
               </div>

               {* pokud jednou submittnu heslo, už se nedá vymazat, protože odchecknutí checkboxu input s heslem disabluje,
                  takže se neodešle s prázdnou hodnotou. Prázdný hidden input se odešle. *}

               <input type="hidden" name="password" value="">
               <div class="opener-content" style="display: {if $body.register}block{else}none{/if};"
                    data-password>
                  <div class="row">
                     <div class="col-lg-6 col-xxs-12">
                        <div id="passwords">
                           <div class="form-group form-group-legend required">
                              <label for="password">{t}Heslo{/t}</label>
                              {block "password"}
                                 <input type="password" name="password" value="{$body.register}" id="password" class="form-control"
                                        autocomplete="new-password"
                                        {if !$body.register}disabled{/if} data-bv-notempty="true"
                                        data-bv-stringlength="true" data-bv-stringlength-min="6">
                              {/block}
                              <a href="#" data-toggle-password>{t}Zobrazit{/t}</a>
                           </div>
                        </div>
                     </div>
                     {block "user-registration-gender"}
                        <div class="col-xxs-12 col-lg-6">
                           <div class="form-group form-group-legend">
                              <label for="igender">{t}Pohlaví{/t}</label>
                              <select class="form-control custom-select" id="igender" name="invoice[gender]">
                                 <option value=""{if !$body.invoice.gender} selected="selected"{/if}>{t}Neuvedeno{/t}</option>
                                 <option value="male"{if $body.invoice.gender === 'male'} selected="selected"{/if}>{t}muž{/t}</option>
                                 <option value="female"{if $body.invoice.gender === 'female'} selected="selected"{/if}>{t}žena{/t}</option>
                              </select>
                              <span class="legend">{t}Nepovinné{/t}</span>
                           </div>
                        </div>
                     {/block}
                  </div>
               </div>
            </div>
         </div>
      {/if}
   {/block}

   {block "form-different-delivery"}

      {* nejdriv check zda existuje deliverytype *}
      {* skryt fakt. adresu pokud deliverytype nevyzaduje dor. adresu (napr. balik na postu) *}
      {if !$deliveryType || $deliveryType->getDelivery()->requiresDeliveryAddress()}
         <div class="form-group">
            <label for="different-address" class="custom-control custom-checkbox-lg">
               <input type="hidden" name="different_address" value="0">
               <input class="custom-control-input" type="checkbox" name="different_address"
                      data-opener="#different-address-content" id="different-address"
                      {if $body.delivery.name}checked{/if}>
               <span class="custom-control-indicator"></span>
               {t}Dodání na jinou adresu nebo do zaměstnání{/t}
               <span class="clear-alt-address" style="display: none;">smazat</span>
            </label>
         </div>
         <div class="opener-content" id="different-address-content"
              style="display:{if $body.delivery.name}block{else}none{/if}">
            {block 'form-delivery-address'}
               <div class="row">
                  <div class="col-xxs-12">
                     <p class="title-default">{t}Dodací adresa{/t}</p>
                  </div>
                  <div class="{$column_class}">
                     <div class="form-group required">
                        <label for="name">{t}Jméno{/t}</label>
                        <input type="text" name="delivery[name]" id="name" class="form-control"
                               value="{$body.delivery.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="delivery[surname]" id="surname" class="form-control"
                               value="{$body.delivery.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="firm">{t}Firma{/t}</label>
                         <input type="text" name="delivery[firm]" id="firm" class="form-control"
                                value="{$body.delivery.firm}" autocomplete="off"
                                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="delivery[phone]" id="phone" class="form-control" value="{$body.delivery.phone}" autocomplete="off" data-bv-phone="true"
                           {if !($deliveryType and $deliveryType->isInPerson()) || $inpersonRequireAddress}
                           data-bv-phone-country="delivery[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="delivery[street]" id="street" class="form-control smartform-instance-delivery smartform-address-street-and-number"
                                  value="{$body.delivery.street}" autocomplete="off" 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="delivery[city]" id="city" class="form-control smartform-instance-delivery smartform-address-city"
                                  value="{$body.delivery.city}" autocomplete="off" 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="delivery[zip]" id="zip" class="form-control smartform-instance-delivery smartform-address-zip" value="{$body.delivery.zip}"
                                  autocomplete="off" data-field-delivery-zip data-bv-notempty="true" data-bv-zipcode="true"
                                  data-bv-zipcode-country="delivery[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="delivery[country]" autocomplete="off"
                                   {if $cfg.Order.Countries|count == 1}readonly{/if}>
                              {html_options options=$cfg.Order.Countries selected=$body.delivery.country|default:$ctrl.active_country}
                           </select>
                        </div>
                     </div>
                  {/block}
               </div>
            {/block}
         </div>
      {/if}
   {/block}

   {* pokud je os. odběr, vymazat del. adress, mohla zbyt z předchozího průchodu košíkem *}
   {if $deliveryType and $deliveryType->isInPerson()}
      <input type="hidden" name="delivery[name]" value="">
      <input type="hidden" name="delivery[surname]" value="">
      <input type="hidden" name="delivery[firm]" value="">
      <input type="hidden" name="delivery[street]" value="">
      <input type="hidden" name="delivery[city]" value="">
      <input type="hidden" name="delivery[zip]" value="">
      <input type="hidden" name="delivery[country]" value="">
   {/if}
</div>
