{extends "index.tpl"}

{block "utils" append}
   {ifmodule REVIEWS}
   {get_ratings id_product=$body.product.id assign='product_reviews'}
   {/ifmodule}
{/block}

{block "css" append}
   {encore_entry_link_tags entry='product'}
{/block}

{block "og-image"}
   {if $body.product.image}
      <meta property="og:image" content="{$cfg.Addr.full|rtrim:"/"}{get_photo photo=$body.product.image size=108}">
   {else}
      <meta property="og:image" content="{static_url url="templates/images/share/fb-share-image.jpg" absolute=true}">
   {/if}
{/block}

{block "header-title"}
   {if !$body.product.meta_title}
      <title>{$body.product.model_short_title} {$body.product.model_section} {$seo_gender}
         - {$dbcfg.shop_title}</title>
   {else}
      <title>{$body.product.meta_title} - {$dbcfg.shop_title}</title>
   {/if}
{/block}

{block "meta-description"}
   {block "seo-gender"}
      {if $body.returnNav[0][1].text == "Ženy"}
         {$seo_gender = "pro ženy"}
      {elseif $body.returnNav[0][1].text == "Muži"}
         {$seo_gender = "pro muže"}
      {elseif $body.returnNav[0][1].text == "Děti"}
         {$seo_gender = "pro děti"}
      {/if}
   {/block}

   {$parent_cat = $body.returnNav[0]|array_slice:-2}
   {if $parent_cat[0].ID}
      {get_seo type="product" section=$parent_cat[0].ID sekce=$body.product.model_section
      nazev=$body.product.model_short_title pohlavi=$seo_gender assign="product_seo"}
   {/if}

   {if $header.meta_description != ""}
      <meta name="description" content="{$header.meta_description}">
   {elseif $product_seo.descr}
      <meta name="description" content="{$product_seo.descr}">
   {else}
      <meta name="description"
            content="{$body.product.model_short_title} {$body.product.model_section} {$seo_gender} za nejlepší cenu na Kosmetika-zdravi.cz. Originální produkt {$body.product.model_short_title} {$body.product.model_section} připraven ihned k odeslání.">
   {/if}
{/block}

{block "google_tag_manager"}
   {include 'block.analytics.gtm.tpl' pageType='product'}
{/block}

{block "main-class"}main-product{/block}

{block "breadcrumbs"}
   <div class="container">
      {include "components/breadcrumbs.tpl"}
   </div>
{/block}

