<div data-reload="product_question">
    {if $body.sent}
        <div class="dotaz-na-produkt" data-form="#tabs-inquiry">
            <div class="alert alert-success">
                Dotaz byl úspěšně odeslán. Odpovíme Vám co nejdříve.
                {$body|var_dump}
            </div>
        </div>
    {else}
        <div class="dotaz-na-produkt" data-form="#tabs-inquiry">
            {if $body.error}
                <div class="alert alert-danger">
                    {$body.error}
                </div>
            {/if}
            <form name="help" method="post" action="" class="col-xs-12" role="form">
                <input type="hidden" name="url" value="{$body.data.url}">
                {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="form-group row required">
                        <label for="name" class="col-sm-3 col-xs-12 text-right form-control-label">Jméno a příjmení</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" name="name" id="name" class="form-control" value="{$body.data.name}" required="required">
                        </div>
                    </div>
                    <div class="form-group row required">
                        <label for="email" class="col-sm-3 col-xs-12 text-right form-control-label">Váš e-mail</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="email" name="email" id="email" class="form-control" value="{$body.data.email}" required="required">
                        </div>
                    </div>
                    <div class="form-group row">
                        <label for="phone" class="col-sm-3 col-xs-12 text-right form-control-label">Telefon</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" name="phone" id="phone" class="form-control" value="{$body.data.phone}">
                        </div>
                    </div>
                {/if}
                <div class="form-group row required">
                    <label for="subject" class="col-sm-3 col-xs-12 text-right form-control-label">Název výrobku</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="subject" id="subject" class="form-control" value="{$body.data.subject}" disabled required="required">
                    </div>
                </div>
                <div class="form-group row required">
                    <label for="message" class="col-sm-3 col-xs-12 text-right form-control-label">Dotaz</label>
                    <div class="col-sm-9 col-xs-12">
                        <textarea id="message" name="message" class="form-control" rows="4" required="required">{$body.data.message}</textarea>
                    </div>
                </div>
                {if findModule('recaptcha')}
                    <div class="form-group row required">
                        <label for="message" class="col-sm-3 col-xs-12 text-right form-control-label">Ověření</label>
                        <div class="col-md-3 col-sm-3">
                            <div class="g-recaptcha" data-sitekey="{findModule('recaptcha','site')}"></div>
                            <script type="text/javascript" src="https://www.google.com/recaptcha/api.js?hl=cs"></script>
                        </div>
                    </div>
                {else}
                    <div class="form-group row required {if $body.email.error == 'Chybně opsaný kód'}has-error{/if}">
                        <label for="captcha" class="col-sm-3 col-xs-12 text-sm-right form-control-label">Opište kód z obrázku</label>
                        <div class="col-md-3 col-sm-3 col-xs-6">
                            <input type="text" name="captcha" id="captcha" class="form-control" value="" required="required">
                        </div>
                        <div class="col-md-3 col-sm-3 col-xs-6">
                            <img alt="captcha" src="{url s=captcha id=$smarty.now}">
                            <input type="hidden" name="captcha_id" value="{$smarty.now}">
                        </div>
                    </div>
                {/if}
                <div class="form-group row">
                    <div class="col-md-5 col-md-offset-3 text-left">
                        <input class="btn btn-primary btn-primary--green btn-block" type="submit" name="SendQuestion" value="Odeslat dotaz">
                    </div>
                </div>
            </form>
        </div>

        <script type="text/javascript">
            // validace dotaz na produkt
            $('form[name=help]').on('submit', function(e) {
                // Prevent submit form
                e.preventDefault();

                var $this = $(e.target),
                    data = $this.serialize(),
                    url = $this.attr('action');

                wpj.domUtils.reloadPartsFromUrl(url, $this.closest('[data-reload]'), data);
            });
        </script>
    {/if}
</div>

