{* @compiler:inline-only *}
<form name="login" method="post" action="" data-form="user" class="form-user" id="login-form"
      {ifmodule RECAPTCHA__CLOUDFLARE}{if $body.newUser}data-wpj-captcha-lazy="user-registration"{/if}{/ifmodule}>
   {get_contexts country=1 assign='contexts'}
   {include "block.messages.tpl"}

   {block "user-form-prepend"}{/block}

   {block "email"}
      <div class="form-group required">
         <label for="email">{t}E-mail{/t}</label>
         <input type="email" name="email" id="email" class="form-control smartform-instance-invoice smartform-email"
                value="{$body.input.email.value}"
                data-bv-notempty="true">
      </div>
   {/block}

   <div class="row">
      {block "password"}
         <div class="col-xxs-12 col-sm-6">
            {if $body.newUser}
               <div class="form-group form-group-legend required">
                  <label for="password">{t}Heslo{/t}</label>
                  <input type="password" name="password" id="password" class="form-control" value=""
                         data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="6"
                         autocomplete="new-password">
                  <a href="#" data-toggle-password="#password" data-show="{t}Zobrazit{/t}"
                     data-trans-hide="{t}Skrýt{/t}">{t}Zobrazit{/t}</a>
               </div>
            {else}
               <div class="form-group form-group-legend">
                  <label for="password">{t}Nové heslo{/t}</label>
                  <input type="password" name="password" id="password" class="form-control" value=""
                         data-bv-stringlength="true" data-bv-stringlength-min="6" autocomplete="new-password">
                  <a href="#" data-toggle-password="#password" data-show="{t}Zobrazit{/t}"
                     data-trans-hide="{t}Skrýt{/t}">{t}Zobrazit{/t}</a>
               </div>
            {/if}
         </div>
      {/block}

      {block "gender"}
         <div class="col-xxs-12 col-sm-6">
            <div class="form-group form-group-legend form-group-gender">
               <label for="gender">{t}Pohlaví{/t}</label>
               <select name="gender" class="custom-select form-control" id="gender">
                  <option selected disabled hidden>
                     {t}Neuvedeno{/t}
                  </option>
                  <option value="M" {if $body.input.gender.value == 'M'}selected{/if}>
                     {t}Muž{/t}
                  </option>
                  <option value="F" {if $body.input.gender.value == 'F'}selected{/if}>
                     {t}Žena{/t}
                  </option>
                  <option value="">
                     {t}Nechci uvést{/t}
                  </option>
               </select>
               <span class="legend">{t}Nepovinné{/t}</span>
            </div>
         </div>
      {/block}
   </div>

   {block "personal-data"}
      <h3>{t}Kontaktní údaje{/t}</h3>
      <div class="row">
         <div class="col-xxs-12 col-sm-6">
            <div class="form-group required">
               <label for="name">{t}Jméno{/t}</label>
               <input type="text" name="name" id="name" class="form-control" value="{$body.input.name.value}"
                      data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2">
            </div>
         </div>

         <div class="col-xxs-12 col-sm-6">
            <div class="form-group required">
               <label for="surname">{t}Příjmení{/t}</label>
               <input type="text" name="surname" id="surname" class="form-control"
                      value="{$body.input.surname.value}"
                      data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2">
            </div>
         </div>

         <div class="col-xxs-12 col-sm-6">
            <div class="form-group required">
               <label for="phone">{t}Telefon{/t}</label>
               <input type="text" name="phone" id="phone" class="form-control smartform-instance-invoice smartform-phone-number"
                      value="{$body.input.phone.value}"
                      data-bv-notempty="true" data-bv-phone="true" data-bv-phone-country="country">
            </div>
         </div>

         <div class="col-xxs-12 col-sm-6">
            {block "invoice-street"}
               <div class="form-group required">
                  <label for="street">{t}Ulice a č.p.{/t}</label>
                  <input type="text" name="street" id="street"
                         class="form-control smartform-instance-invoice smartform-address-street-and-number"
                         value="{$body.input.street.value}" data-field-invoice-street autocomplete="off" data-bv-notempty="true"
                         data-bv-regexp="true" pattern=".*\S+\s+[0-9]+.*"
                         data-bv-regexp-message="{t}Doplňte prosím číslo popisné{/t}"{if $tpl_vars.disallowEditB2B} readonly{/if}>
               </div>
            {/block}
         </div>

         <div class="col-xxs-12 col-sm-6">
            <div class="zip-group">
               <div class="form-group required">
                  <label for="city">{t}Město{/t}</label>
                  <input type="text" name="city" id="city" class="form-control smartform-instance-invoice smartform-address-city"
                         value="{$body.input.city.value}" 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="zip">{t}PSČ{/t}</label>
                  <input type="text" name="zip" id="zip" class="form-control smartform-instance-invoice smartform-address-zip"
                         value="{$body.input.zip.value}" autocomplete="off" data-field-invoice-zip
                         data-bv-notempty="true" data-bv-zipcode="true"
                         data-bv-zipcode-country="country"{if $tpl_vars.disallowEditB2B} readonly{/if}>
               </div>
            </div>
         </div>

         <div class="col-xxs-12 col-sm-6">
            {block "invoice-country"}
               <div class="form-group required">
                  <label for="country">{t}Stát{/t}</label>

                  {$activeCountry = $body.input.country.value|default:$ctrl.active_country}

                  <select name="country" class="custom-select form-control" id="country"{if $tpl_vars.disallowEditB2B} readonly{/if}>
                     {foreach $contexts.country->getAll() as $country}
                        <option value="{$country->getId()}" {if $activeCountry == $country->getId()}selected{/if}>
                           {$country->getName()}
                        </option>
                     {/foreach}
                  </select>
               </div>
            {/block}
         </div>

         {*<div class="col-xxs-12" data-invoice-state-field style="{if $activeCountry != 'IT'}display: none;{/if}">
            <div class="form-group">
               <label for="state">{t}Region{/t}</label>
               <input type="text" name="state" id="state" class="form-control" value="{$body.input.state.value}" data-field-invoice-countycode>
            </div>
         </div>*}

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

   {block "different-address-opener"}
      <div class="form-group">
         <label for="different-address" class="custom-control custom-checkbox">
            <input type="checkbox" name="different-address" id="different-address" class="custom-control-input"
                   data-opener="[data-different-address]" {$body.input.dname.value|checked}>

            <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;">{t}smazat{/t}</span>
         </label>
      </div>
   {/block}

   {block "different-address-content"}
      <div class="opener-content" style="display: {if $body.input.dname.value}block{else}none{/if};" data-different-address>
         <h3>{t}Dodací adresa{/t}</h3>
         <div class="row">
            <div class="col-xxs-12 col-sm-6">
               <div class="form-group required">
                  <label for="dname">{t}Jméno{/t}</label>
                  <input type="text" name="dname" id="dname" class="form-control"
                         value="{$body.input.dname.value}"
                         autocomplete="off" data-bv-notempty="true" data-bv-stringlength="true"
                         data-bv-stringlength-min="2">
               </div>
            </div>
            <div class="col-xxs-12 col-sm-6">
               <div class="form-group required">
                  <label for="dsurname">{t}Příjmení{/t}</label>
                  <input type="text" name="dsurname" id="dsurname" class="form-control"
                         value="{$body.input.dsurname.value}"
                         autocomplete="off" data-bv-notempty="true" data-bv-stringlength="true"
                         data-bv-stringlength-min="2">
               </div>
            </div>
            {*<div class="col-xxs-12 col-sm-6">
               <div class="form-group">
                  <label for="dfirm">{t}Firma{/t}</label>
                  <input type="text" name="dfirm" id="dfirm" class="form-control"
                         value="{$body.input.dfirm.value}"
                         autocomplete="off" data-bv-stringlength="true" data-bv-stringlength-min="3">
               </div>
            </div>*}
            <div class="col-xxs-12 col-sm-6">
               <div class="form-group">
                  <label for="dphone">{t}Telefon{/t}</label>
                  <input type="text" name="dphone" id="dphone" class="form-control smartform-instance-delivery smartform-phone-number"
                         value="{$body.input.dphone.value}"
                         data-bv-phone="true" data-bv-phone-country="dcountry">
               </div>
            </div>
            <div class="col-xxs-12 col-sm-6">
               {block "delivery-street"}
                  <div class="form-group required">
                     <label for="dstreet">{t}Ulice a č.p.{/t}</label>
                     <input type="text" name="dstreet" id="dstreet"
                            class="form-control smartform-instance-delivery smartform-address-street-and-number"
                            value="{$body.input.dstreet.value}" autocomplete="off" data-field-delivery-street
                            data-bv-notempty="true" data-bv-regexp="true" pattern=".*\S+\s+[0-9]+.*"
                            data-bv-regexp-message="{t}Doplňte prosím číslo popisné{/t}">
                  </div>
               {/block}
            </div>
            <div class="col-xxs-12 col-sm-6">
               <div class="zip-group">
                  <div class="form-group required">
                     <label for="dcity">{t}Město{/t}</label>
                     <input type="text" name="dcity" id="dcity" class="form-control smartform-instance-delivery smartform-address-city"
                            value="{$body.input.dcity.value}"
                            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="dzip">{t}PSČ{/t}</label>
                     <input type="text" name="dzip" id="dzip" class="form-control smartform-instance-delivery smartform-address-zip"
                            value="{$body.input.dzip.value}"
                            autocomplete="off" data-field-delivery-zip data-bv-notempty="true" data-bv-zipcode="true"
                            data-bv-zipcode-country="dcountry">
                  </div>
               </div>
            </div>
            <div class="col-xxs-12 col-sm-6">
               {block "delivery-country"}
                  <div class="form-group required">
                     <label for="dcountry">{t}Stát{/t}</label>
                     {$activeCountry = $body.input.dcountry.value|default:$ctrl.active_country}

                     <select name="dcountry" id="dcountry" class="custom-select form-control" autocomplete="off">
                        {foreach $contexts.country->getAll() as $country}
                           <option value="{$country->getId()}"
                                   {if $activeCountry == $country->getId()}selected{/if}>
                              {$country->getName()}
                           </option>
                        {/foreach}
                     </select>
                  </div>
               {/block}
            </div>

            {*<div class="col-xxs-12" data-delivery-state-field style="{if $activeCountry != 'IT'}display: none;{/if}">
               <div class="form-group">
                  <label for="dstate">{t}Region{/t}</label>
                  <input type="text" name="dstate" id="dstate" class="form-control" value="{$body.input.dstate.value}" data-field-delivery-countycode>
               </div>
            </div>*}
         </div>
      </div>
   {/block}

   {block "company"}
      <div class="form-group">
         <label for="firm-address" class="custom-control custom-checkbox">
            <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.input.firm.value|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>
      <div class="opener-content" style="display: {if $body.input.firm.value}block{else}none{/if};"
           data-firm-address>

         <h3>{t}Firemní údaje{/t}</h3>
         <div class="row">
            <div class="col-xxs-12 {if $showCopyEmail}col-sm-6{/if}">
               <div class="form-group">
                  <label for="firm">{t}Firma{/t}</label>
                  <input type="text" name="firm" value="{$body.input.firm.value}" id="firm" class="form-control smartform-company-name"
                         autocomplete="off" data-bv-stringlength="true" data-bv-stringlength-min="3"
                         {if $tpl_vars.disallowEditB2B}readonly{/if}>
               </div>
            </div>
            {if $showCopyEmail}
               <div class="col-xxs-12 col-sm-6">
                  <div class="form-group">
                     <label for="copy_email">{t}E-mail pro fakturaci{/t}</label>
                     <input type="email" name="copy_email" id="copy_email" class="form-control smartform-instance-invoice smartform-email"
                            value="{$body.input.copy_email.value}">
                  </div>
               </div>
            {/if}
            <div class="col-xxs-12 col-sm-6">
               <div class="form-group">
                  <label for="ico">{t}IČO{/t}</label>
                  <input type="text" name="ico" id="ico" value="{$body.input.ico.value}"
                         class="form-control smartform-company-registration-number"
                         autocomplete="off" data-bv-stringlength="true" data-bv-stringlength-min="8"
                         data-bv-stringlength-max="10" {if $tpl_vars.disallowEditB2B}readonly{/if}>
               </div>
            </div>
            <div class="col-xxs-12 col-sm-6">
               <div class="form-group">
                  <label for="dic">{t}DIČ{/t}</label>
                  <input type="text" name="dic" value="{$body.input.dic.value}" id="dic" class="form-control smartform-company-vat-number"
                         autocomplete="off" data-bv-vat="true" data-bv-vat-country="country"
                         {if $tpl_vars.disallowEditB2B}readonly{/if}>
               </div>
            </div>
         </div>
      </div>
   {/block}

   <div class="form-group">
      {block "news"}
         <label for="news" class="custom-control custom-checkbox">
            <input type="checkbox" name="news" value="Y" id="news"
                   class="custom-control-input" {$body.input.news|checked:'Y'}>
            <span class="custom-control-indicator"></span>
            {t}Dostávat novinky{/t}
            {strip}
               ({if $body.input.news == 'Y' and $body.input.date_subscribe.value}
               {t date=$body.input.date_subscribe.value|date_format:"%d. %m. %Y"}Souhlas udělen dne {date}{/t}
            {else}
               <a href="{url s=page label='consent'}" target="_blank">
                  {t}Souhlasím se zpracováním osobních údajů{/t}
               </a>
            {/if})
            {/strip}
         </label>
      {/block}
   </div>

   <div class="registration-submit">
      {if $body.newUser}
         {block 'consent'}
            {* @formatter:off *}
            <p class="registration-consent">{t consent={url s=page label='consent'}
               privacyPolicy={url s=page label='privacy_policy'} escape=false}Odesláním registrace souhlasím
                  se <a href="{consent}" target="_blank">zpracováním osobních údajů za účelem registrace</a> a beru
                  na vědomí <a href="{privacyPolicy}" target="_blank">Zásady zpracování osobních údajů</a>.{/t}
            </p>
            {* @formatter:on *}
         {/block}

         {if !findModule('recaptcha', 'cloudflare') and findModule('recaptcha', 'registration') and findModule('recaptcha', 'site_invisible')}
            {include "block.recaptcha.invisible.tpl"}
            {captchaBtn text="{t}Zaregistrovat se{/t}"}
         {else}
            <input class="btn btn-primary" form="login-form" type="submit" name="Submit" value="{t}Zaregistrovat se{/t}">
         {/if}
      {else}
         <input class="btn btn-primary" form="login-form" type="submit" name="Submit" value="{t}Uložit{/t}">
      {/if}
   </div>
</form>
