{extends "index.tpl"}

{block content}
   <div class="page-returns">
      <div class="returns-header m-b-2">
         <h1>{t}Odstoupení od smlouvy{/t}</h1>
         {include 'block.messages.tpl'}
         {insert_page type="RETURNS_LIST" use_default=1}
      </div>

      {if $body.returns|count}
         <h2 class="h5">{t}Moje vrácené zboží{/t}</h2>
         <table class="table table-orders">
            <thead>
            <tr>
               <th class="hidden-xs-down">{t}Číslo{/t}</th>
               <th>{t}Objednávka{/t}</th>
               <th class="hidden-sm-down">{t}Datum podání{/t}</th>
               <th>{t}Produkty{/t}</th>
               <th class="hidden-sm-down">{t}Stav{/t}</th>
               <th>{t}Detail{/t}</th>
            </tr>
            </thead>

            {foreach $body.returns as $return}
               <tr>
                  <td class="hidden-xs-down">{$return.code}</td>
                  <td>{t}č.{/t} {$return.order_no}</td>
                  <td class="hidden-sm-down">{$return.date_created|format_date_locale_pretty:'d. L. Y'}</td>
                  <td>
                     {foreach $return.items as $item}
                        <a target="_blank"
                           href="{path('kupshop_content_redirect_redirect', ['type' => 'product', 'id' => $item.id_product])}">
                           {if $item.pieces}{$item.pieces} {t}ks{/t} {/if}{$item.descr}
                        </a>
                        <br>
                     {/foreach}
                  </td>
                  <td class="hidden-sm-down">
                     <strong>{$return.status_name}</strong>
                     <small> {if $return.status == 0}
                           ({$return.date_created|format_date_locale_pretty:'d. L. Y'})
                        {elseif in_array($return.status, $body.accepted_statuses)}
                           ({$return.date_accepted|format_date_locale_pretty:'d. L. Y'})
                        {elseif in_array($return.status, $body.handle_statuses)}
                           ({$return.date_handle|format_date_locale_pretty:'d. L. Y'}
                        {/if}</small>
                  </td>
                  <td>
                     <a href="{path('kupshop_returns_returns_return', ['id' => $return.id])}"
                        class="btn btn-primary btn-sm">{t}Detail{/t}</a>
                  </td>
               </tr>
            {/foreach}
         </table>
      {/if}
   </div>
{/block}
