{block name='productdetails-reviews'}
    {et_isShopVersionAtLeast value="5.5.0-rc.1" assign='shopIsAtLeast55'}
    <div class="reviews">
        {block name='productdetails-reviews-content'}
            <div id="reviews-overview" class="row">
                {* Ratings Overview *}
                {block name='productdetails-reviews-overview'}
                    {if $Artikel->Bewertungen->oBewertungGesamt->nAnzahl > 0}
                        <div class="col col-12">
                            {block name='productdetails-reviews-heading'}
                                <div class="et-productdetails-reviews-heading">
                                    {include file='productdetails/rating.tpl' total=$Artikel->Bewertungen->oBewertungGesamt->nAnzahl}
                                    <span>{$Artikel->Bewertungen->oBewertungGesamt->nAnzahl} {lang key='Votes'}</span>
                                </div>
                            {/block}
                        </div>

                        <div class="col col-12 col-md-6">
                            {block name='productdetails-reviews-votes'}
                                {foreach name=sterne from=$Artikel->Bewertungen->nSterne_arr item=nSterne key=i}
                                    {assign var=int1 value=5}
                                    {math equation='x - y' x=$int1 y=$i assign='schluessel'}
                                    {assign var=int2 value=100}
                                    {math equation='a/b*c' a=$nSterne b=$Artikel->Bewertungen->oBewertungGesamt->nAnzahl c=$int2 assign='percent'}
                                    <div class="row et-reviews-votes">
                                        <div class="col col-4 {if $et_ProductDetailInformation.displayMode == 'list'}col-lg-auto{else}col-lg-2{/if} et-reviews-votes-key">
                                        {if isset($bewertungSterneSelected) && $bewertungSterneSelected === $schluessel}
                                            <strong>
                                        {/if}
                                        {if $nSterne > 0 && (!isset($bewertungSterneSelected) || $bewertungSterneSelected !== $schluessel)}
                                            <a href="{$Artikel->cURLFull}?btgsterne={$schluessel}#tab-votes">{$schluessel} {if $i == 4}{lang key='starSingular' section='product rating'}{else}{lang key='starPlural' section='product rating'}{/if}</a>
                                        {else}
                                            {$schluessel} {if $i == 4}{lang key='starSingular' section='product rating'}{else}{lang key='starPlural' section='product rating'}{/if}
                                        {/if}
                                        {if isset($bewertungSterneSelected) && $bewertungSterneSelected === $schluessel}
                                            </strong>
                                        {/if}
                                        </div>
                                        <div class="col col-6 {if $et_ProductDetailInformation.displayMode == 'list'}col-lg-auto{else}col-lg-4{/if} ml-auto order-lg-2 et-reviews-votes-rating">
                                            {if !empty($nSterne)}{$nSterne}{else}0{/if} {lang key='Votes'}
                                        </div>
                                        <div class="col col-12 {if $et_ProductDetailInformation.displayMode == 'list'}col-lg{else}col-lg-6{/if} et-reviews-votes-progress">
                                            <div class="progress">
                                                <div class="progress-bar" role="meter" style="width: {round($percent)}%" aria-valuenow="{round($percent)}" aria-valuemin="0" aria-valuemax="100" aria-label="{$schluessel} {if $i == 4}{{lang key='starSingular' section='product rating'}|escape:'html'}{else}{{lang key='starPlural' section='product rating'}|escape:'html'}{/if}">
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                {/foreach}
                                {if isset($bewertungSterneSelected) && $bewertungSterneSelected > 0}
                                    {block name='productdetails-reviews-note-all-ratings'}
                                        <p>
                                            {include file="widgets/base/button.tpl" variant="primary" href="{$Artikel->cURLFull}#tab-votes" label="{lang key='allRatings'}" title="{lang key='allRatings'}"}
                                        </p>
                                    {/block}
                                {/if}
                            {/block}
                        </div>
                    {/if}
                {/block}

                {* Review *}
                {block name='productdetails-reviews-votes-form'}
                    <div class="col col-12 col-md-6 productdetails-product-rating">
                        <form method="post" action="{get_static_route id='bewertung.php'}#tab-votes" id="article_rating" class="label-slide">
                            {csrf_token}
                            <div class="subheadline">
                                {if $Artikel->Bewertungen->oBewertungGesamt->nAnzahl == 0}
                                    {lang key='firstReview'}
                                {else}
                                    {lang key='shareYourExperience' section='product rating'}
                                {/if}
                            </div>
                            <input type="hidden" name="bfa" value="1" />
                            <input type="hidden" name="a" value="{$Artikel->kArtikel}" />
                            {include file="widgets/base/button.tpl" type="submit" name="bewerten" value="1" variant="primary" label="{if $bereitsBewertet}{lang key='edit' section='product rating'}{else}{lang key='productAssess' section='product rating'}{/if}"}
                        </form>
                    </div>
                {/block}
            </div>
        {/block}

        {block name='productdetails-reviews-reviews-in-lang'}
            {* Not Used by easytemplate *}
        {/block}

        {* Most Useful Review *}
        {if isset($Artikel->HilfreichsteBewertung->oBewertung_arr[0]->nHilfreich) &&
            $Artikel->HilfreichsteBewertung->oBewertung_arr[0]->nHilfreich > 0
        }
            {block name='productdetails-reviews-form-most-useful'}
                <div class="card reviews-mosthelpful">
                    {block name='productdetails-reviews-most-helpful-header'}
                        <div class="card-header">
                            <span class="h3">
                                {lang key='theMostUsefulRating' section='product rating'}
                            </span>
                        </div>
                    {/block}
                    {block name='productdetails-reviews-most-helpful'}
                        <form method="post" action="{if $shopIsAtLeast55}{$Artikel->cURLFull}#tab-votes{else}{get_static_route id='bewertung.php'}#tab-votes{/if}" class="label-slide">
                            {csrf_token}
                            <input type="hidden" name="bhjn" value="1" />
                            <input type="hidden" name="a" value="{$Artikel->kArtikel}" />
                            <input type="hidden" name="btgsterne" value="{$BlaetterNavi->nSterne}" />
                            <input type="hidden" name="btgseite" value="{$BlaetterNavi->nAktuelleSeite}" />

                            {block name='productdetails-reviews-most-helpful-body'}
                                <div class="card-body review">
                                    {foreach $Artikel->HilfreichsteBewertung->oBewertung_arr as $oBewertung}
                                        {block name='productdetails-reviews-form-most-useful-include-review-item'}
                                            {include file='productdetails/review_item.tpl' oBewertung=$oBewertung bMostUseful=true}
                                        {/block}
                                    {/foreach}
                                </div>
                            {/block}
                        </form>
                    {/block}
                </div>
            {/block}
        {/if}

        {* Review Items *}
        {if $ratingPagination->getPageItemCount() > 0}
            {block name='productdetails-reviews-verified-purchase-notice'}
                {* Unused in ET360v2 *}
            {/block}
            {block name='productdetails-reviews-include-pagination-top'}
                {include file='snippets/pagination.tpl' oPagination=$ratingPagination cThisUrl=$Artikel->cURLFull cAnchor='tab-votes' cParam_arr=['btgsterne'=>$bewertungSterneSelected]}
            {/block}
            {block name='productdetails-reviews-form'}
                <form id="reviews-list" method="post" action="{if $shopIsAtLeast55}{$Artikel->cURLFull}#tab-votes{else}{get_static_route id='bewertung.php'}#tab-votes{/if}" class="reviews-list label-slide">
                    {csrf_token}
                    <input type="hidden" name="bhjn" value="1" />
                    <input type="hidden" name="a" value="{$Artikel->kArtikel}" />
                    <input type="hidden" name="btgsterne" value="{$BlaetterNavi->nSterne}" />
                    <input type="hidden" name="btgseite" value="{$BlaetterNavi->nAktuelleSeite}" />
                    {foreach $ratingPagination->getPageItems() as $oBewertung}
                        {block name='productdetails-reviews-form-include-review-item'}
                            <div class="review {if $oBewertung@last}last{/if}">
                                {include file='productdetails/review_item.tpl' oBewertung=$oBewertung}
                            </div>
                        {/block}
                    {/foreach}
                </form>
            {/block}
            {block name='productdetails-reviews-include-pagination-bottom'}
                {include file='snippets/pagination.tpl' oPagination=$ratingPagination cThisUrl=$Artikel->cURLFull cAnchor='tab-votes' cParam_arr=['btgsterne'=>$bewertungSterneSelected] showFilter=false}
            {/block}
        {/if}
    </div>
{/block}
