{block name='contact-index-content'}
    {et_isShopVersionAtLeast value="5.3.0-rc.3" assign='shopIsAtLeast53'}
    {et_isShopVersionAtLeast value="5.5.0-rc.1" assign='shopIsAtLeast55'}
    {$inWidget=$inWidget|default:false}

    {if !empty($Spezialcontent->titel) && !$inWidget}
        {block name='contact-index-heading'}
            {opcMountPoint id='opc_before_heading' inContainer=false}
            <div class="container{if isset($Link) && $Link->getIsFluid() === true}-fluid{/if}">
                <div class="title h2">
                    {$Spezialcontent->titel}
                </div>
            </div>
        {/block}
    {/if}

    {block name='contact-index-include-extension'}
        {include file='snippets/extension.tpl'}
    {/block}
    {if isset($step)}
        <div class="{if !$inWidget}container{if isset($Link) && $Link->getIsFluid() === true}-fluid{/if}{/if}">
            {opcMountPoint id='opc_before_form'}
            {if !empty($Spezialcontent->oben)}
                {block name='contact-index-custom-content-top'}
                    <div class="custom_content">
                        {$Spezialcontent->oben}
                    </div>
                {/block}
            {/if}

            {if !empty($fehlendeAngaben)}
                {block name='contact-index-alert'}
                    <div role="alert" class="alert alert-danger alert-dismissable" aria-live="assertive" aria-atomic="true">
                        <button type="button" aria-label="{if $shopIsAtLeast55}{lang key="close" section="aria"}{else}Close{/if}" class="close" data-dismiss="alert">
                            <i class="{et_getIcon key="close"}"></i>
                        </button>

                        {lang key='fillOut'}
                    </div>
                {/block}
            {/if}
            {block name='contact-index-form'}
                <form name="contact" action="{get_static_route id='kontakt.php'}" method="post" class="contact-form jtl-validate label-slide">
                    {csrf_token}
                    {if $shopIsAtLeast53}{honeypot}{/if}
                    {block name='contact-index-form-content'}
                        {block name="et-contact-index-form-required-info"}
                            {if $shopIsAtLeast55}
                                <div class="required-info">{lang key='requiredInfo'}</div>
                            {/if}
                        {/block}
                        {block name='contact-index-fieldset-contact'}
                            <fieldset class="et-boxed-content">
                                <div class="row {if !empty($Spezialcontent->oben)}is-top{/if}">
                                    <div class="col col-12 col-lg-4">
                                        {block name='contact-index-legend-contact'}
                                            <div class="h3">{lang key='contact'}</div>
                                        {/block}
                                    </div>
                                    <div class="col col-12 col-lg-8">
                                        {block name='contact-index-salution'}
                                            <div class="row">
                                                {if $Einstellungen.kontakt.kontakt_abfragen_anrede !== 'N'}
                                                    <div class="col col-12 col-md-6">
                                                        {formgroup
                                                        label="{lang key='salutation' section='account data'}{if $Einstellungen.kontakt.kontakt_abfragen_anrede === 'O'}<span class='optional'> - {lang key='optional'}</span>{/if}"
                                                        label-for="salutation"
                                                        }
                                                            <select name="anrede" id="salutation" class="form-control custom-select" {if ($Einstellungen.kontakt.kontakt_abfragen_anrede === 'Y')}required{/if}>
                                                                <option value="" selected="selected" {if $Einstellungen.kontakt.kontakt_abfragen_anrede === 'Y'}disabled{/if}>
                                                                    {if $Einstellungen.kontakt.kontakt_abfragen_anrede === 'Y'}{lang key='salutation' section='account data'}{else}{lang key='noSalutation'}{/if}
                                                                </option>
                                                                <option value="w"{if isset($Vorgaben->cAnrede) && $Vorgaben->cAnrede === 'w'} selected="selected"{/if}>{lang key='salutationW'}</option>
                                                                <option value="m"{if isset($Vorgaben->cAnrede) && $Vorgaben->cAnrede === 'm'} selected="selected"{/if}>{lang key='salutationM'}</option>
                                                            </select>
                                                        {/formgroup}
                                                    </div>
                                                {/if}
                                            </div>
                                        {/block}
                                        {if $Einstellungen.kontakt.kontakt_abfragen_vorname !== 'N' || $Einstellungen.kontakt.kontakt_abfragen_nachname !== 'N'}
                                            {block name='contact-index-name'}
                                                <div class="row">
                                                    {if $Einstellungen.kontakt.kontakt_abfragen_vorname !== 'N'}
                                                        <div class="col col-12 col-md-6">
                                                            {block name='contact-index-name-firstname'}
                                                                {include file='snippets/form_group_simple.tpl' options=["text", "firstName", "vorname", {$Vorgaben->cVorname}, {lang key='firstName' section='account data'}, {$Einstellungen.kontakt.kontakt_abfragen_vorname}]}
                                                            {/block}
                                                        </div>
                                                    {/if}
                                                    {if $Einstellungen.kontakt.kontakt_abfragen_nachname !== 'N'}
                                                        <div class="col col-12 col-md-6">
                                                            {assign var=invalidReason value=null}
                                                            {if isset($fehlendeAngaben.nachname)}
                                                                {if $fehlendeAngaben.nachname == 1}
                                                                    {lang assign='invalidReason' key='fillOut'}
                                                                {elseif $fehlendeAngaben.nachname == 2}
                                                                    {lang assign='invalidReason' key='lastNameNotNumeric' section='account data'}
                                                                {/if}
                                                            {/if}
                                                            {block name='contact-index-name-last-name'}
                                                                {include file='snippets/form_group_simple.tpl' options=['text' , 'lastName', 'nachname', {$Vorgaben->cNachname}, {lang key='lastName' section='account data'}, {$Einstellungen.kontakt.kontakt_abfragen_nachname}, {$invalidReason}]}
                                                            {/block}
                                                        </div>
                                                    {/if}
                                                </div>
                                            {/block}
                                        {/if}

                                        {if $Einstellungen.kontakt.kontakt_abfragen_firma !== 'N'}
                                            {block name='contact-index-company'}
                                                <div class="row">
                                                    <div class="col col-12 col-md-6">
                                                        {include file='snippets/form_group_simple.tpl' options=[ 'text' , 'firm', 'firma', {$Vorgaben->cFirma}, {lang key='firm' section='account data'}, {$Einstellungen.kontakt.kontakt_abfragen_firma}]}
                                                    </div>
                                                </div>
                                            {/block}
                                        {/if}
                                        {block name='contact-index-mail'}
                                            <div class="row">
                                                <div class="col col-12">
                                                    {assign var=invalidReason value=null}
                                                    {if isset($fehlendeAngaben.email)}
                                                        {if $fehlendeAngaben.email == 1}{lang assign='invalidReason' key='fillOut'}
                                                        {elseif $fehlendeAngaben.email == 2}{lang assign='invalidReason' key='invalidEmail'}
                                                        {elseif $fehlendeAngaben.email == 3}{lang assign='invalidReason' key='blockedEmail'}
                                                        {elseif $fehlendeAngaben.email == 4}{lang assign='invalidReason' key='noDnsEmail' section='account data'}
                                                        {elseif $fehlendeAngaben.email == 5}{lang assign='invalidReason' key='emailNotAvailable' section='account data'}{/if}
                                                    {/if}
                                                    {include file='snippets/form_group_simple.tpl' options=['email' , 'email', 'email', {$Vorgaben->cMail}, {lang key='email' section='account data'}, true, {$invalidReason}]}
                                                </div>
                                            </div>
                                        {/block}
                                        {if $Einstellungen.kontakt.kontakt_abfragen_tel !== 'N' || $Einstellungen.kontakt.kontakt_abfragen_mobil !== 'N'}
                                            {block name='contact-index-phone-mobile'}
                                                <div class="row">
                                                    {if $Einstellungen.kontakt.kontakt_abfragen_tel !== 'N'}
                                                        <div class="col col-12 col-md-6">
                                                            {assign var=invalidReason value=null}
                                                            {if isset($fehlendeAngaben.tel) && $fehlendeAngaben.tel === 1}{lang assign='invalidReason' key='fillOut'}{elseif isset($fehlendeAngaben.tel) && $fehlendeAngaben.tel === 2}{lang assign='invalidReason' key='invalidTel'}{/if}
                                                            {block name='contact-index-tel'}
                                                                {include file='snippets/form_group_simple.tpl' options=['tel' , 'tel', 'tel', {$Vorgaben->cTel}, {lang key='tel' section='account data'}, {$Einstellungen.kontakt.kontakt_abfragen_tel}, {$invalidReason}]}
                                                            {/block}
                                                        </div>
                                                    {/if}
                                                    {if $Einstellungen.kontakt.kontakt_abfragen_mobil !== 'N'}
                                                        <div class="col col-12 col-md-6">
                                                            {assign var=invalidReason value=null}
                                                            {if isset($fehlendeAngaben.mobil) && $fehlendeAngaben.mobil === 1}{lang assign='invalidReason' key='fillOut'}{elseif isset($fehlendeAngaben.mobil) && $fehlendeAngaben.mobil === 2}{lang assign='invalidReason' key='invalidTel'}{/if}
                                                            {block name='contact-index-mobile'}
                                                                {include file='snippets/form_group_simple.tpl' options=['tel' , 'mobile', 'mobil', {$Vorgaben->cMobil}, {lang key='mobile' section='account data'}, {$Einstellungen.kontakt.kontakt_abfragen_mobil}, {$invalidReason}]}
                                                            {/block}
                                                        </div>
                                                    {/if}
                                                </div>
                                            {/block}
                                        {/if}

                                        {if $Einstellungen.kontakt.kontakt_abfragen_fax !== 'N'}
                                            {block name='contact-index-fax'}
                                                <div class="row">
                                                    <div class="col col-12 col-md-6">
                                                        {assign var=invalidReason value=null}
                                                        {if !empty($fehlendeAngaben.fax) && $fehlendeAngaben.fax === 1}{lang assign='invalidReason' key='fillOut'}{elseif isset($fehlendeAngaben.fax) && $fehlendeAngaben.fax === 2}{lang assign='invalidReason' key='invalidTel'}{/if}
                                                        {include file='snippets/form_group_simple.tpl' options=['tel' , 'fax', 'fax', {$Vorgaben->cFax}, {lang key='fax' section='account data'}, {$Einstellungen.kontakt.kontakt_abfragen_fax}, {$invalidReason}]}
                                                    </div>
                                                </div>
                                            {/block}
                                        {/if}
                                        {assign var=cPost_arr value=$cPost_arr|default:[]}
                                        {block name='contact-index-include-checkbox'}
                                            {include file='snippets/checkbox.tpl' nAnzeigeOrt=$nAnzeigeOrt cPlausi_arr=$fehlendeAngaben cPost_arr=$cPost_arr}
                                        {/block}
                                    </div>
                                </div>
                            </fieldset>
                        {/block}
                        {block name='contact-index-hr'}
                            {* <hr class="contact-form-hr"> *}
                        {/block}
                        {block name='contact-index-fieldset-message'}
                            <fieldset class="et-boxed-content">
                                <div class="row">
                                    <div class="col col-12 col-lg-4">
                                        {block name='contact-index-legend-message'}
                                            <div class="h3">{lang key='message' section='contact'}</div>
                                        {/block}
                                    </div>
                                    <div class="col col-12 col-lg-8">
                                        {if $betreffs}
                                            {block name='contact-index-form-subject'}
                                                {if isset($fehlendeAngaben.betreff)}
                                                    <div role="alert" class="alert alert-danger">
                                                        {lang key='fillOut'}
                                                    </div>
                                                {/if}
                                                <div class="row">
                                                    <div class="col col-12 col-md-12">
                                                        {formgroup
                                                        class="{if isset($fehlendeAngaben.subject)} has-error{/if}"
                                                        label="{lang key='subject' section='contact'}"
                                                        label-for="subject"
                                                        }
                                                        {if !empty($fehlendeAngaben.subject)}
                                                            <div class="form-error-msg" aria-live="assertive" role="alert" aria-atomic="true"><i class="{et_getIcon key="missingInput"}"></i>
                                                                {lang key='fillOut'}
                                                            </div>
                                                        {/if}
                                                            <select name="subject" id="subject" class="form-control custom-select" required aria-invalid="{if isset($fehlendeAngaben.subject)}true{else}false{/if}">
                                                                <option value="" selected disabled>{lang key='subject' section='contact'}</option>
                                                                {foreach $betreffs as $betreff}
                                                                    <option value="{$betreff->kKontaktBetreff}" {if $Vorgaben->kKontaktBetreff == $betreff->kKontaktBetreff}selected{/if}>{$betreff->AngezeigterName}</option>
                                                                {/foreach}
                                                            </select>
                                                        {/formgroup}
                                                    </div>
                                                </div>
                                            {/block}
                                        {/if}
                                        {block name='contact-index-form-message'}
                                            <div class="row">
                                                <div class="col col-12 col-md-12">
                                                    {formgroup
                                                    class="{if isset($fehlendeAngaben.nachricht)} has-error{/if}"
                                                    label="{lang key='message' section='contact'}"
                                                    label-for="message"
                                                    }
                                                    {if !empty($fehlendeAngaben.nachricht)}
                                                        <div class="form-error-msg" aria-live="assertive" role="alert" aria-atomic="true"><i class="{et_getIcon key="missingInput"}"></i>
                                                            {lang key='fillOut'}
                                                        </div>
                                                    {/if}
                                                        <textarea class="form-control" name="nachricht" rows="10" id="message" required placeholder=" " aria-invalid="{if isset($fehlendeAngaben.nachricht)}true{else}false{/if}">{if isset($Vorgaben->cNachricht)}{$Vorgaben->cNachricht}{/if}</textarea>
                                                    {/formgroup}
                                                </div>
                                            </div>
                                        {/block}
                                    </div>
                                </div>
                            </fieldset>
                        {/block}
                        {if (!isset($smarty.session.bAnti_spam_already_checked) || $smarty.session.bAnti_spam_already_checked !== true) &&
                        isset($Einstellungen.kontakt.kontakt_abfragen_captcha) && $Einstellungen.kontakt.kontakt_abfragen_captcha !== 'N' && JTL\Session\Frontend::getCustomer()->getID() === 0}
                            {block name='contact-index-form-captcha'}
                                <hr>
                                <div class="row">
                                    <div class="col col-12 col-md-6 {if !empty($fehlendeAngaben.captcha)} has-error{/if}">
                                        {captchaMarkup getBody=true}
                                        <hr>
                                    </div>
                                </div>
                            {/block}
                        {/if}
                        {opcMountPoint id='opc_before_submit'}
                        {block name='contact-index-form-submit'}
                            <div class="row">
                                {if isset($oSpezialseiten_arr[$smarty.const.LINKTYP_DATENSCHUTZ])}
                                    <div class="col col-12 contact-form-privacy">
                                        {block name='contact-index-form-submit-privacy'}
                                            <a href="{$oSpezialseiten_arr[$smarty.const.LINKTYP_DATENSCHUTZ]->getURL()}" class="popup">
                                                {lang key='privacyNotice'}
                                            </a>
                                        {/block}
                                    </div>
                                {/if}
                                <div class="col col-12 col-lg-8 offset-lg-4">
                                    {block name='contact-index-form-submit-button'}
                                        <div class="row">
                                            <div class="col col-md-4 col-xl-3 ml-auto-util">
                                                <input type='hidden' name='kontakt' value='1' />
                                                {include file="widgets/base/button.tpl" type="submit" variant="primary" classes="btn-block" label="{lang key='sendMessage' section='contact'}"}
                                            </div>
                                        </div>
                                    {/block}
                                </div>
                            </div>
                        {/block}
                    {/block}
                </form>
                <br>
            {/block}
            {if !empty($Spezialcontent->unten)}
                {block name='contact-index-custom-content-bottom'}
                    <div class="custom_content">
                        {$Spezialcontent->unten}
                    </div>
                {/block}
            {/if}
        </div>
    {/if}
{/block}