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

   <div class="user-form-fields-wrapper">
      <h3>{t}Účet{/t}</h3>

      <div class="row">
         <div class="col-xs-12 col-sm-6">
            <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>
         </div>
         {block 'gender'}{/block}
      </div>

      <div class="row">
         {if $body.newUser}
            <div class="col-xs-12 col-sm-6">
               <div class="form-group 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>
               </div>
            </div>
            <div class="col-xs-12 col-sm-6">
               <div class="form-group required">
                  <label for="passwordAgain">{t}Heslo znovu{/t}</label>
                  <input type="password" name="passwordAgain" id="passwordAgain" class="form-control" value=""
                         data-bv-notempty="true" data-bv-identical="true"
                         data-bv-identical-message="{t}Hesla se neshodují{/t}"
                         data-bv-identical-field="password" autocomplete=new-password>
               </div>
            </div>
         {else}
            <div class="col-xs-12 col-sm-6 form-group required">
               <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">
            </div>
            <div class="col-xs-12 col-sm-6">
               <div class="form-group required">
                  <label for="passwordAgain">{t}Nové heslo znovu{/t}</label>
                  <input type="password" name="passwordAgain" id="passwordAgain" class="form-control" value=""
                         data-bv-identical="true" data-bv-identical-message="{t}Hesla se neshodují{/t}"
                         data-bv-identical-field="password">
               </div>
            </div>
         {/if}
      </div>

      <div class="row">
         <div class="col-xs-12 col-sm-6">
            <h3>{t}Kontaktní údaje{/t}</h3>
            <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 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 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-xs-12 col-sm-6">
            <h3>{t}Fakturační adresa{/t}</h3>

            {if $dbcfg.here_autocomplete == "Y" and $contexts.country->getAll()|count > 1}
               <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>
            {/if}

            {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}" autocomplete="off" data-field-invoice-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}"{if $tpl_vars.disallowEditB2B} readonly{/if}>
               </div>
            {/block}

            <div class="zip-group">
               <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}"
                         data-bv-notempty="true" data-bv-zipcode="true" data-bv-zipcode-country="country"{if $tpl_vars.disallowEditB2B} readonly{/if} autocomplete="off" data-field-invoice-zip>
               </div>
               <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}"
                         data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2"{if $tpl_vars.disallowEditB2B} readonly{/if} autocomplete="off" data-field-invoice-city>
               </div>
            </div>

            {block "invoice-country"}
               {if !($dbcfg.here_autocomplete == "Y" and $contexts.country->getAll()|count > 1)}
                  <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>
               {/if}
            {/block}
         </div>
      </div>

      {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-xs-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 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 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 class="form-group">
                     <label for="dphone">{t}Telefon{/t}</label>
                     <input type="text" name="dphone" id="dphone" class="form-control" value="{$body.input.dphone.value}"
                            data-bv-phone="true" data-bv-phone-country="dcountry">
                  </div>
               </div>
               <div class="col-xs-12 col-sm-6">

                  {if $dbcfg.here_autocomplete == "Y" and $contexts.country->getAll()|count > 1}
                     <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>
                  {/if}

                  {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 class="zip-group">
                     <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}" data-field-delivery-zip
                               autocomplete="off" data-bv-notempty="true" data-bv-zipcode="true"
                               data-bv-zipcode-country="dcountry">
                     </div>
                     <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}" data-field-delivery-city
                               autocomplete="off" data-bv-notempty="true" data-bv-stringlength="true"
                               data-bv-stringlength-min="2">
                     </div>
                  </div>
                  {block "delivery-country"}
                     {if !($dbcfg.here_autocomplete == "Y" and $contexts.country->getAll()|count > 1)}
                        <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>
                     {/if}
                  {/block}
               </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="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 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>
             {if $showCopyEmail}
               <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>
             {/if}
             <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>
       {/block}

   </div>
   <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" type="submit" name="Submit" value="{t}Zaregistrovat se{/t}">
         {/if}
      {else}
         <input class="btn btn-primary" type="submit" name="Submit" value="{t}Uložit{/t}">
      {/if}
   </div>
</form>
