{extends_parent}

{block 'login-block'}
   {if $isB2BUser}
      <p class="user-error">{t escape=false contact={url s=page label='contact'}}Pokud máte problém s objednáním a nebo potřebujete změnit fakturační údaje, tak kontaktujte svého obchodního zástupce a nebo se s námi spojte
            <strong><a href="{contact}">zde.</a></strong>{/t}</p>
   {elseif $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}

{block 'form-personal-data-address-wrapper' prepend}
   {if $isB2BUser}
      <div class="row personal-data-b2b">
         {if $body.invoice}
            <div class="col-xxs-6 col-sm-4">
               <div class="content">
                  {if $body.invoice.firm}
                     <label class="h4" for="firm-address">{$body.invoice.firm}</label>
                  {/if}
                  <div class="row">
                     <div class="col-md-4 col-xxs-6">
                        {if $body.invoice.ico}
                           <p>{$body.invoice.ico}</p>
                        {/if}
                        {if $body.invoice.dic}
                           <p>{$body.invoice.dic}</p>
                        {/if}
                     </div>
                  </div>
               </div>
            </div>
         {/if}
         <div class="col-xxl-8 col-xxs-12">
            <div class="content">
               <div class="row">
                  <div class="col-sm-4 col-xxs-12">
                     <p class="p-title">
                        <strong>
                           {if !empty($body.user.delivery.firm)}
                              {$body.user.delivery.firm}
                           {else}
                              {$body.user.invoice.firm}
                           {/if}
                        </strong>
                     </p>
                     {if $body.invoice.email}
                        <input type="hidden" name="invoice[email]" id="iemail" value="{$body.invoice.email}">
                        <p >{$body.invoice.email}</p>
                     {/if}
                     {if $body.invoice.phone}
                        <input type="hidden" name="invoice[phone]" id="iphone" value="{$body.invoice.phone}" />
                        <p>{$body.invoice.phone}</p>
                     {/if}
                  </div>
                  <div class="col-sm-4 col-xxs-12">
                     <p class="p-title"><strong>{t}Fakturační adresa{/t}</strong></p>
                     {if $body.invoice.street}
                        <p>{$body.invoice.street}</p>
                     {/if}
                     {if $body.invoice.city and $body.invoice.street}
                        <p>{$body.invoice.city} {$body.invoice.zip}</p>
                     {/if}
                  </div>
                  <div class="col-sm-4 col-xxs-12">
                     <p class="p-title"><strong>{t}Doručovací adresa{/t}</strong></p>
                     {if $body.delivery.street}
                        <p>{$body.delivery.street}</p>
                     {/if}
                     {if $body.delivery.city and $body.delivery.street}
                        <p>{$body.delivery.city} {$body.delivery.zip}</p>
                     {/if}
                  </div>
               </div>
            </div>
         </div>
      </div>
   {/if}
{/block}

{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"
             placeholder="{t}Váš e-mail{/t}"
             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">{t}Přihlaste se{/t}</a></p>
   </div>
{/block}

{block 'invoice-address'}
   {if $deliveryType}
      {$order_payment = $deliveryType->getPayment()}
   {/if}

   {if ($deliveryType and $deliveryType->getDelivery()->getType() == 1) or $order_payment.class == 'PayPal' or !$deliveryType}
      <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}">
            </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}"
                      data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="2" autocomplete="off"
                      data-field-invoice-city>
            </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}"
                      data-bv-notempty="true" data-bv-zipcode="true" data-bv-zipcode-country="invoice[country]" autocomplete="off"
                      data-field-invoice-zip>
            </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}
               <div class="delivery-country-select">
                  <span class="country-flag"
                        style="background-image: url('/common/static/images/flags/{$body.invoice.country|default:$ctrl.active_country|lower}.svg')"></span>
                  <select class="form-control" id="icountry" name="invoice[country]"
                          {if $cfg.Order.Countries|count == 1 || $tpl_vars.delivery_country_picker}readonly{/if}>
                     {html_options options=$cfg.Order.Countries selected=$body.invoice.country|default:$ctrl.active_country}
                  </select>
               </div>
            </div>
         </div>
      {/block}
   {else}
      <input type="hidden" name="invoice[country]" value="{$body.invoice.country|default:$ctrl.active_country}">
   {/if}
{/block}

{block 'firm-invoice-address'}
   {* mam osobni odber (nevyzaduje zadani adresy), chci fakturu na firmu *}
   {if $deliveryType and $deliveryType->getDelivery()->getType() != 1 and $order_payment.class != 'PayPal'}
      <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}">
            </div>
         </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">
               </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-bv-notempty="true" data-bv-zipcode="true" data-field-invoice-zip
                         data-bv-zipcode-country="invoice[country]">
               </div>
            </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}readonly{/if}>
                  {html_options options=$cfg.Order.Countries selected=$body.invoice.country|default:$ctrl.active_country}
               </select>
            </div>
         </div>
      </div>
   {/if}
{/block}

{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>
         <div class="delivery-country-select">
            <span class="country-flag"
                  style="background-image: url('/common/static/images/flags/{$body.delivery.country|default:$ctrl.active_country|lower}.svg')"></span>
            <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>
   </div>
{/block}

{block "delivery-custom-address"}
   {if (!$deliveryType || !$deliveryType->isInPerson()) || $inpersonRequireAddress}
      <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="delivery[custom_address]" id="dcustom_address" class="form-control"
                   value="{$body.delivery.custom_address}">
            <span class="legend">{t}Nepovinné{/t}</span>
         </div>
      </div>
   {/if}
{/block}

{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">
            <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-stringlength="true" data-bv-stringlength-min="8"
                   data-bv-stringlength-max="10" {if $tpl_vars.disallowEditB2B}readonly{/if}>
         </div>
      </div>
   </div>
   <div class="row">
      <div class="{$column_class}">
         <div class="form-group">
            <label for="idic">{t}Členský stát{/t}</label>
            {get_contexts country=1 assign='dic_contexts'}
            <select class="form-control" id="country" name="cart_data[dic_country]" autocomplete="off">
               {foreach $dic_contexts.country->getSupported() as $country}
                  <option value="{$country->getId()}"
                          {if $dic_contexts.country->getActiveId() == $country->getId()}selected{/if}>{$country->getId()}</option>
               {/foreach}
            </select>
         </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"
                   {if $tpl_vars.disallowEditB2B}readonly{/if}>
         </div>
      </div>
   </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>

                  <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>

                  {if !$cfg['znz_tpl']['hide_birthdate']}
                     <div class="col-xxs-12 col-lg-6">
                        <div class="form-group form-group-legend">
                           <label for="birthdate">{t}Datum narození{/t}</label>
                           <input type="date" class="form-control" id="birthdate" name="invoice[birthdate]"
                                  value="{$body.invoice.birthdate}">
                           <span class="legend">{t}Nepovinné{/t}</span>
                        </div>
                     </div>
                  {/if}
               </div>
            </div>
         </div>
      </div>
   {/if}
{/block}

{block 'firm-address-checkbox'}
   <div class="form-group b2b-hidden">
      <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}
