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

{block title}
    Pozice {$body.data.code}
{/block}

{block size}
    {if $body.acn =="edit"}
        width = 1220;
        height = 900;
    {/if}
{/block}

{block tabs}
    {windowTab id='flapLocations' label="Pozice {$body.data.code}"}
{/block}

{block tabsContent}
    {if $body.acn =="edit"}
        {if findRight('WAR_PROD_EDIT')}

           {ifmodule PRODUCTS_BATCHES}
               {$batches= true}
           {/ifmodule}

           <div class="form-group">
              <div class="col-md-{if $batches}4{else}5{/if}">
                 <input type="text" class="form-control input-sm" id="id_product" name="data[id_product]" maxlength="100" value=""
                        onKeyPress="checkInputData('int')" placeholder="{'searchNameCode'|translate:'orders'}"/>
              </div>
              <div class="col-md-4">
                 <select id="id_variation" name="data[id_variation]" class="input-sm form-control selecter"  data-text-single="Vyberte variantu"></select>
                 <script type="text/javascript">
                    $(function () {
                       initAutocompleteVariation('#id_product', '#id_variation');
                    });
                 </script>
              </div>

               {if $batches}
                  <div class="col-md-2">
                     <select id="id_batch" name="data[id_product_batch]" class="input-sm form-control selecter" data-text-single="Vyberte šarži"></select>
                     <script type="text/javascript">
                        initAutocompleteBatches('#id_product', '#id_variation', '#id_batch');

                     </script>
                  </div>
               {/if}

              <div class="col-md-{if $batches}1{else}2{/if}">
                 <input type="text" class="form-control  input-sm"
                        name="data[pieces]" placeholder="ks" size="2" maxlength="255"
                        onkeypress="checkInputData('int');"/>
              </div>
              <div class="col-md-1">
                 <button type="submit" name='acn' value='editProducts' class="btn btn-primary btn-sm confirm"
                         title="seš si jistej, co děláš? Víš, že se to nemá!">{'editProducts'|translate}</button>
              </div>
           </div>
        {/if}

        <div id="flapLocations" class="tab-pane fade boxFlex box iframe-box">
            <iframe class='on-demand boxFlex' src="" data-src="launch.php?s=list.php&type=warehouseProducts&location={$body.data.id}"></iframe>
        </div>
    {else}
        <div class="form-group">
            <div class="col-md-1 control-label text-left">
                <label>Lokace</label>
            </div>
            <div class="col-md-2 control-label">
                <label>{'flapLocationsLabel'|translate}</label>
            </div>
        </div>
        <div id="flapLocations" class="tab-pane fade boxStatic">
            <div class="form-group">
                <div class="col-md-2 text-right">
                    <select name="data[id_location]" class="selecter">
                        {foreach $body.locations as $location}
                            <option value="{$location.id}">{$location.code}</option>
                        {/foreach}
                    </select>
                </div>
                <div class="col-md-3">
                    <input type="text" class="form-control input-sm" name="data[code]" maxlength="20" value="" placeholder="police-krabice, např. 02-03"/>
                </div>
            </div>
        </div>
    {/if}

    <div class="form-group">
        <div class="col-md-4">
            {insert_barcode height=30 width=2 code=$body.data.code}
        </div>
       <div class="col-md-4">
          {if $body.order.id}
               <div class="alert alert-warning">
                  Box obsahuje objednávku <a href="javascript:nw('order', '{$body.order.id}');">{$body.order.order_no}</a>.
               </div>
          {/if}
       </div>
       <div class="col-md-4">
          {if $body.store_transfer.id}
               <div class="alert alert-warning">
                  Box obsahuje převodku <a href="javascript:nw('storesTransfers', '{$body.store_transfer.id}');">{$body.store_transfer.id}</a>.
               </div>
          {/if}
       </div>
    </div>
{/block}
