{extends "ordering.tpl"}

{block "order-content"}
   {block "cart-header-row"}
      <div class="row">
         {block "cart-heading"}
            <div class="col-xs-12 cart-heading {if !$ctrl.logged or $body.openOrders}col-md-6{/if}">
               <h1 class="h2">{t}Produkty v košíku{/t}</h1>
            </div>
         {/block}

         {block "cart-login"}
            {if !$ctrl.logged}
               <div class="col-xs-12 col-md-6 text-right cart-signin-div">
                  <div class="cart-signup">
                     <p>{t}Již u nás máte účet?{/t} <a href="" class="cart-signin">{t}Přihlaste se{/t}</a>.
                        <a href="{url s=user act=new}">{t}Registrace nového účtu{/t}</a>.
                     </p>
                  </div>
               </div>
            {/if}
         {/block}
      </div>
   {/block}

   {block "cart-products-row"}
      <div class="row">
         <div class="col-xs-12 " data-reload="cart">
            {if $body.products}
               {include "ordering/ordering.products.tpl"}

                {block "order-dicsount-render"}
                  {if findModule('order_discount')}
                     <div>
                        {foreach $body->getPurchaseState()->getDiscountHandlers() as $handler}
                            {$handler->render() nofilter}
                        {/foreach}
                     </div>
                  {/if}
                {/block}
            {else}
               <p class="alert alert-info" role="alert">{t}Váš košík je prázdný :({/t}</p>
            {/if}
         </div>
      </div>
   {/block}

   {block "cart-priceboxes"}
      <div class="row">
         <div class="col-sm-6 col-xs-12">
            {block 'cart-free-delivery'}
               {include "ordering/ordering.freedelivery.tpl"}
            {/block}
         </div>

         <div class="col-sm-6 col-xs-12 pull-right">
            {* slevový kupón *}
            {block 'cart-discount'}
               {include "ordering/ordering.voucher.tpl"}
            {/block}

            {* box s cenou, nezobrazuje dopravu *}
            {showPriceBox transport=0}

            {block 'cart-benefit-discount-points'}{/block}
         </div>
      </div>
   {/block}

   {block 'cart-buttons'}
      {cartBtns submitName='OrderNext' valueNext='delivery' msg="{t}Dopravu a platbu si vyberete v dalším kroku{/t}"}
   {/block}
{/block}


<script>
   {block onready append}
   {block "voucher-script"}
   $('.cart-voucher > p a').click(function () {
      $(this).parents('p').fadeOut().siblings('div').fadeIn().find(':input').focus();
      return false;
   });

   // disable voucher button when input is empty
   var voucherBtn = $('.cart-voucher input.btn');

   voucherBtn.prop('disabled', true);
   $('#couponNo').keyup(function (e) {
      voucherBtn.prop('disabled', this.value == "");
   }).keydown(function (e) {
      if (e.keyCode == 13)
         voucherBtn.click();
   });
   {/block}
   {/block}
</script>