{block "content"}
   {if $body.model.show_type == "ST2"}
      {$shade = false}
   {elseif $body.model.show_type == "ST3"}
      {$shade = true}
   {else}
      {$sorted_products = $body.products|sort_variations}
      {foreach $sorted_products as $product}
         {$shade = $product.photos|sort_photos:['O']|count}
         {break}
      {/foreach}
   {/if}

   {function productTitle}
      <div class="d-flex title-wrapper">
         {if $resp}
            <h2 class="h1 product-title-resp">{$body.product.model_short_title}
               <span class="h5 product-subtitle"><span
                          data-text="variation-title">{$body.product.descr|default:$body.product.model_section}</span> <span
                          data-text="variation-set"></span></span>
            </h2>
         {else}
            <h1>{$body.product.model_short_title}
               <span class="h5 product-subtitle"><span
                          data-text="variation-title">{$body.product.descr|default:$body.product.model_section}</span> <span
                          data-text="variation-set"></span></span>
            </h1>
         {/if}

         <div class="gender-wrapper{if $resp} gender-wrapper-resp{/if}">
            {if $body.product.sex}
               <div class="gender">
                  {if $body.product.sex == 'W'}
                     <span class="fc icons_gender-female"></span>
                     {t}Pro ženy{/t}
                  {elseif $body.product.sex == 'M'}
                     <span class="fc icons_gender-male"></span>
                     {t}Pro muže{/t}
                  {elseif $body.product.sex == 'U'}
                     <span class="fc icons_gender-unisex"></span>
                     {t}Unisex{/t}
                  {elseif $body.product.sex == 'K'}
                     <span class="fc icons_gender-child"></span>
                     {t}Pro děti{/t}
                  {/if}
               </div>
            {/if}

            {if $product_reviews.rating_count}
               {include "product/product.rating.microdata.tpl" hideScript=$resp}
            {/if}
         </div>
      </div>
   {/function}

   <div class="container product-container">

      {productTitle resp=true}

      <div class="product-wrapper row">
         <div class="col-lg-4 col-xl-5 col-xxs-12 product-detail-gallery">
            {include "product/product.photo.tpl"}
         </div>

         <div class="col-xxl-6 col-xl-7 col-lg-8 col-xxs-12" data-filter="products">
            <div class="d-flex">
               {* tagy *}
               <div class="product-tags">
                  {if $body.product.producer}
                     <a href="{url s=category IDcat=0 IDpd=$body.product.producer.id}">{$body.product.producer.title}</a>
                  {/if}
                  {foreach $body.product.sections as $section}
                     {if $section.name and $section.figure == "Y" and $section.parents[$activeCategory.breadcrumb[1].ID]}
                        <a href="{url s=category IDcat=$section.id}">{$section.name}</a>
                     {/if}
                  {/foreach}
                  {if $body.product.param[80].values}
                     {foreach $body.product.param[80].values as $value}
                        <span>{$value.value}</span>
                        {* todo link na aktivní filtr ? co když nebude zapnuté filtrování podle daného parametru ? *}
                     {/foreach}
                  {/if}

                  {foreach $body.product.param_list as $key => $param}
                     {if !in_array($key,[18,28,29,37,38,39,80,81]) && $param.figure!='N'}
                        {if $p != 1}
                           {$bcr = $activeCategory.breadcrumb|array_slice:-2}
                           {$p = 1}
                        {/if}
                        {foreach $param.parameters as $value => $param_name}
                           <a href="{$bcr[0].link}#{$param.name|strip_accent}=%5B%22{$value}%22%5D" data-variation="{foreach $param.products as $prod}{if $body.products[$prod].param[$key].values[$value]}{$prod};{/if}{/foreach}">
                              {if $body.product.param[$key].descr != '<!--BOOL-->'}
                                 {$param_name}
                              {else}
                                 {$param.name}
                              {/if}
                           </a>
                        {/foreach}
                     {/if}
                  {/foreach}

               </div>
               {block "product-code"}
                  <p class="product-code">{t}Kód{/t}: <span data-product-code></span></p>
               {/block}

            </div>

            {productTitle resp=false}

            {include "product/product.fn.gpsr_tab_content.tpl"}

            {if $shade}
               {include "product/product.variations.shade.tpl" listType='detail' listId=$body.product.id}
            {else}
               {include "product/product.variations.tpl" listType='detail' listId=$body.product.id}
            {/if}

            <div class="row product-deliveries-row">
               {if $body.product.inStore > 0 || $body.product.in_store_suppliers > 0}
                  <div class="col-sm-6 col-xxs-12 product-deliveries">
                     {block "product-delivery"}
                        <p class="h5">{t}Předpokládané doručení{/t}</p>
                        {get_delivery_dates assign='deliveries' product=$body.product}
                        {if $ctrl.currency == 'CZK'}
                           <p>
                              <strong>Česká pošta</strong>
                              <span>{$deliveries.list[1].date|format_date_locale_pretty:'eeee d. L. Y'}</span>
                           </p>
                           <p>
                              <strong>PPL</strong>
                              <span>{$deliveries.list[2].date|format_date_locale_pretty:'eeee d. L. Y'}</span>
                           </p>
                           <p>
                              <strong>Zásilkovna</strong>
                              <span>{$deliveries.list[7].date|format_date_locale_pretty:'eeee d. L. Y'}</span>
                           </p>
                        {else}
                           <p>
                              <strong>{$deliveries.list[9].name}</strong>
                              <span>{$deliveries.list[9].date|format_date_locale_pretty:'eeee d. L. Y'}</span>
                           </p>
                           <p>
                              <strong>Zásilkovna</strong>
                              <span>{$deliveries.list[8].date|format_date_locale_pretty:'eeee d. L. Y'}</span>
                           </p>
                        {/if}
                     {/block}
                  </div>
               {/if}
               <div class="col-sm-6 col-xxs-12">
                  <p class="h5">{t}Proč nakupovat u nás?{/t}</p>
                  {block "product-usp"}
                     <ul class="list-unstyled">
                        <li>{t}Garantovaná záruka originálu{/t}</li>
                        {if $cheapest_delivery and $cheapest_delivery->getValue()->isPositive()}
                           <li>{t escape=false cena=$cheapest_delivery|format_price}Poštovné od {cena} nebo zdarma{/t}</li>
                        {else}
                           <li>{t}Poštovné zdarma{/t}</li>
                        {/if}
                        <li>{t}Bleskové dodání kamkoliv si budete přát{/t}</li>
                     </ul>
                  {/block}
               </div>
            </div>

            {block "product-slider"}
               {if $body.model.id_richcontent or $body.hasCotyPictures}
                  {insert_slider label="product-richcontent" sliderClass="product-slider"}
               {else}
                  {insert_slider label="product" sliderClass="product-slider"}
               {/if}
            {/block}


            {if $body.product.param['1'] or $body.product.param['2'] or $body.product.param['3']}
               {include "product/product.params.tpl"}
            {/if}

            <h2 class="h4">{t}O produktu{/t}</h2>
            {include "product/product.description.tabs.tpl"}

         </div>
      </div>

      {insert_products type="productsInSerie" models=true id_serie=$body.serie.id_abra id_model=$body.model.id_abra count=12 offset=NULL image=2
      template="catalog/block.products.serie.tpl" catalog_class="col-lg-4 col-xxs-6"}
   </div>
   <div class="container container-padded">
      {insert_products type="soldProductsInSection" models=true id_section=$breadcrumbs[count($breadcrumbs)-2].ID id_product=$body.product.id count=8
      offset=NULL image=2 template="catalog/block.products.trending.tpl"}

      {insert_products type="last_visited_model" models=true ID=$body.product.id_model count=6 image=2 assign="last_visited"
      template="catalog/block.products.last_visited.tpl"}
   </div>
{/block}

{block "body" append}
   {*<div class="added-to-cart-resp" data-added-to-cart-resp>
      <h6>{t}Produkt je přidán do košíku{/t}</h6>
      <a href="{url s=cart}">{t}Přejít do košíku{/t}</a>
   </div>*}

   {include 'focus/focus.watchdog.tpl' class="watchdog-focus"}
{/block}

{block "js-entry" append}
   {encore_entry_script_tags entry='product'}
{/block}

{block "js-dynamic-load" append}
   {ifmodule REVIEWS}
   {if !$body.product->isold()}
      {asset_compile}
         <script src="/common/static/bootstrapvalidator/js/bootstrapValidator.js"></script>
         <script src="/common/static/bootstrapvalidator/js/language/{$ctrl.active_language_code}.js"></script>
      {/asset_compile}
   {/if}
   {/ifmodule}
{/block}

{block "fb-pixel" append}
   {if $dbcfg.analytics.fb_pixel.id}
      {include 'block.fbpixel.tpl' pageType='product'}
   {/if}
{/block}

{block analytics append}
   {if !isDebug() and $dbcfg.custom.karsaEhsopId and !$body.product->isold()}
      {include "block.karsa.tpl" karsa_products=$body.products}
   {/if}
{/block}
