{block name='account-downloads'}
    {if !empty($Bestellung->oDownload_arr)}
        {block name='account-downloads-subheading'}
            <h2>{lang key='yourDownloads'}</h2>
        {/block}
        {block name='account-downloads-order-downloads'}
            {foreach $Bestellung->oDownload_arr as $oDownload}
                <div class="card col-12 col-md-8 download-item">
                    <div class="card-header" id="download-{$oDownload@iteration}">
                        <button class="btn btn-block btn-link" role="button"
                            aria-expanded="false"
                            aria-controls="collapse-download-{$oDownload@iteration}"
                            data-toggle="collapse"
                            data-target="#collapse-download-{$oDownload@iteration}"
                        >
                            {block name='account-downloads-order-downloads-item-heading'}
                                {$oDownload->oDownloadSprache->getName()}
                            {/block}
                        </button>
                    </div>

                    <div id="collapse-download-{$oDownload@iteration}" class="collapse">
                        <div class="card-body">
                            {block name='account-downloads-order-downloads-item-body'}
                                <div class="row">
                                    <div class="col col-md-4">{lang key='downloadOrderDate'}:</div>
                                    <div class="col col-md-8">{$Bestellung->dErstellt|default:"--"|date_format:"d.m.Y H:i"}</div>
                                </div>
                                <div class="row">
                                    <div class="col col-md-4">{lang key='downloadLimit'}:</div>
                                    <div class="col col-md-8">{$oDownload->cLimit|default:{lang key='unlimited'}}</div>
                                </div>
                                <div class="row">
                                    <div class="col col-md-4">{lang key='validUntil'}:</div>
                                    <div class="col col-md-8">{$oDownload->dGueltigBis|default:{lang key='unlimited'}}</div>
                                </div>
                                <div class="row">
                                    <div class="col col-md-4">{lang key='download'}:</div>
                                    <div class="col col-md-8">
                                        {if $Bestellung->cStatus == $smarty.const.BESTELLUNG_STATUS_BEZAHLT
                                        || $Bestellung->cStatus == $smarty.const.BESTELLUNG_STATUS_VERSANDT
                                        || $Bestellung->cStatus == $smarty.const.BESTELLUNG_STATUS_TEILVERSANDT}
                                            <form
                                                method="post"
                                                action="{get_static_route id='jtl.php'}"
                                                class="jtl-validate label-slide"
                                            >
                                                {csrf_token}

                                                <input name="a" type="hidden" value="getdl" />
                                                <input name="bestellung" type="hidden" value="{$Bestellung->kBestellung}" />
                                                <input name="dl" type="hidden" value="{$oDownload->getDownload()}" />

                                                {block name='account-downloads-order-downloads-item-download-button'}
                                                    {include file="widgets/base/button.tpl" variant="primary" classes="btn-sm" type="submit" label="{lang key='download'}" icon="{et_getIcon key="download"}" iconPosition="left"}
                                                {/block}
                                            </form>
                                        {else}
                                            {lang key='downloadPending'}
                                        {/if}
                                    </div>
                                </div>
                            {/block}
                        </div>
                    </div>
                </div>
            {/foreach}
        {/block}
    {elseif !empty($oDownload_arr)}
        {block name='account-downloads-customer-downloads'}
            <div class="row">
                <div class="col col-12 col-md-6">
                    <div class="card download-main account-data-item">
                        <div class="card-header">
                            {block name='account-downloads-customer-downloads-heading'}
                                <h2 class="h3">
                                    {lang key='myDownloads'}
                                </h2>
                            {/block}
                        </div>
                        <div class="card-body download-main-body">
                            <div id="account-download-accordion">
                                {block name='account-downloads-customer-downloads-items'}
                                {block name='account-downloads-customer-downloads-body'} {* NOVA Block since 5.3.x *}
                                    {foreach $oDownload_arr as $oDownload}
                                        <div class="card download-item">
                                            <div class="card-header" id="download-{$oDownload@iteration}">
                                                <button class="btn btn-block btn-link" role="button"
                                                    aria-expanded="false"
                                                    aria-controls="collapse-download-{$oDownload@iteration}"
                                                    data-toggle="collapse"
                                                    data-target="#collapse-download-{$oDownload@iteration}"
                                                >
                                                    {block name='account-downloads-customer-downloads-item-heading'}
                                                        {$oDownload->oDownloadSprache->getName()}
                                                    {/block}
                                                </button>
                                            </div>

                                            <div class="collapse" id="collapse-download-{$oDownload@iteration}"
                                                aria-labelledby="download-{$oDownload@iteration}"
                                                data-parent="#account-download-accordion"
                                            >
                                                <div class="card-body">
                                                    {block name='account-downloads-customer-downloads-item-body'}
                                                        {assign var=cStatus value=$smarty.const.BESTELLUNG_STATUS_OFFEN}
                                                        {foreach $Bestellungen as $Bestellung}
                                                            {if $Bestellung->kBestellung == $oDownload->kBestellung}
                                                                {assign var=cStatus value=$Bestellung->cStatus}
                                                                {assign var=dErstellt value=$Bestellung->dErstellt}
                                                            {/if}
                                                        {/foreach}
                                                        <div class="row">
                                                            <div class="col col-md-4">{lang key='downloadOrderDate'}:</div>
                                                            <div class="col col-md-8">{$dErstellt|default:"--"|date_format:"d.m.Y H:i"}</div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col col-md-4">{lang key='downloadLimit'}:</div>
                                                            <div class="col col-md-8">{$oDownload->cLimit|default:{lang key='unlimited'}}</div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col col-md-4">{lang key='validUntil'}:</div>
                                                            <div class="col col-md-8">{$oDownload->dGueltigBis|default:{lang key='unlimited'}}</div>
                                                        </div>
                                                        <div class="row">
                                                            <div class="col col-md-4">{lang key='download'}:</div>
                                                            <div class="col col-md-8">
                                                            {form method="post" action="{get_static_route id='jtl.php'}" slide=true}
                                                            <form method="post" action="{get_static_route id='jtl.php'}" class="jtl-validate label-slide">
                                                                {csrf_token}

                                                                <input name="kBestellung" type="hidden" value="{$oDownload->kBestellung}" />
                                                                <input name="kKunde" type="hidden" value="{JTL\Session\Frontend::getCustomer()->getID()}" />
                                                                {if $cStatus == $smarty.const.BESTELLUNG_STATUS_BEZAHLT
                                                                || $cStatus == $smarty.const.BESTELLUNG_STATUS_VERSANDT
                                                                || $cStatus == $smarty.const.BESTELLUNG_STATUS_TEILVERSANDT}
                                                                    <input name="dl" type="hidden" value="{$oDownload->getDownload()}" />
                                                                    {block name='account-downloads-customer-downloads-item-download-button'}
                                                                        {include file="widgets/base/button.tpl" variant="primary" classes="btn-sm" type="submit" label="{lang key='download'}" icon="{et_getIcon key="download"}" iconPosition="left"}
                                                                    {/block}
                                                                {else}
                                                                    {lang key='downloadPending'}
                                                                {/if}
                                                            {/form}
                                                            </div>
                                                        </div>
                                                    {/block}
                                                </div>
                                            </div>
                                        </div>
                                    {/foreach}
                                {/block}
                                {/block}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        {/block}
    {/if}
{/block}
