{extends file="[shared]/window.tpl"}

{block tabsContent}
   <div class="row">
      <div class="col-xs-4 pull-right">
         <div class="wpj-form-group">
            <a href="#" data-add-all class="btn btn-success btn-block"><span
                  class="bi bi-plus-lg m-r-1"></span>{'buttonAddValue'|translate}</a>
         </div>
      </div>
   </div>
   <div class="wpj-panel wpj-panel-default">
      <div class="wpj-panel-heading">
         <div class="row">
            <div class="col-xs-5">
               <small class="text-muted">{'item'|translate:'preordersUsers'}</small>
            </div>
            <div class="col-xs-2">
               <small class="text-muted">{'piecePrice'|translate:'preordersUsers'}</small>
            </div>
            <div class="col-xs-2">
               <small class="text-muted">{'piecesSent'|translate:'preordersUsers'}</small>
            </div>
            <div class="col-xs-2">
               <small class="text-muted">{'piecesToAdd'|translate:'preordersUsers'}</small>
            </div>
            <div class="col-xs-1">
               <small class="text-muted"></small>
            </div>
         </div>
      </div>
      <div class="wpj-list-group">
          {foreach $body.data.items as $item}
              {if $item.pieces_sent >= $item.pieces}{continue}{/if}
             <div class="wpj-list-group-item">
                <div class="row">
                   <div class="col-xs-5">
                      <strong><a href="javascript:nw('products','{$item.id_product}');" class="text-dark">{$item.title}</a></strong>
                   </div>
                   <div class="col-xs-2">
                       {$item.piece_price|format_price}
                   </div>
                   <div class="col-xs-2">
                       {$item.pieces_sent} / {$item.pieces}
                   </div>
                   <div class="col-xs-2">
                      <div class="input-group">
                         <input class="form-control" name="data[items][{$item.id}]"
                                aria-label="{'piecesToAdd'|translate}">
                         <div class="input-group-btn">
                            <button type="button" data-add-all-count="{$item.pieces - $item.pieces_sent}" class="btn btn-success">Vše
                            </button>
                         </div>
                      </div>
                   </div>
                   <div class="col-xs-1">
                      <small class="text-muted"></small>
                   </div>
                </div>
             </div>
          {/foreach}
      </div>
   </div>
   <script>
      $('button[data-add-all-count]').on('click', function () {
         var $btn = $(this);
         var count = $btn.data('add-all-count');
         $btn.parent('.input-group-btn').siblings('input').val(count);
      });

      $('[data-add-all]').on('click', function (e) {
         $('button[data-add-all-count]').click();
      });
   </script>
{/block}
