{extends "../list.tpl"}

{block buttons_dropup}
   <li>
      <a href="{$ctrl.currUrl.Rel}&acn=StockInExport" title="Export naskladnění s položkami">
         Export naskladnění s položkami
      </a>
   </li>
{/block}

{block "list-content" append}
    {if isset($price)}
       <div class="col-md-12">
          <div class="well">
             Cena celkem: <b>{$price|format_price}</b>
          </div>
       </div>
    {/if}
    {if $smarty.get.index == 'future'}
       <div class="col-md-2 col-md-offset-10">
          <div class="well">
             <input type="button" class="btn btn-primary btn-block" onClick="massStockIn();" value="Hromadná kontrola"/>
          </div>
       </div>
       <script type="text/javascript">
          function massStockIn() {
             let checked = $('input[name="stockIns"]:checked').map(function () {
                return this.value;
             }).get().join('_');

             nw('stockInCheck', checked);
          }
       </script>
    {/if}
{/block}

{block name="list-filter" append}
    {if !empty($var.closure_now.with_vat)}
       <div class="panel-heading">
          <div class="row">
             <div class="col-md-3 control-label">
                <strong>Aktuální hodnota skladu: </strong>
             </div>
             <div class="col-md-3">
                <strong>{$var.closure_now.with_vat|format_price} </strong>s DPH
             </div>
             <div class="col-md-3">
                <strong> {$var.closure_now.without_vat|format_price} </strong>bez DPH
             </div>
             <div class="col-md-2">
                <a href="?s=list.php&type=stockIn&acn=exportCurrentStore" class="btn btn-primary">Exportovat aktuální hodnotu skladu</a>
             </div>
          </div>
           {if !empty($var.closure_last)}
              <div class="row">
                 <div class="col-md-3 control-label">
                    <strong>Poslední uzávěrka: </strong>
                 </div>
                 <div class="col-md-3">
                    <strong>{$var.closure_last.without_vat|format_price} </strong>bez DPH
                 </div>
                 <div class="col-md-1 control-label">
                    <strong>Rozdíl: </strong>
                 </div>
                 <div class="col-md-3">
                    <strong> {{$var.closure_now.without_vat-$var.closure_last.without_vat}|format_price} </strong>bez DPH
                 </div>
              </div>
           {/if}
       </div>
    {/if}
{/block}

<script>
    {block onready append}
    var reload_timer;
    timeout_reload();

    $(document).on('click', 'input', function () {
       clearTimeout(reload_timer);
       timeout_reload();
    });

    function timeout_reload() {
       reload_timer = setTimeout(function () {
          window.location.reload(1);
       }, 60 * 1000);
    }
    {/block}
</script>
