<div data-reload="contact-form">
   {if $body.error}
      <div class="alert alert-danger">
         {$body.error}
      </div>
   {/if}

   {include "block.messages.tpl"}

   {if $body.sent}
      <div class="alert alert-success">
         {t}Zpráva byla úspěšně odeslána. Odpovíme ti co nejdříve.{/t}
      </div>
   {else}
      <form method="post" action="{path('kupshop_content_contactform_sendform', ['type'=>'contact'])}" data-contact-form>
         {if $ctrl.logged}
            <input type="hidden" name="name" value="{$ctrl.name} {$ctrl.surname}">
            <input type="hidden" name="email" value="{$ctrl.email}">
            <input type="hidden" name="phone" value="{$ctrl.phone}">
         {else}
            <div class="row">
               <div class="col-xxs-12">
                  <div class=" form-group required">
                     <label for="name" class="form-control-label">{t}Jméno a příjmení{/t}</label>
                     <input type="text" name="name" id="name" class="form-control" value="{$body.data.name}"
                            data-bv-notempty="true" data-bv-stringlength="true" data-bv-stringlength-min="3">
                  </div>
               </div>
               <div class="col-xxs-12">
                  <div class=" form-group required">
                     <label for="phone" class="form-control-label">{t}Telefon{/t}</label>
                     <input type="text" name="phone" id="phone" class="form-control" value="{$body.data.phone}"
                            data-bv-phone="true" data-bv-phone-country="{$ctrl.active_country}"
                            data-bv-phone-message="{t}Zadejte platné telefoní číslo{/t}">
                  </div>
               </div>
               <div class="col-xxs-12">
                  <div class=" form-group required">
                     <label for="email" class="form-control-label">{t}E-mail{/t}</label>
                     <input type="email" name="email" id="email" class="form-control" value="{$body.data.email}"
                            data-bv-notempty="true" data-bv-emailaddress-message="{t}Zadejte platnou e-mailovou adresu{/t}">
                  </div>
               </div>
            </div>
         {/if}

         <div class="row">
            <div class="col-xxs-12">
               <div class=" form-group required">
               <textarea id="message" value="{$body.data.message}" name="message" class="form-control" rows="8" data-bv-notempty="true"
                         placeholder="{t}Zpráva{/t}*" data-bv-field="message"></textarea>
               </div>
            </div>
         </div>

         <div class="send-block">
            <div class="form-group">
               <div class="recaptcha-wrapper">
                  {include "block.recaptcha.tpl"}
               </div>
            </div>

            <button class="btn btn-primary btn-block" type="submit" name="Submit" value="{t}Odeslat{/t}">{t}Odeslat{/t}</button>
         </div>
      </form>
      <script>
         wpj.onReady.push(function() {
            $('[data-contact-form]').bootstrapValidator({
               feedbackIcons: {
                  valid: 'fc fc-check',
                  invalid: 'fc fc-remove',
                  validating: 'fc fc-refresh',
               },
            }).on('success.form.bv', function (e) {
               e.preventDefault()
               var $this = $(e.target)
               wpj.domUtils.reloadPartsFromUrl($this.attr('action'), $this.closest('[data-reload]'), $this.serialize())
            })
         })
      </script>
   {/if}
</div>
