{foreach $body.items|regroup:'id_order' as $order}
    {$first = $order|reset}
   <div class="returns-box-accordion returns-box returns-box-returns" data-returns{if $dbcfg.returns.returnMoreOrders == "Y"} data-returns-order="{$first.order_no}"{/if}>
      <div class="returns-box-accordion-order-header expanded" data-returns-toggle="{$first.order_no}">
         <p class="title-default">{t order_no=$first.order_no date=$first.date|format_date_locale_pretty:'d. L. Y'}Objednávka č. {order_no} ze dne {date}{/t}</p>
      </div>
      <div class="returns-box-accordion-order-items" data-returns-items="{$first.order_no}">
         {foreach $order as $item}
            {change_currency currency=$item.currency}
            {$img_size = "product_gallery"}
            {if isset($cfg.Photo.types["product_cart"])}{$img_size = "product_cart"}{/if}
            {$photo_dimensions = $cfg.Photo.types["product_cart"].size}
               <div class="item">
                  <div class="image">
                     <a href="{url s=product IDproduct=$item.product.id TITLE=$item.product.title}"
                        title="{t}Zobrazit produkt{/t}">
                        {block 'image'}
                           <img src="{get_photo photo=$item.product.image size=$img_size}" alt="{$item.product.title}"
                                class="img-responsive" width="{$photo_dimensions[0]}" height="{$photo_dimensions[1]}">
                        {/block}
                     </a>
                  </div>
                  <div class="title-wrapper">
                     <div class="title">
                        <a href="{url s=product IDproduct=$item.product.id TITLE=$item.product.title}"
                           title="{t}Zobrazit produkt{/t}">
                           {$item.product.title}
                        </a>
                        {if $item.id_variation}
                           <span class="variation-title">{$item.product.variationTitle}</span>
                        {/if}
                     </div>
                     <div class="price">{$item.piece_price_with_vat|format_price:"ceil=no"}</div>
                  </div>
                  {if $item.no_returns}
                     <div class="item-no-returns-message">{t}Tento produkt není možné vrátit.{/t}</div>
                  {else}
                  <label for="item_{$item.id}" class="custom-control custom-checkbox c-input c-checkbox">
                     <input class="custom-control-input" type="checkbox" name="return_items[{$item.id}][item]" id="item_{$item.id}"
                            value="{$item.id}" {if $item.selected}checked{/if}>
                     <span class="c-indicator custom-control-indicator"></span>
                     {t}vrátit{/t}
                  </label>
                  <div class="pieces {if !$body.returns.return_items[{$item.id}]}disabled{/if}" data-buy_count="wrapper">
                     {$step = $item.product.unit.step|default:1}
                     {ifmodule PRODUCTS__STEP}
                     {$data = $item.product->getData()}
                     {$step = $data.step|default:$step}
                     {/ifmodule}

                     {if $body.returns.return_items[{$item.id}].pieces}
                        {$pieces = $body.returns.return_items[{$item.id}].pieces}
                     {else}
                        {$pieces = $item.returnable_pieces}
                     {/if}

                     {if !$pieces}
                        {$step = 0}
                     {/if}
                     <input type="number" name="return_items[{$item.id}][pieces]"
                            value="{$pieces|string_format:"%.{$item.product.unit.pieces_precision|default:0}f"}"
                            class="form-control" step="{$step}" min="{$step}" max="{$item.returnable_pieces}"
                            data-buy_count="input"
                             {if $module.PRODUCTS__UNITS_FLOAT}
                                data-precision="{$item.product.unit.pieces_precision|default:0}"
                             {/if}
                     >
                     <div class="buy_count">
                        <button type="button" class="fc plus plus_unit" title="{t mnozstvi=$step}Přidat {mnozstvi} ks{/t}"
                                {if $pieces >= $item.returnable_pieces}disabled{/if}></button>
                        <button type="button" class="fc minus minus_unit" title="{t mnozstvi=$step}Odebrat {mnozstvi} ks{/t}"
                                {if $pieces <= $step}disabled{/if}></button>
                        {if $module.PRODUCTS__UNITS_FLOAT}
                           <p class="ordering-product-units">{$item.product.unit.short_name|lower}</p>
                        {/if}
                     </div>
                  </div>
                  <div class="form-group required" style="margin-left: 26px; margin-bottom: 6px;">
                     {$return_reason = $body.returns.return_items[{$item.id}].return_reason|default:-1}
                     <select name="return_items[{$item.id}][return_reason]" class="reason custom-select c-select form-control"
                             {if !$body.returns.return_items[{$item.id}]}disabled{else}required{/if}>
                        <option value="">{t}-- Vyberte důvod --{/t}</option>
                        {foreach $body.return_reasons as $key => $reason}
                           <option value="{$key}" {if $return_reason == $key}selected{/if}>{$reason}</option>
                        {/foreach}
                     </select>
                  </div>
                  {/if}
               </div>
            {/change_currency}
         {/foreach}
      </div>
   </div>
{/foreach}
