{block name='account-my-account'}
    {$inWidget = $inWidget|default:false}
    {et_isShopVersionAtLeast value="5.2.0-beta" assign='shopIsAtLeast52'}
    {et_isShopVersionAtLeast value="5.3.0-rc.3" assign='shopIsAtLeast53'}
    {et_isShopVersionAtLeast value="5.4.0-rc.1" assign='shopIsAtLeast54'}
    {block name='heading'}
        {if !$inWidget}
            <h2>{lang key='welcome' section='login'} <span translate="no">{$Kunde->cVorname} {$Kunde->cNachname}</span></h2>
        {/if}
    {/block}
    {opcMountPoint id='opc_before_account_page'}
    {block name='account-my-account-head-data'}
        <div class="row account-head-data">
            <div class="col col-12 col-lg-6">
                {block name='account-my-account-alert'}
                    {lang key='myAccountDesc' section='login'}
                {/block}
            </div>
            <div class="col col-12 col-lg-6">
                {block name='account-my-account-account-credit'}
                    <div class="account-head-data-credit">
                        <h3>
                            {lang key='moneyOnAccount' section='login'}
                        </h3>
                        <div class="et-account-credit">
                            {lang key='yourMoneyOnAccount' section='login'}: {$Kunde->cGuthabenLocalized}
                        </div>
                    </div>
                {/block}
            </div>
        </div>
    {/block}
    {block name='account-my-account-account-data'}
        <div class="row">
            <div class="col col-12 col-lg-6 account-data-item account-data-item-orders">
                {block name='account-my-account-orders-content'}
                    <div class="card">
                        <div class="card-header">
                            {block name='account-my-account-orders-content-header'}
                                <div class="row align-items-center-util">
                                    <div class="col">
                                        <h2 class="h3">
                                            <a class='link-discreet' href="{$cCanonicalURL}?bestellungen=1">
                                                {lang key='myOrders'}
                                            </a>
                                        </h2>
                                    </div>
                                    <div class="col col-auto font-size-sm">
                                        <a href="{$cCanonicalURL}?bestellungen=1">
                                            {lang key='showAll'}
                                        </a>
                                    </div>
                                </div>
                            {/block}
                        </div>
                        {if count($Bestellungen) > 0}
                            {block name='account-my-account-orders-body'}
                                <div class="table-responsive">
                                    <table class="table table-vertical-middle">
                                        <tbody>
                                        {if isset($Einstellungen.global.global_rma_enabled) && $Einstellungen.global.global_rma_enabled === 'Y'}
                                            {$returnableProducts = $rmaService->getReturnableProducts()}
                                        {/if}
                                        {foreach $Bestellungen as $order}
                                            {if $order@index === 5}{break}{/if}
                                            <tr title="{lang key='showOrder' section='login'}: {lang key='orderNo' section='login'} {$order->cBestellNr}"
                                                class="clickable-row cursor-pointer"
                                                data-toggle="tooltip"
                                                data-placement="top"
                                                data-boundary="window"
                                                data-href="{$cCanonicalURL}?bestellung={$order->kBestellung}">
                                                <td>{$order->dBestelldatum}</td>
                                                <td class="text-right-util">{$order->cBestellwertLocalized}</td>
                                                <td class="text-right-util">
                                                   {$order->Status}
                                                </td>
                                                <td class="text-right-util d-none d-md-table-cell">
                                                    <a href="{$cCanonicalURL}?bestellung={$order->kBestellung}" title="{lang key='showOrder' section='login'}: {lang key='orderNo' section='login'} {$order->cBestellNr}" class="link-discreet">
                                                        <i class="{et_getIcon key="view"}"></i>
                                                    </a>
                                                    {if isset($Einstellungen.global.global_rma_enabled) && $Einstellungen.global.global_rma_enabled === 'Y' && $rmaService->isOrderReturnable($order->kBestellung, $returnableProducts)}
                                                        <a href="{$cCanonicalURL}?newRMA={$order->kBestellung}" class="ml-2 link-discreet" aria-label="{lang key='rma' section='rma'}: {lang key='rma_artikelwahl' section='rma'}" title="{lang key='rma' section='rma'}: {lang key='rma_artikelwahl' section='rma'}">
                                                            <i class="{et_getIcon key="redo"}"></i>
                                                        </a>
                                                    {/if}
                                                </td>
                                            </tr>
                                        {/foreach}
                                        </tbody>
                                    </table>
                                </div>
                            {/block}
                        {else}
                            {block name='account-my-account-orders-content-nodata'}
                                <div class="card-body">
                                    {lang key='noOrdersYet' section='account data'}
                                </div>
                            {/block}
                        {/if}
                    </div>
                {/block}
            </div>
            <div class="col col-12 col-lg-6 account-data-item account-data-item-address">
                {block name='account-my-account-billing-address'}
                    <div class="card">
                        <div class="card-header">
                            {block name='account-my-account-billing-address-header'}
                                <div class="row align-items-center-util">
                                    <div class="col">
                                        <h2 class="h3">
                                            <a class='link-discreet' href="{$cCanonicalURL}?editRechnungsadresse=1">
                                                {lang key='myPersonalData'}
                                            </a>
                                        </h2>
                                    </div>
                                    <div class="col col-auto font-size-sm">
                                        <a href="{$cCanonicalURL}?editRechnungsadresse=1">
                                            {lang key='showAll'}
                                        </a>
                                    </div>
                                </div>
                            {/block}
                        </div>
                        {block name='account-my-account-billing-address-body'}
                            <div class="table-responsive">
                                <table class="table table-vertical-middle">
                                    <tbody>
                                    {block name='account-my-account-billing-address-billing-address'}
                                        <tr>
                                            <td class="min-w-sm">
                                                <div class="et-account-personal-heading">{lang key='billingAdress' section='account data'}</div>
                                                <div class="et-account-personal-data" translate="no">{$Kunde->cStrasse} {$Kunde->cHausnummer}<br/>{$Kunde->cPLZ} {$Kunde->cOrt}, {$Kunde->cLand}</div>
                                            </td>
                                            <td class="text-right-util">
                                                <a
                                                    href="{$cCanonicalURL}?editRechnungsadresse=1"
                                                    title="{lang key='editBillingAdress' section='account data'}"
                                                    aria-label="{lang key='editBillingAdress' section='account data'}"
                                                >
                                                    <span class="{et_getIcon key="edit"}"></span>
                                                </a>
                                            </td>
                                        </tr>
                                    {/block}
                                    {if $shopIsAtLeast52}
                                        {block name='account-my-account-shipping-address-shipping-address'}
                                            <tr>
                                                <td class="min-w-sm">
                                                    <div class="et-account-personal-heading">{lang key='myShippingAddresses' section='global'}</div>
                                                </td>
                                                <td class="text-right-util">
                                                    <a href="{$cCanonicalURL}?editLieferadresse=1" aria-label="{lang key='editShippingAddress' section='account data'}">
                                                        <span class="{et_getIcon key="edit"}"></span>
                                                    </a>
                                                </td>
                                            </tr>
                                        {/block}
                                    {/if}
                                    {block name='account-my-account-billing-address-contact'}
                                        <tr>
                                            <td class="min-w-sm">
                                                <div class="et-account-personal-heading">{lang key='contactInformation' section='account data'} {lang key='and'} {lang key='email' section='account data'}</div>
                                                <div class="et-account-personal-data" translate="no">{$Kunde->cMail}</div>
                                            </td>
                                            <td class="text-right-util">
                                                <a
                                                    class='float-right'
                                                    href="{$cCanonicalURL}?editRechnungsadresse=1"
                                                    title="{lang key='editCustomerData' section='account data'}"
                                                    aria-label="{lang key='editCustomerData' section='account data'}"
                                                >
                                                    <span class="{et_getIcon key="edit"}"></span>
                                                </a>
                                            </td>
                                        </tr>
                                    {/block}
                                    {block name='account-my-account-billing-address-password'}
                                        <tr>
                                            <td class="min-w-sm">
                                                <div class="et-account-personal-heading">{lang key='password' section='account data'}</div>
                                            </td>
                                            <td class="text-right-util">
                                                <a
                                                    href="{get_static_route id='jtl.php' params=['pass' => 1]}"
                                                    title="{lang key='changePassword' section='login'}"
                                                    aria-label="{lang key='changePassword' section='login'}"
                                                >
                                                    <span class="{et_getIcon key="edit"}"></span>
                                                </a>
                                            </td>
                                        </tr>
                                    {/block}
                                    {block name='account-my-account-billing-address-twofa'}
                                        {if $shopIsAtLeast54 && $twoFAEnabled === true}
                                            <tr>
                                                <td class="min-w-sm">
                                                    <div class="et-account-personal-heading">{lang key='twoFactorAuthentication' section='account data'}</div>
                                                </td>
                                                <td class="text-right-util">
                                                    <a  href="{get_static_route id='jtl.php' params=['twofa' => 1]}"
                                                        title="{lang key='manageTwoFA' section='account data'}"
                                                        aria-label="{lang key='manageTwoFA' section='account data'}"
                                                    >
                                                        <span class="{et_getIcon key="edit"}"></span>
                                                    </a>
                                                </td>
                                            </tr>
                                        {/if}
                                    {/block}
                                    </tbody>
                                </table>
                            </div>
                        {/block}
                    </div>
                {/block}
                <div class="et-account-delete-action">
                    {include file="widgets/base/button.tpl" variant="danger" href="{get_static_route id='jtl.php' params=['del' => 1]}" title="{lang key='deleteAccount' section='login'}" label="{lang key='deleteAccount' section='login'}" iconPosition="left" icon="{et_getIcon key="delete"}"}
                </div>
            </div>
        </div>
        <div class="row">
            {if $Einstellungen.global.global_wunschliste_anzeigen === 'Y'}
                <div class="col col-12 col-lg-6 account-data-item account-data-item-wishlist">
                    {block name='account-my-account-wishlist-content'}
                        <div class="card" id="my-wishlists">
                            <div class="card-header">
                                {block name='account-my-account-wishlist-header'}
                                    <div class="row align-items-center-util">
                                        <div class="col">
                                            <h2 class="h3">
                                                <a class='link-discreet' href="{get_static_route id='wunschliste.php'}">
                                                    {lang key='myWishlists'}
                                                </a>
                                            </h2>
                                        </div>
                                        <div class="col col-auto font-size-sm">
                                            <a href="{get_static_route id='wunschliste.php'}">
                                                {lang key='showAll'}
                                            </a>
                                        </div>
                                    </div>
                                {/block}
                            </div>
                            {if count($oWunschliste_arr) >0}
                                {block name='account-my-account-wishlists'}
                                    {get_static_route id='wunschliste.php' assign='wlSlug'}
                                    <div class="table-responsive">
                                        <table class="table table-vertical-middle">
                                            <tbody>
                                            {foreach $oWunschliste_arr as $wishlist}
                                                <tr>
                                                    {block name='account-my-account-wishlist-name'}
                                                        <td>
                                                            {if $shopIsAtLeast52}
                                                                <div class="et-account-wishlist-heading"><a href="{$wlSlug}?wl={$wishlist->getID()}" class="link-discreet" title="{lang key="goToWishlist" section="global"}">{$wishlist->getName()}</a></div>
                                                                <div class="et-account-wishlist-data">{$wishlist->getProductCount()} {lang key='products'}</div>
                                                            {else}
                                                                <div class="et-account-wishlist-heading"><a href="{$wlSlug}?wl={$wishlist->kWunschliste}" class="link-discreet" title="{lang key="goToWishlist" section="global"}">{$wishlist->cName}</a></div>
                                                                <div class="et-account-wishlist-data">{$wishlist->productCount} {lang key='products'}</div>
                                                            {/if}
                                                        </td>
                                                    {/block}
                                                    {block name='account-my-account-wishlist-visibility'}
                                                        <td class="text-right-util">
                                                            <div class="d-inline-flex flex-nowrap">
                                                                {if $shopIsAtLeast52}
                                                                    <span data-switch-label-state="public-{$wishlist->getID()}" class="{if !$wishlist->isPublic()}d-none{/if}">
                                                                        {lang key='public'}
                                                                    </span>
                                                                    <span data-switch-label-state="private-{$wishlist->kWunschliste}" class="{if $wishlist->isPublic()}d-none{/if}">
                                                                        {lang key='private'}
                                                                    </span>
                                                                    <div class="custom-control custom-switch">
                                                                        <input type='checkbox'
                                                                               class='custom-control-input wl-visibility-switch'
                                                                               id="wl-visibility-{$wishlist->getID()}"
                                                                               data-wl-id="{$wishlist->getID()}"
                                                                               {if $wishlist->isPublic()}checked{/if}
                                                                               aria-label="{if $wishlist->isPublic()}{lang key='wishlistNoticePublic' section='login'}{else}{lang key='wishlistNoticePrivate' section='login'}{/if}"
                                                                        >
                                                                        <label class="custom-control-label" for="wl-visibility-{$wishlist->getID()}"></label>
                                                                    </div>
                                                                {else}
                                                                    <span data-switch-label-state="public-{$wishlist->kWunschliste}" class="{if $wishlist->nOeffentlich != 1}d-none{/if}">
                                                                        {lang key='public'}
                                                                    </span>
                                                                    <span data-switch-label-state="private-{$wishlist->kWunschliste}" class="{if $wishlist->nOeffentlich == 1}d-none{/if}">
                                                                        {lang key='private'}
                                                                    </span>
                                                                    <div class="custom-control custom-switch">
                                                                        <input type='checkbox'
                                                                               class='custom-control-input wl-visibility-switch'
                                                                               id="wl-visibility-{$wishlist->kWunschliste}"
                                                                               data-wl-id="{$wishlist->kWunschliste}"
                                                                               {if $wishlist->nOeffentlich == 1}checked{/if}
                                                                               aria-label="{if $wishlist->nOeffentlich == 1}{lang key='wishlistNoticePublic' section='login'}{else}{lang key='wishlistNoticePrivate' section='login'}{/if}"
                                                                        >
                                                                        <label class="custom-control-label" for="wl-visibility-{$wishlist->kWunschliste}"></label>
                                                                    </div>
                                                                {/if}
                                                            </div>
                                                        </td>
                                                    {/block}
                                                </tr>
                                            {/foreach}
                                            </tbody>
                                        </table>
                                    </div>
                                {/block}
                            {else}
                                {block name='account-my-account-wishlist-no-data'}
                                    <div class="card-body d-flex justify-content-center align-items-center flex-column">
                                        {lang key='noWishlist' section='account data'}
                                    </div>
                                {/block}
                            {/if}
                        </div>
                    {/block}
                </div>
            {/if}
            {if $Einstellungen.vergleichsliste.vergleichsliste_anzeigen === 'Y'}
                <div class="col col-12 col-lg-6 account-data-item account-data-item-comparelist">
                    {block name='account-my-account-comparelist'}
                        <div class="card account-comparelist">
                            <div class="card-header">
                                {block name='account-my-account-comparelist-header'}
                                    <h2 class="h3">
                                        <a class="link-discreet" href="{get_static_route id='vergleichsliste.php'}" title="{lang key='goToCompareList' section='comparelist'}">
                                            {lang key='myCompareList'}
                                        </a>
                                    </h2>
                                {/block}
                            </div>
                            <div class="card-body">
                                {block name='account-my-account-comparelist-body'}
                                    <p>
                                        {if count($compareList->oArtikel_arr) > 0}
                                            {lang key='compareListItemCount' section='account data' printf=count($compareList->oArtikel_arr)}
                                        {else}
                                            {lang key='compareListNoItems'}
                                        {/if}
                                    </p>
                                    {include file="widgets/base/button.tpl" variant="secondary" classes="btn-sm" href="{get_static_route id='vergleichsliste.php'}" title="{lang key='goToCompareList' section='comparelist'}" label="{lang key='goToCompareList' section='comparelist'}"}
                                {/block}
                            </div>
                        </div>
                    {/block}
                </div>
            {/if}
            {if isset($Einstellungen.global.global_rma_enabled) && $Einstellungen.global.global_rma_enabled === 'Y'}
                <div class="col-12 col-lg-6 account-data-item account-data-item-rma">
                    {block name='account-my-account-rma'}
                        <div class="card account-rma">
                            <div class="card-header">
                                {block name='account-my-account-rma-header'}
                                    <div class="row align-items-center-util">
                                        <div class="col">
                                            <h2 class="h3">
                                                {if count($rmas) > 0}
                                                    <a href="{$cCanonicalURL}?returns=1" class="text-decoration-none-util">
                                                    {lang key='myReturns' section='rma'}
                                                    </a>
                                                {else}
                                                    {lang key='myReturns' section='rma'}
                                                {/if}
                                            </h2>
                                        </div>
                                        {if count($rmas) > 0}
                                            <div class="col col-auto font-size-sm">
                                                <a href="{$cCanonicalURL}?returns=1" aria-label="{lang key='manageReturns' section='rma'}">
                                                    {lang key='showAll'}
                                                </a>
                                            </div>
                                        {/if}
                                    </div>
                                {/block}
                            </div>
                            {block name='account-my-account-rma-body'}
                                {if count($rmas) > 0}
                                    <div class="table-responsive">
                                        <table class="table table-vertical-middle">
                                            <tbody>
                                            {foreach $rmas as $rma}
                                                {block name='account-my-account-rma-body-rmaitem'}
                                                <tr class="clickable-row cursor-pointer" data-href="{$cCanonicalURL}?showRMA={$rma->id}">
                                                    <td>
                                                        <div class="d-block font-weight-bold">
                                                            <span class="far fa-calendar mr-2"></span>{$rma->createDate|date_format:"%d.%m.%Y"}
                                                            <span class="badge badge-{$rmaService->getStatus($rma)->class} ml-2">{$rmaService->getStatus($rma)->text}</span>
                                                        </div>
                                                        <small class="text-muted-util font-weight-bold">
                                                            {lang key='product'}
                                                            <span class="badge badge-light">
                                                                {$rma->getRMAItems()|count|default:0}
                                                            </span>
                                                        </small>
                                                        {assign var=returnAddress value=$rma->getReturnAddress()}
                                                        {if $returnAddress !== null}
                                                            <small class="text-muted-util ml-2">
                                                                {if $returnAddress->companyName}<span class="mr-2">{$returnAddress->companyName}</span>{/if}
                                                                <span class="mr-2">{$returnAddress->street} {$returnAddress->houseNumber}</span>
                                                                {$returnAddress->postalCode} {$returnAddress->city}
                                                            </small>
                                                        {/if}
                                                    </td>
                                                    <td class="text-right-util d-none d-md-table-cell">
                                                        <span class="{et_getIcon key="view"}"></span>
                                                    </td>
                                                </tr>
                                                {/block}
                                            {/foreach}
                                            </tbody>
                                        </table>
                                        <div class="card-body">
                                            <a class="btn btn-secondary btn-sm" href="{$cCanonicalURL}?newRMA=0" title="{lang key='rma' section='rma'}: {lang key='rma_artikelwahl' section='rma'}" aria-label="{lang key='rma' section='rma'}: {lang key='rma_artikelwahl' section='rma'}">
                                                {lang key='createRetoure' section='rma'}
                                            </a>
                                        </div>
                                    </div>
                                {else}
                                    {block name='account-my-account-rma-no-data'}
                                        <div class="card-body">
                                            <p>{lang key='rmaNoItems' section='rma'}</p>
                                            <a class="btn btn-secondary btn-sm" href="{$cCanonicalURL}?newRMA=0" title="{lang key='rma' section='rma'}: {lang key='rma_artikelwahl' section='rma'}" aria-label="{lang key='rma' section='rma'}: {lang key='rma_artikelwahl' section='rma'}">
                                                {lang key='createRetoure' section='rma'}
                                            </a>
                                        </div>
                                    {/block}
                                {/if}
                            {/block}
                        </div>
                    {/block}
                </div>
            {/if}
        </div>
    {/block}
    {opcMountPoint id='opc_after_account_page'}

    {block name='account-my-account-include-downloads'}
        {include file='account/downloads.tpl'}
    {/block}

    {block name='account-my-account-actions'}
        <div class="row btn-row">
            <div class="col col-md-auto col-12 ml-auto-util">
                {include file="widgets/base/button.tpl" variant="primary" classes="btn-block min-w-sm" href="{get_static_route id='jtl.php'}?logout=1" title="{lang key='logOut'}" iconPosition="left" icon="{et_getIcon key="logout"}" label="{lang key='logOut'}"}
            </div>
        </div>
    {/block}
{/block}
