{function menu item="menu_item" input="menu_input"}
   <ul>
      {foreach $data as $entry}
         <li {if !$opened[$entry.id]}class="collapsed"{/if}>
            <div class="row">
               <div class="col-md-4">
                   <span class="btn btn-link">
                       {if $entry.submenu}
                          <i class="btn-primary glyphicon glyphicon-{if $opened[$entry.id]}minus{else}plus{/if}"></i>
                       {/if}
                       {$entry.title}
                   </span>
               </div>

               {$item = $set[$entry.id]}
               <div class="col-md-1 control-label"><small>{'discount'|translate}</small></div>
               <div class="col-md-3">
                  <input type="hidden" name="plSecID[{$entry.id}]" value="{$entry.id}">
                  <input type="text" name="plSecDiscount[{$entry.id}]" value="{$item.discount}"
                         class="form-control input-sm" onKeyPress="checkInputData('float');"
                         style="float: left; width: 90%;">

                  {if $entry.submenu}
                     <span title="Překopírovat i do podsekcí" id="copyToSubsections" style="float: right; margin-top: 6px; color: #48cfad;"
                           class="glyphicon glyphicon-arrow-down">
                     </span>
                  {/if}
               </div>
               <div class="col-md-2">
                  <select name="plSecUnit[{$entry.id}]" class="selecter">
                     <option value="perc" {"perc"|selected:$item.unit}>%</option>
                     <option value="price" {"price"|selected:$item.unit}>{$dbcfg.currency}</option>
                  </select>
               </div>
            </div>
            {menu data=$entry.submenu item=$item}
         </li>
      {/foreach}
   </ul>
{/function}
<h1 class="h4 main-panel-title">{'discountSection'|translate}</h1>
<div class="tree">
   <ul>
      <li class="first-branch tree-highlight">
         {menu data=$body.tree set=$body.dbSec opened=$body.opened}
      </li>
   </ul>
</div>

<script type="text/javascript">
   $(document).on('click', '#copyToSubsections', function() {
      value = $(this).siblings('[name*="plSecDiscount"]').val();


      $(this).closest('li').find("[name*=\"plSecDiscount\"]").val(value);
   });
</script>
