{extends "email/base.tpl"}

{block email_hello}
   {$body.header nofilter}
{/block}

{block email_content}
   {if strpos($body.body, '{POLOZKY}')}
      {$items = $order->fetchItems()}
      {capture assign=items}
         <table border="0" cellpadding="0" cellspacing="0" width="100%" style="font-family: arial, helvetica, sans-serif; font-size: 12px;border-collapse: collapse;margin-bottom: 20px;">
            {foreach $items as $item}
               {$set = ""}
               {if $item.product}
                  {$item.product->fetchParameters()}
                  {$set = $item.product.param.22.value}
               {/if}
               <tr>
                  <td colspan="4" style="padding: 10px 2px 3px; font-weight: 700;">{$item.descr} <span style="padding: 10px 2px 3px; font-weight: 100;">{$set}</span></td>
               </tr>
               <tr>
                  <td style="border-bottom: 1px solid #e5e5e5;padding: 3px 2px 7px;"><strong>ID:</strong> {$item.id_product}</td>
                  <td style="border-bottom: 1px solid #e5e5e5;padding: 3px 2px 7px;"><strong>EAN:</strong> {$item.ean}</td>
                  <td style="border-bottom: 1px solid #e5e5e5;padding: 3px 2px 7px;" align="right">{$item.pieces} {t}ks{/t}</td>
                  <td style="border-bottom:1px solid #e5e5e5;padding: 3px 2px 7px;white-space: nowrap;" align="right">{$item.piece_price.value_without_vat|format_price:"ceil=no"}/{t}ks bez DPH{/t}</td>
               </tr>
            {/foreach}
         </table>
      {/capture}
      {$body.body = str_replace('{POLOZKY}', $items, $body.body)}
   {/if}

   {if strpos($body.body, '{POUKAZY}')}
      {$items = $order->fetchItems()}
      {$cf = $order->getSecurityCode()}
      {get_order_coupons order=$order assign='order_coupons'}
      {capture assign=vouchers}
         {if $order_coupons}
            <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse: collapse;margin-bottom: 20px;" class="table-vouchers">
               <caption style="padding: 7px 0;border-bottom: 2px solid #e5e5e5;font-weight: 700;text-align:left;">{t}Dárkové poukazy{/t}:</caption>
               {foreach $order_coupons as $key => $coupons}
                  {foreach $coupons as $coupon}
                     <tr>
                        <td style="border-bottom:1px solid #e5e5e5;padding: 3px 2px 7px;;">
                           {$items[$key]['descr']}, {t}platnost do{/t} {$coupon.date_to|format_date:'admin'}
                        </td>
                        <td style="border-bottom:1px solid #e5e5e5;padding:3px 2px 7px;;text-align: right;white-space: nowrap;">{t}Kód{/t} {$coupon.code}</td>
                        <td style="border-bottom:1px solid #e5e5e5;padding:3px 2px 7px;;text-align: right;white-space: nowrap;">
                           {$coupon_url = path('kupshop_orderingbundle_pdfcoupon', ['id_order' => $order.id, 'id_coupon' => $coupon.id, 'cf' => $cf], 0)}
                           <a href="{$coupon_url}" style="color: {$emailVars.colorPrimary}; font-weight: 700; text-decoration: none;
                                   text-transform: uppercase;" class="link">{t}Zobrazit{/t}</a>
                        </td>
                     </tr>
                  {/foreach}
               {/foreach}
            </table>
         {/if}
      {/capture}
      {$body.body = str_replace('{POUKAZY}', $vouchers, $body.body)}
   {/if}

   {$body.body nofilter}
{/block}

{block email_bye}
   {$body.footer nofilter}
{/block}