{extends "index.tpl"}

{block "css-entry" append}
   {encore_entry_link_tags entry='cart'}
{/block}

{block "meta-robots"}
   <meta name="robots" content="noindex, nofollow">
{/block}

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

{block "header"}
   {include 'ordering/ordering.header.tpl'}
{/block}

{block "main"}
   {block "tpl-vars"}
      {$tpl_vars.zasilkovna_btn_class = "btn-secondary btn-sm" scope="global"}
      {$tpl_vars.online_payment_visible_items = 1}
      {$tpl_vars.delivery_country_picker = false}
      {$tpl_vars.custom_stock_btn = true}
      {$tpl_vars.preselect_delivery = "false"}
      {$tpl_vars.gdpr_checkbox = ($dbcfg.consent.enable == 'Y')}
      {$tpl_vars.gift_show_price = false}
   {/block}

   {block 'printAvailability'}
      {function printAvailability}
         {*
            $product.availability rika, jestli jsou vsechny pozadovane kusy jedne polozky skladem.
            $product.availability == 0 a $product.inStore == 1 znamena, ze je skladem jen cast pozadovanych kusu.
            availability muze byt 0, 1 a 2
            2 se pouzive pouze pokud je zpanuty modul sklad dodavatelu (napr KK).
            Pozor, availability se muze upravit pomoci in_store_show_max
            Pokud se neodecita ze skladu, availability je 1 pokud deliverytime je 0.
         *}

         {if $product.availability == 0 and $product.inStore == 0}
            <p class="delivery delivery-notinstore">{$product.deliveryTimeText}</p>
         {elseif $product.availability == 0 and $product.inStore > 0 }
            <p class="delivery delivery-partly">{t pocet=$product.inStore}skladem pouze {pocet} ks{/t}</p>
         {elseif $product.availability == 1}
            <p class="delivery delivery-instore">
               {if $product.inStore < 4}
                  {t}skladem 1-3 kusy{/t}
               {else}
                  {$product.deliveryTimeText}
               {/if}
            </p>
         {elseif $product.availability == 2}
            {* ošklivost, ale $product.in_store_suppliers je tu vždy prázdné, asi je nemocný class.Cart *}
            {$productInStoreSuppliers = $product.product->getInStoreSuppliers()}
            {if $productInStoreSuppliers > 0}
               <p class="delivery delivery-instore">
                  {if $productInStoreSuppliers > 0 && $productInStoreSuppliers < 4}
                     {t}Skladem 1-3 balení{/t}
                  {else}
                     {$product.deliveryTimeText}
                  {/if}
               </p>
            {/if}
         {/if}

      {/function}
   {/block}

   {foreach $body.steps as $stepName => $step}
      {if $step@last and $stepName == $body.stepName}
         {$isLastStep = true scope='global'}
      {/if}
   {/foreach}

   {$totalCount = 0 scope='global'}
   {foreach $body.products as $item}
      {$totalCount = $totalCount + $item.pieces}
   {/foreach}

   <main class="main main-ordering main-{$body.stepName}">
      {block "order-process"}
         {include "ordering/ordering.process.tpl"}
      {/block}

      <div class="container container-narrow order-container">

         <form name="login" method="post" action="" id="cart" class="cart-form cart-{$body.stepName}">

            {include "ordering/ordering.messages.tpl"}

            <div class="order-content">
               <div>
                  {block "order-content"}
                  {/block}
               </div>
               {include "ordering/ordering.summary-sidebar.tpl"}
            </div>
         </form>
      </div>
      {block "cart-also_bought"}
      {/block}
   </main>
{/block}

{block "footer"}
   <div class="container container-narrow">
      {include 'components/footer/footer.top.tpl'}
   </div>
{/block}

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

{block "js-dynamic-load" append}
   {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}
{/block}
