{extends "index.tpl"}

{block content}
   <div class="page-returns page-reclamations">
      <div class="reclamations-header m-b-2">
         <h1>{t}Reklamace{/t}</h1>
         {include "block.messages.tpl"}
         {insert_page type="RECLAMATIONS_LIST" use_default=1}
      </div>

      {if $body.reclamations|count}
         <h2 class="h5">{t}Moje reklamace{/t}</h2>
         <table class="table table-orders">
            <thead>
            <tr>
               <th>{t}Číslo{/t}</th>
               <th>{t}Objednávka{/t}</th>
               <th>{t}Datum podání{/t}</th>
               <th>{t}Produkty{/t}</th>
               <th>{t}Stav{/t}</th>
               <th>{t}Detail{/t}</th>
            </tr>
            </thead>

            {foreach $body.reclamations as $reclamation}
               <tr>
                  <td>{$reclamation.code}</td>
                  <td>{t}č.{/t} {$reclamation.order_no}</td>
                  <td>{$reclamation.date_created|format_date_locale_pretty:'d. L. Y'}</td>
                  <td>
                     {foreach $reclamation.item 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>
                     <strong>{$reclamation.status_name}</strong>
                     <small> {if $reclamation.status == 0}
                           ({$reclamation.date_created|format_date_locale_pretty:'d. L. Y'})
                        {elseif in_array($reclamation.status, $body.accepted_statuses)}
                           ({$reclamation.date_accepted|format_date_locale_pretty:'d. L. Y'})
                        {elseif in_array($reclamation.status, $body.handle_statuses)}
                           ({$reclamation.date_handle|format_date_locale_pretty:'d. L. Y'})
                        {/if}</small>
                  </td>
                  <td>
                     <a href="{path('kupshop_reclamations_reclamations_reclamation', ['id' => $reclamation.id])}"
                        class="btn btn-primary btn-sm">{t}Detail{/t}</a>
                  </td>
               </tr>
            {/foreach}
         </table>
      {/if}
   </div>
{/block}
