{ifmodule BONUS_PROGRAM}
{if $ctrl.id and $activePoints}
   <div class="cart-bonuspoints-picker">
      <div>
         <p class="title">{t}Uplatnit body{/t}</p>
         <p>{t}Máte celkem{/t}
            <strong>{$activePoints} {t plural="body" plural5="bodů" count=$activePoints}bod{/t}</strong>.</p>
         <p>1 {t}bod{/t} = {$data.discount|format_price:"currency={$data.unit};ceil=no;decimal=dynamic"}</p>
      </div>
      {block "cart-bonuspoints-picker-label"}{/block}
      <div class="submit-group {if $bonus_points}active{/if}">
          {if !$bonus_points}
             {get_used_bonus_points assign='usedBonusPoints'}
             {$maxActivePoints = max($activePoints - $usedBonusPoints, 0)}
             <input type="number" id="bonus_points_picker" name="{$name}[bonus_points]" value="{$bonus_points}"
                    class="form-control" min="0" step="1" max="{$maxActivePoints}" title="{t}Počet bodů{/t}"
                    data-bv-excluded="true" placeholder="{block "cart-bonuspoints-picker-placeholder"}{/block}" {if $maxActivePoints == 0}disabled{/if}>
             <input class="btn btn-secondary" type="submit" name="BonusProgramDiscount" value="{t}Použít body{/t}" {if $maxActivePoints == 0}disabled{/if}>
          {else}
             <span>{* todo preklad celeho stringu *}
                 {t}Uplatnili jste{/t} <strong>{$bonus_points}</strong> {t plural="body" plural5="bodů" count=$bonus_points}bod{/t}.
             </span>
             <input type="hidden" name="{$name}[bonus_points]" value="{$bonus_points}" data-bonuspoints="input">
             <button type="submit" name="BonusProgramDiscount" class="delete"
                     data-bonuspoints="delete">{t}zrušit{/t}</button>
             <script>
                wpj.onReady.push(function() {
                    {* todo dat do externiho JS *}
                   $('[data-bonuspoints="delete"]').on('click', function() {
                      $(this).siblings('[data-bonuspoints="input"]').val(0);
                   });
                });
             </script>
          {/if}
      </div>
   </div>
{/if}
{/ifmodule}
