{extends "../window.tpl"}


{block js}
   {$smarty.block.parent}
   <link rel="stylesheet" media="screen" type="text/css" href="./static/colorpicker/css/simpleSwatchPicker.css" />
   <script src="./static/colorpicker/js/jquery.simpleSwatchPicker.js"></script>

{/block}
{block tabs}
   {windowTab id='flapDeliveryType'}
{/block}

{block tabsContent}
   <div id="flapDeliveryType" class="tab-pane fade active in boxStatic">
      <div class="form-group">
         <div class="col-md-2 control-label">
            <label>{'show'|translate:'button'}</label>
            <a class="help-tip" data-toggle="tooltip" title="{'setVisibleInfo'|translate}">
               <i class="bi bi-question-circle"></i>
            </a>
         </div>
         <div class="col-md-1">
            {print_toggle name="figure"}
         </div>
      </div>
      <div class="form-group">
         <div class="col-md-2 control-label"><label>{'deliveryType'|translate}</label></div>
         <div class="col-md-4">
            {print_select name="data[id_delivery]" var=$body.delivery selected=$body.data.id_delivery}
         </div>
         <div class="col-md-2 control-label"><label>{'paymentType'|translate}</label></div>
         <div class="col-md-4">
            {print_select name="data[id_payment]" var=$body.payment selected=$body.data.id_payment}
         </div>
      </div>

      <div class="form-group">
         <div class="col-md-2 control-label"><label>{'price'|translate:'base'}</label></div>
         <div class="col-md-3">
            <div class="input-group">
               {if $body.data.currencies|count > 1}
                  <div class="input-group-btn" style="min-width:70px;">
                     <select class="selecter" id="currencySelecter" name="data[currency]">
                        {foreach $body.data.currencies as $currencyID => $currency}
                           <option{if $currencyID == $body.data.currency} selected{/if}>{$currencyID}</option>
                        {/foreach}
                     </select>
                  </div>
               {/if}
               <input type="text" class="form-control input-sm" name="data[price]" id="price" maxlength="20" value="{$body.data.price}" onKeyPress="checkInputData('float');" />
               <div class="input-group-btn" id="priceWithVatDropdown">
                  <a class="btn btn-primary dropdown-toggle btn-sm" data-toggle="dropdown">
                     <span id="priceWithVatState">{if $body.data.priceWithVat}{'with'|translate:'vat'}{else}{'without'|translate:'vat'}{/if} {'vat'|translate:'vat'}</span>
                     <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                     <li><a data-value="1">{'withTax'|translate:'choice'}</a></li>
                     <li><a data-value="0">{'withoutTax'|translate:'choice'}</a></li>
                  </ul>
               </div>
            </div>
            <span class="help-block">{'infoKeepEmptyToCalculate'|translate}</span>
         </div>
         <input type="hidden" name="data[priceWithVat]" id="priceWithVat" value="{if $body.data.priceWithVat}1{else}0{/if}" />
         <script type="text/javascript">
            $("#priceWithVatDropdown").on("click", "li a", function(e) {
               $("#priceWithVatState").html($(this).html());
               var value = $(this).data("value"), oldValue = $("#priceWithVat").val();
               $("#priceWithVat").val(value);
               if(oldValue != value) {
                  var vat = $("#priceVat :selected").data("vat"),
                     $price = $("#price");
                  switch(value) {
                     case 1:
                        $price.val(formatPrice($price.val() * (100 + vat) / 100));
                        break;
                     case 0:
                        $price.val(formatPrice($price.val() * 100 / (100 + vat)));
                        break;
                  }
                  $('input[name=data\\[discount\\]]').keyup();
               }
            });
         </script>

         <div class="col-md-2 col-md-offset-1 control-label"><label for="priceVat">{'tax'|translate}</label></div>
         <div class="col-md-3">
            <select name="data[vat]" class="selecter" id="priceVat" {($dbcfg.delivery_config.from_products == 'Y') ? 'disabled' : ''}>
               {foreach from=$body.vats item=vat key=key}
                  <option value="{$vat.id}" data-vat="{$vat.vat}" {if $body.data.vat == $vat.id}selected{/if}>
                     {$vat.descr}
                  </option>
               {/foreach}
            </select>
         </div>
      </div>
      <div class="form-group">
         <div class="col-md-2 control-label two-lines">
            <label>{'freeFrom'|translate}</label>
            <a class="help-tip" data-toggle="tooltip" title="{'priceDontCountInFrom'|translate}"><i class="bi bi-question-circle"></i></a>
         </div>
         <div class="col-md-3">
            <div class="input-group">
               <input type="text" class="form-control input-sm" name="data[price_dont_countin_from]" size="10" maxlength="10" value="{if $body.data.price_dont_countin_from !== null}{toDecimal($body.data.price_dont_countin_from)|format_editable_price:-4}{/if}"
                  onkeypress="checkInputData('float');" />
               <span class="input-group-addon" id="currencyDontCountinFrom">{$body.data.currency}</span>
            </div>
            <script>
               $('#currencySelecter').change(function(){
                  $('#currencyDontCountinFrom').text($(this).val());
               });
            </script>
            <span class="help-block">{'infoKeepEmptyToAlwaysPay'|translate}</span>
         </div>

         <div class="col-md-2 control-label">
            <label>{'freeFromReg'|translate}</label>
            <a class="help-tip" data-toggle="tooltip" title="{'priceDontCountInFromReg'|translate}"><i class="bi bi-question-circle"></i></a>
         </div>
         <div class="col-md-3">
            <div class="input-group">
               <input type="text" class="form-control input-sm" name="data[price_dont_countin_from_reg]" size="10" placeholder="{if $body.data.price_dont_countin_from !== null}{toDecimal($body.data.price_dont_countin_from)|format_editable_price:-4}{/if}" maxlength="10" value="{if $body.data.price_dont_countin_from_reg !== null}{toDecimal($body.data.price_dont_countin_from_reg)|format_editable_price:-4}{/if}"
                  onkeypress="checkInputData('float');" />
               <span class="input-group-addon" id="currencyDontCountinFromReg">{$body.data.currency}</span>
            </div>
            <script>
               $('#currencySelecter').change(function(){
                  $('#currencyDontCountinFromReg').text($(this).val());
               });
            </script>
            <span class="help-block">{'infoKeepEmptyToSame'|translate}</span>
         </div>
      </div>
      <div class="form-group">
         <div class="col-md-2 control-label">
            <label>{'highlight'|translate}</label>
            <a class="help-tip" data-toggle="tooltip" title="{'infoHighlight'|translate}">
               <i class="bi bi-question-circle"></i>
            </a>
         </div>
         <div class="col-md-2">
            <div class="input-group">
               <input type="text" id="colorSelector" name="data[format]" value="{$body.data.format}" class="form-control input-sm">

               <script type="text/javascript">
                  $('#colorSelector').simpleSwatchPicker({ 'palette' : 'pastel', 'selectMessage':'' });
               </script>
            </div>
         </div>
      </div>
      <div class="form-group">
         <div class="col-md-2 control-label">
            <label>{'description'|translate}</label>
            <a class="help-tip" data-toggle="tooltip" title="{'descriptionHelp'|translate}"><i class="bi bi-question-circle"></i></a>
         </div>
         <div class="col-md-10">
            <textarea name="data[description]" class="form-control input-sm">{$body.data.description}</textarea>
            {insert_wysiwyg target="data[description]"}
            <span class="help-block">
               {'infoPlaceholder1'|translate} <a href="javascript:nw('emails', '0', '&flap=2&symbols=1')" target="_blank">{'infoPlaceholder2'|translate}</a>
            </span>
         </div>
      </div>
   </div>
{/block}
