{extends "../window.tpl"}

{block js}
   {$smarty.block.parent}
   <script type="text/javascript" src="../ckeditor/ckeditor.js"></script>
   <script type="text/javascript" src="static/js/jquery.mjs.nestedSortable.min.js"></script>
   <script src="static/js/chosen.image.js"></script>
   <script type="text/javascript" src="static/js/blocks.js?2"></script>
{/block}
{block tabs}
   {windowTab id='flapSection'}
   {windowTab id='flapBlocks'}
   {if findModule('sections_lead')}
      {windowTab id='flapLead'}
   {/if}
   {if findModule("products_parameters") && !findModule('components')}
      {windowTab id='flapSearch'}
   {/if}
   {windowTab id='flapSeo' label='flapSeo'|translate:'seo'}
   {if findModule('feeds')}
      {windowTab id='flapXML'}
   {/if}
   {if $body.acn == 'edit' && $body.data.id > 0}
      {windowTab id='flapProducts'}
   {/if}
   {if $body.acn == 'edit' && findModule("photos")}
      {windowTab id='flapPhotos' label="{'flapPhotos'|translate}"}
   {/if}
{/block}

{block tabsContent}
   <div id="flapSection" class="tab-pane fade active in boxStatic">
      <div class="row">
         <div class="col-xs-6">
            <div class="wpj-form-group">
               <label>{'name'|translate}</label>
               <input type="text" class="form-control input-sm" name="data[name]" size="30" maxlength="200" value="{$body.data.name}"
                      required/>
            </div>
         </div>
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <label>{'name_short'|translate}
                  <a class="help-tip" data-toggle="tooltip" title="{'name_short_help'|translate}"><i
                        class="bi bi-question-circle"></i></a>
               </label>
               <input type="text" class="form-control input-sm" name="data[name_short]" size="30" maxlength="50"
                      value="{$body.data.name_short}"/>
            </div>
         </div>
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <label>{'redirect_url'|translate}
                  <a class="help-tip" data-toggle="tooltip" title="{'redirect_url_help'|translate}"><i
                        class="bi bi-question-circle"></i></a>
               </label>
               <input type="text" class="form-control input-sm" name="data[redirect_url]" pattern="^\/?(.+)" value="{$body.data.redirect_url}"
                      placeholder="/url-address"/>
            </div>
         </div>
      </div>

      {if $module.PRODUCTS_SECTIONS__ANNOTATION}
         <div class="row">
            <div class="col-xxs-12">
               <div class="wpj-form-group">
                  <label>{'annotation'|translate}</label>
                  <textarea class="form-control" name="data[annotation]" cols="3">{$body.data.annotation}</textarea>
               </div>
            </div>
         </div>
      {/if}

      <div class="row">
         <div class="col-xs-6">
            <div class="wpj-form-group">
               {* todo new autocomplete *}
               <label>{'topSection'|translate}</label>
               <select class="selecter" name="sections[]" data-autocomplete="categories" data-visibleOnly="false"
                       data-preload="sections">
                  <option value="" {$find.IDcat|checked:'0'}>[{'root'|translate}]</option>
                  {foreach $body.sections as $selectedSection}
                     <option value="{$selectedSection}" selected>{$selectedSection}</option>
                  {/foreach}
               </select>
            </div>
         </div>
         <div class="col-xs-3{if $body.data.id == 0} hidden{/if}">
            <div class="wpj-form-group">
               <label>{'visibility'|translate}</label>
               {$figures = ['Y' => {'figureY'|translate}, 'N' => {'figureN'|translate}, 'O' => {'figureO'|translate}]}
               {print_select name="data[figure]" var=$figures selected=$body.data.figure}
            </div>
         </div>
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <label>{'priority'|translate}</label>
               {print_select name="data[priority]" selected=$body.data.priority|default:0 var=[-1 => {'priority_minor'|translate}, 0 => {'priority_normal'|translate}, 1 => {'priority_major'|translate}]}
            </div>
         </div>
      </div>

      <div class="row">
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <div class="d-flex align-items-center">
                  {print_toggle value=$body.data.show_in_search name="show_in_search"}
                  <label>{'showInSearch'|translate nofilter}</label>
               </div>
            </div>
         </div>
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <div class="d-flex align-items-center">
                  {print_toggle name="behaviour"}
                  <label>{'behaviour'|translate nofilter}</label>
               </div>
            </div>
         </div>
      </div>

      <div class="row">
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <label class="label-legend">{'sectionPhoto'|translate} <small>{$cfg.Photo.types.section.size[0]}x{$cfg.Photo.types.section.size[1]}px</small></label>

               {if $body.acn =="edit" && !empty($body.data.photo)}
                  <div class="wpj-image-upload-wrapper">
                     <span class="image-placeholder">
                        <img src="{static_url url=$body.data.photo.src}" alt="{$body.data.name}" class="img-responsive">
                     </span>
                     <a href="javascript:nw('imageEditor', '{$body.data.id}', 'type=section');" class="btn btn-secondary">
                        <span class="bi bi-brush"></span>
                     </a>
                     <a class="btn btn-danger"
                        href="launch.php?s=sections.php&amp;acn=erasephoto&amp;ID={$body.data.id}&amp;IDsec={$body.data.id}">
                        <span class="bi bi-trash"></span>
                     </a>
                  </div>
               {else}
                  <div class="wpj-image-upload-wrapper">
                     <span class="image-placeholder empty">
                        <span class="bi bi-image-fill"></span>
                     </span>

                       <div>
                          <input type="file" class="filestyle" name="picture" data-iconName="bi bi-upload"
                                 data-buttonName="btn-success" data-buttonText=""/>
                          <span class="help-block">{'sectionPhotoNote'|translate}</span>
                       </div>
                  </div>
               {/if}
            </div>
         </div>

      </div>

      {block "custom-data"}{/block}

      {ifmodule SLIDERS}
      {$positions = KupShop\ContentBundle\Util\SliderUtil::getPositions()}
         <div class="row">
            <div class="col-xs-12">
               <div class="wpj-main-panel-title">
                  <h4>{'sliderTitle'|translate}</h4>
               </div>
            </div>
            {foreach $positions as $position => $positionName}
               <div class="col-xs-3">
                  <div class="wpj-form-group">
                     <label for="sliders-select">{if count($positions) === 1}Banner{else}{$positionName} banner{/if}</label>
                     <select
                        id="sliders-select"
                        name="data[sliders][{$position}]"
                        class="selecter"
                        data-autocomplete="sliders"
                        data-preload="sliders"
                     >
                        <option value=""></option>
                        {if $body.data.sliders[$position]}
                           <option value="{$body.data.sliders[$position].id_slider}" selected>{$body.data.sliders[$position].id_slider}</option>
                        {/if}
                     </select>
                  </div>
               </div>
            {/foreach}
         </div>
      {/ifmodule}

      <div class="row">
         <div class="col-xs-12">
            <div class="wpj-main-panel-title">
               <h4>{'orderby_default'|translate}</h4>
            </div>
         </div>
      </div>

      <div class="row wpj-form-group-flex">
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <label>{'orderby'|translate}</label>
               <select name="data[orderby]" class="selecter">
                  {block 'sections-order-by'}
                     {foreach $body.sortOptions as $sort => $_}
                        {$sortTitle = implode('_', ['orderby', $sort])}
                        <option value="{$sort}" {$body.data.orderby|selected:$sort}>{$sortTitle|translate}</option>
                     {/foreach}
                  {/block}
               </select>
            </div>
         </div>
         <div class="col-xs-4">
            <div class="wpj-form-group">
               <div class="d-flex align-items-center">
                  {print_toggle nameRaw="data[data][enable_sort_by_in_store]" value=$body.data.data.enable_sort_by_in_store|default:$dbcfg.sort_in_cat_by_in_store}
                  <label>{'enableDefaultSortByInStore'|translate}
                     <a class="help-tip" data-toggle="tooltip" title="{'enableDefaultSortByInStore_help'|translate}"><i
                           class="bi bi-question-circle"></i></a>
                  </label>
               </div>
            </div>
         </div>
      </div>
      <div class="row wpj-form-group-flex">
         <div class="col-xs-3">
            <div class="wpj-form-group">
               <label>{'orderdir'|translate}</label>
               <select name="data[orderdir]" class="selecter">
                  <option value="ASC" {$body.data.orderdir|selected:"ASC"}>{'orderdir_asc'|translate}</option>
                  <option value="DESC" {$body.data.orderdir|selected:"DESC"}>{'orderdir_desc'|translate}</option>
               </select>
            </div>
         </div>
         <div class="col-xs-4">
            <div class="wpj-form-group">
               <div class="d-flex align-items-center">
                  {print_toggle nameRaw="data[data][enable_sort_by_product_position]" value=$body.data.data.enable_sort_by_product_position|default:'Y'}
                  <label>{'enableDefaultSortByProductPosition'|translate}
                     <a class="help-tip" data-toggle="tooltip" title="{'enableDefaultSortByProductPosition_help'|translate}"><i
                           class="bi bi-question-circle"></i></a>
                  </label>
               </div>
            </div>
         </div>
      </div>


      {ifmodule PRODUCTS_SECTIONS__TOP_PRODUCT}
         <div class="row">
            <div class="col-xs-3">
               <div class="wpj-form-group">
                  <div class="d-flex align-items-center">
                     {print_toggle nameRaw="data[data][first_top_as_double_tile]" value=$body.data.data.first_top_as_double_tile}
                     <label>{'first_top_as_double_tile'|translate}</label>
                  </div>
               </div>
            </div>
         </div>
      {/ifmodule}

      {if $cfg.Sections.Flags}
         <div class="row">
            <div class="col-xs-12">
               <label>{'flags'|translate}</label>
               <div class="">
                  {foreach $cfg.Sections.Flags as $key => $flag}
                     <div class="checkbox pull-left">
                        <input type="checkbox" name="data[flags{$key}]" value="ON" {if $body.data.flags and $body.data.flags[$key]}checked="checked"{/if}
                               id="c{$key}" class="check"/>
                        <label for="c{$key}">{$flag.plural}</label>
                     </div>
                  {/foreach}
               </div>
            </div>
         </div>
      {/if}

      {if $cfg.tpl.submenu_product}
         {if !$body.sections[0]} {* produkt v menu u root sekce *}
            <div class="row">
               <div class="col-xs-6">
                  <div class="wpj-form-group">
                     <label>Produkt v menu</label>
                     <select name="data[data][products][]" multiple='multiple' class="selecter" data-type="ProductId" data-preload="products"
                             data-autocomplete="products">
                        {foreach $body.data.data.products as $product}
                           <option value="{$product}" selected>{$product}</option>
                        {/foreach}
                     </select>
                  </div>
               </div>
            </div>
         {/if}
      {/if}

      {if isSuperuser()}
         <div class="row">
            <div class="col-xs-12">
               <div class="wpj-main-panel-title">
                  <h4>Šablona <span class="glyphicon glyphicon-flash" style="color:#AAB2BD;" title="Vidí pouze superadmin"></span></h4>
               </div>
            </div>
         </div>
         <div class="row">
            <div class="col-xs-6">
               <input type="text" class="form-control input-sm" name="data[template]" size="30" maxlength="255" value="{$body.data.template}">
            </div>
         </div>
      {else}
         <input type="hidden" name="data[template]" value="{$body.data.template}">
      {/if}

      {block 'sections-own-fields'}
      {/block}
   </div>
   <div id="flapBlocks" class="tab-pane fade boxFlex">
      {include "utils/blocks.tpl" identifiers=$cfg.Blocks.identifiers blocks=$body.data.blocks photos=$body.data.photos acn=$body.acn editLink=$body.sectionURL}

      {include "utils/blocksHistory.tpl"}
   </div>
   {if findModule('sections_lead')}
      <div id="flapLead" class="tab-pane fade boxFlex">
         <h1 class="h4 main-panel-title">{'sectionLead'|translate}</h1>
         <p>{'sectionLeadDescr'|translate}</p>
         <div class="form-group">
            <div class="col-md-2 control-label"><label>{'showLead'|translate}</label></div>
            <div class="col-md-10">
               <div class="radio pull-left">
                  <input type="radio" class="check" name="data[lead_figure]" value="Y" {$body.data.lead_figure|checked:"Y"} id="LF1"/>
                  <label for="LF1">{'yes'|translate:'choice'}</label>
               </div>
               <div class="radio pull-left">
                  <input type="radio" class="check" name="data[lead_figure]" value="N" {$body.data.lead_figure|checked:"N"} id="LF2"/>
                  <label for="LF2">{'no'|translate:'choice'}</label>
               </div>
            </div>
         </div>
         <div class="leadSettings">
            <div class="form-group">
               <div class="col-md-2 control-label"><label>Text na úvodu</label></div>
               <div class="col-md-10">
                  <textarea name="data[lead_text]" rows="9">{$body.data.lead_text}</textarea>
                  {insert_wysiwyg target="data[lead_text]"}
               </div>
            </div>
            <div class="form-group">
               <div class="col-md-2 control-label"><label>{'leadProducts'|translate}</label></div>
               <div class="col-md-10">
                  <div class="radio pull-left">
                     <input type="radio" class="check" name="data[lead_products_figure]" value="Y"
                            id="LP1" {$body.data.lead_products_figure|checked:"Y"} />
                     <label for="LP1">{'yes'|translate:'choice'}</label>
                  </div>
                  <div class="radio pull-left">
                     <input type="radio" class="check" name="data[lead_products_figure]" value="N"
                            id="LP2" {$body.data.lead_products_figure|checked:"N"} />
                     <label for="LP2">{'no'|translate:'choice'}</label>
                  </div>
               </div>
            </div>
            <div class="form-group">
               <div class="col-md-10 col-md-offset-2">
                  <div id="LP2o">
                     <div class="row">
                        <div class="col-md-4">
                           <div class="checkbox">
                              <input type="checkbox" name="data[lead_products_show][]" class="check" value="N"
                                     {if $body.data.lead_products|strstr:"N"}checked{/if} id="LP2o1"/>
                              <label for="LP2o1">{'statusNews'|translate}</label>
                           </div>
                        </div>
                        <div class="col-md-5">
                           <div class="checkbox">
                              <input type="checkbox" name="data[lead_products_show][]" value="D"
                                     {if $body.data.lead_products|strstr:"D"}checked{/if} id="LP2o2" class="check"/>
                              <label for="LP2o2">{'statusDiscount'|translate}</label>
                           </div>
                        </div>
                     </div>
                     <div class="row">
                        <div class="col-md-4">
                           <div class="checkbox">
                              <input type="checkbox" name="data[lead_products_show][]" value="A"
                                     {if $body.data.lead_products|strstr:"A"}checked{/if} id="LP2o3" class="check"/>
                              <label for="LP2o3">{'statusSoldout'|translate}</label>
                           </div>
                        </div>
                        <div class="col-md-7">
                           <div class="checkbox">
                              <input type="checkbox" name="data[lead_products_show][]" value="S"
                                     {if $body.data.lead_products|strstr:"S"}checked{/if} id="LP2o4" class="check"/>
                              <label for="LP2o4">{'statusBestseller'|translate}</label></div>
                        </div>
                     </div>
                  </div>
                  <script type="text/javascript">
                     $.dataField('lead_products_figure').on('click ifChecked', function (e) {
                        $('#LP2o').toggle($(this).val() == 'Y');
                     }).filter(':checked').click();
                  </script>
               </div>
            </div>
         </div>
         <script>
            $.dataField('lead_figure').on('click ifChecked', function (e) {
               $('.leadSettings').toggle($(this).val() == 'Y');
            }).filter(':checked').click();
         </script>
      </div>
   {/if}

   {if {find_module name="products_parameters"} && !{find_module name="components"}}
      <div id="flapSearch" class="tab-pane fade boxFlex">
         <p>{'sectionSearchDescr'|translate}</p>
         {block "sections-filter-own-fields"}{/block}

         <div class="row">
            {ifmodule PRODUCERS}
               <div class="col-xs-3">
                  <div class="wpj-form-group">
                     <div class="d-flex align-items-center">
                        {print_toggle name="producers_filter"}
                        <label>{'filterProd'|translate}</label>
                     </div>
                  </div>
               </div>
            {ifmodule INDEXED_FILTER}
               <div class="col-xs-3">
                  <div class="checkbox">
                     <input type="hidden" name="data[producers_indexing]" value="N"/>
                     <input type="checkbox" class="check" name="data[producers_indexing]" id="PRINDEX"
                            value="Y" {($body.data.producers_indexing == 'Y')|checked}>
                     <label for="PRINDEX">
                        {'Index'|translate:'filters'}
                        <a class="help-tip" data-toggle="tooltip"
                           title="Stránka bude přístupná i pro roboty (bez javascriptu). Zapínejte pouze u parametrů, které se často používají v organickém vyhledávání.">
                           <i class="bi bi-question-circle"></i>
                        </a>
                     </label>
                  </div>
               </div>
               <div class="col-xs-3">
                  <div class="checkbox">
                     <input type="hidden" name="data[producers_to_title]" value="N"/>
                     <input type="checkbox" class="check" name="data[producers_to_title]" id="PRTITLE"
                            value="Y" {($body.data.producers_to_title == 'Y')|checked}>
                     <label for="PRTITLE">
                        {'toTitle'|translate:'filters'}
                        <a class="help-tip" data-toggle="tooltip" title="Vytvoří se pěkná URL a název parametru se přidá do nadpisu sekce.">
                           <i class="bi bi-question-circle"></i>
                        </a>
                     </label>
                  </div>
               </div>
            {/ifmodule}
            {/ifmodule}
         </div>

         {ifmodule LABELS}
            <div class="row">
               <div class="col-xs-3">
                  <div class="wpj-form-group">
                     <div class="d-flex align-items-center">
                        {print_toggle name="labels_filter"}
                        <label>{'filterLabels'|translate}</label>
                     </div>
                  </div>
               </div>
            </div>
         {/ifmodule}

         <div class="wpj-panel wpj-panel-default">
            <div class="wpj-panel-heading">
               <div class="row">
                  <div class="col-xs-1">
                  </div>
                  <div class="col-xs-2">
                     <small>{'filterParamName'|translate}</small>
                  </div>
                  <div class="col-xs-2">
                     <small>{'filterEnable'|translate}</small>
                  </div>
               </div>
            </div>

            <div class="wpj-list-group" id="sorter">
               {foreach from=$body.parameters item=parameter key=key}
                  <div class="wpj-list-group-item">
                     <div class="row">
                        <div class="col-xs-1">
                           <input type="hidden" name="data[param][{$parameter.id}][weight]" value="{$parameter.weight|default:{$parameter@index}}"
                                  data-sort=""/>
                           <span class="drag-drop-mover">
                              <i class="bi bi-arrows-move handle"></i>
                           </span>
                        </div>
                        <div class="col-xs-2">
                           <strong>
                              {$parameter.name}
                              {$unit = $parameter.unit|replace:'|':', '}
                              {if $unit != ""}
                                 [{$unit}]
                              {/if}
                           </strong>
                        </div>
                        <div class="col-xs-2">
                           {if $parameter.checked}
                              {$value = 'Y'}
                           {else}
                              {$value = 'N'}
                           {/if}
                           {print_toggle nameRaw="data[param][`$key`][use]" value=$value}
                        </div>
                        {ifmodule INDEXED_FILTER}
                           <div class="col-xs-2">
                              <div class="checkbox">
                                 <input type="hidden" name="data[param][{$parameter.id}][index]" value="N">
                                 <input type="checkbox" class="check" name="data[param][{$parameter.id}][index]" id="PRMINDEX{$parameter.id}"
                                        value="Y" {$parameter.index_checked|checked} />
                                 <label for="PRMINDEX{$parameter.id}">
                                    {'Index'|translate:'filters'}
                                 </label>
                              </div>
                           </div>
                           <div class="col-xs-2">
                              <div class="checkbox">
                                 <input type="hidden" name="data[param][{$parameter.id}][to_title]" value="N">
                                 <input type="checkbox" class="check" name="data[param][{$parameter.id}][to_title]" id="PRMTITLE{$parameter.id}"
                                        value="Y" {$parameter.toTitle_checked|checked} />
                                 <label for="PRMTITLE{$parameter.id}">
                                    {'toTitle'|translate:'filters'}
                                 </label>
                              </div>
                           </div>
                        {/ifmodule}
                     </div>
                  </div>
               {/foreach}
            </div>
         </div>

         {if {find_module name="products_variations"}}
            <div class="wpj-panel wpj-panel-default m-t-3">
               <div class="wpj-panel-heading">
                  <div class="row">
                     <div class="col-xs-1">
                     </div>
                     <div class="col-xs-2">
                        <small>{'filterVariationName'|translate}</small>
                     </div>
                     <div class="col-xs-2">
                        <small>{'filterEnable'|translate}</small>
                     </div>
                     {ifmodule INDEXED_FILTER}
                        <div class="col-xs-2"></div>
                        <div class="col-xs-2"></div>
                     {/ifmodule}
                     {ifmodule CONVERTORS}
                        <div class="col-xs-2">
                           <small>{'filterVariationConvertor'|translate}</small>
                        </div>
                     {/ifmodule}
                  </div>
               </div>
               <div class="wpj-list-group" id="sort-labels">
                  {foreach from=$body.variants item=variant key=key}
                     <div class="wpj-list-group-item">
                        <div class="row">
                           <div class="col-xs-1">
                              <input type="hidden" name="data[variants][{$variant.id}][weight]" value="{$variant.weight|default:{$variant@index}}"
                                     data-sort=""/>
                              <span class="drag-drop-mover">
                                 <i class="bi bi-arrows-move handle"></i>
                              </span>
                           </div>
                           <div class="col-xs-2">
                              <strong>{$variant.label}</strong>
                           </div>
                           <div class="col-xs-2">
                              <div class="checkbox">
                                 <input type="checkbox" class="check" name="data[variants][{$variant.id}][use]" id="VAR{$variant.id}"
                                        value="ON" {$variant.checked|checked} />
                                 <label for="VAR{$variant.id}"></label>

                                 {* todo toggle *}
                                 {*{print_toggle nameRaw="{"data[variants][{$key}][use]"}" onOff=1 value={$variant.checked|default:0}}*}
                              </div>
                           </div>
                           {ifmodule INDEXED_FILTER}
                              <div class="col-xs-2">
                                 <div class="checkbox">
                                    <input type="hidden" name="data[variants][{$variant.id}][index]" value="N">
                                    <input type="checkbox" class="check" name="data[variants][{$variant.id}][index]" id="VARINDEX{$variant.id}"
                                           value="Y" {$variant.index_checked|checked} />
                                    <label for="VARINDEX{$variant.id}">
                                       {'Index'|translate:'filters'}
                                    </label>
                                 </div>
                              </div>
                              <div class="col-xs-2">
                                 <div class="checkbox">
                                    <input type="hidden" name="data[variants][{$variant.id}][to_title]" value="N">
                                    <input type="checkbox" class="check" name="data[variants][{$variant.id}][to_title]" id="VARTITLE{$variant.id}"
                                           value="Y" {$variant.toTitle_checked|checked} />
                                    <label for="VARTITLE{$variant.id}">
                                       {'toTitle'|translate:'filters'}
                                    </label>
                                 </div>
                              </div>
                           {/ifmodule}
                           {ifmodule CONVERTORS}
                              <div class="col-xs-2">
                                 <select class="selecter" name="data[variants][{$variant.id}][convertor]" data-type="convertor"
                                         data-preload="Convertors"
                                         data-filter-type="autocomplete" data-autocomplete="Convertors" data-autocomplete-params="allow_empty=1">
                                    {if $variant.convertor}
                                       <option value="{$variant.convertor}" selected>{$variant.convertor}</option>
                                    {/if}
                                 </select>
                              </div>
                           {/ifmodule}
                        </div>
                     </div>
                  {/foreach}
               </div>
            </div>
         {/if}
      </div>
      <script type="text/javascript">
         sort_section('#sort-labels');
         sort_section('#sorter');

         function sort_section(name) {
            $(name).sortable({
               helper: function (e, row) {
                  var $row = $(row);
                  var $helper = $row.clone().addClass('drag-drop');
                  return $helper[0];
               },
               stop: function (event, ui) {
                  $(this).children().each(function (index, item) {
                     $(item).find('[data-sort]').val($(item).index()).change();
                  });
               },
               handle: '.handle',
               placeholder: 'placeholder',
            });
         }
      </script>
   {/if} {* ifmodule PRODUCTS_PARAMETERS *}

   <div id="flapSeo" class="tab-pane fade boxFlex">
      <div class="row">
         <div class="col-xs-12">
            <div class="wpj-main-panel-title">
               <h4>{'flapSeo'|translate:'seo'}</h4>
            </div>
         </div>
      </div>
      <div class="row">
         <div class="col-xs-8">
            <div class="wpj-form-group">
               <label>{'meta_title'|translate:'seo'}</label>
               <input type="text" class="form-control input-sm" name="data[meta_title]" size="30" maxlength="70"
                      value="{$body.data.meta_title}"
                      onchange="$('input[name*=meta_title_changed]').val('1')"/>
               <span class="help-block">{'maxLength70'|translate:'seo'} <span class="charCounter" rel="data[meta_title]"></span></span>
               <input type="hidden" name="data[meta_title_changed]" value="{$body.data.meta_title_changed}">
            </div>
         </div>
         {if findModule('products_sections', 'custom_url')}
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>{'section_url'|translate}</label>
                  <input type="text" class="form-control input-sm" name="data[url]" maxlength="255" size="30" value="{$body.data.url}"/>
               </div>
            </div>
         {/if}
         <div class="col-xs-12">
            <div class="wpj-form-group">
               <label>{'meta_description'|translate:'seo'}</label>
               {assign var="metaDescriptionLength" value=160}
               {if $body.data.meta_description|count_characters:true > 160}
                  {assign var="metaDescriptionLength" value=250}
               {/if}
               <textarea class="form-control input-sm" name="data[meta_description]" rows="3"
                         maxlength="{$metaDescriptionLength}">{$body.data.meta_description}</textarea>
               <span class="help-block">
                  {"maxLength$metaDescriptionLength"|translate:"seo"}
                  <span class="charCounter" rel="data[meta_description]"></span>
               </span>
            </div>
         </div>

         {block 'seo-own-fields'}{/block}
      </div>

      {ifmodule INDEXED_FILTER}
         <div class="row">
            <div class="col-xs-12">
               <div class="wpj-main-panel-title">
                  <h4>{'Filtering'|translate:'filters'}</h4>
               </div>
            </div>
         </div>
         <div class="row">
            <div class="col-xs-8">
               <div class="wpj-form-group">
                  <label>{'Title'|translate:'filters'}</label>
                  <input type="text" class="form-control input-sm" name="data[title]" size="30" maxlength="100" value="{$body.data.title}"/>
               </div>
            </div>
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>{'FilterURL'|translate:'filters'}</label>
                  <input type="text" class="form-control input-sm" name="data[filter_url]" size="30" maxlength="100"
                         value="{$body.data.filter_url}"/>
               </div>
            </div>
         </div>
      {/ifmodule}
   </div>
   {if findModule('feeds')}
      <div id="flapXML" class="tab-pane fade boxFlex">
         <div class="row">
            <div class="col-xs-12">
               <div class="wpj-main-panel-title">
                  <h4>{'flapXML'|translate}</h4>
               </div>
            </div>
         </div>
         <div class="row">
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>Heureka</label>
                  <select class="selecter selecter-categories" name="data[feed_heureka]" data-type="feed_heureka">
                     <option value="">Vyberte sekci</option>
                     <option value="{$body.data.feed_heureka}" selected>{$body.data.feed_heureka_text}</option>
                  </select>
               </div>
            </div>
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>Heureka SK</label>
                  <select class="selecter-categories" name="data[feed_heureka_sk]" data-type="feed_heureka_sk">
                     <option value="">Vyberte sekci</option>
                     <option value="{$body.data.feed_heureka_sk}" selected>{$body.data.feed_heureka_sk_text}</option>
                  </select>
               </div>
            </div>
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>Google</label>
                  <select class="selecter-categories" name="data[feed_google]" data-type="feed_google">
                     <option value="">Vyberte sekci</option>
                     <option value="{$body.data.feed_google}" selected>{$body.data.feed_google_text}</option>
                  </select>
               </div>
            </div>
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>Seznam</label>
                  <select class="selecter-categories" name="data[feed_seznam]" data-type="feed_seznam">
                     <option value="">Vyberte sekci</option>
                     <option value="{$body.data.feed_seznam}" selected>{$body.data.feed_seznam_text}</option>
                  </select>
               </div>
            </div>
            <div class="col-xs-4">
               <div class="wpj-form-group">
                  <label>Glami</label>
                  <select class="selecter-categories" name="data[feed_glami]" data-type="feed_glami">
                     <option value="">Vyberte sekci</option>
                     <option value="{$body.data.feed_glami}" selected>{$body.data.feed_glami_text}</option>
                  </select>
               </div>
            </div>
         </div>

         <script type="text/javascript">
            function applyChosen($selector, type) {
               $selector.ajaxChosen({
                  dataType: 'json',
                  type: 'GET',
                  keepTypingMsg: 'Zadejte více znaků...',
                  lookingForMsg: 'Hledání slova',
                  url: 'launch.php?s=autocomplete.php&type=' + $selector.data('type'),
               }, function (data) {
                  return data;
               }, {
                  width: '100%',
                  placeholder_text_single: 'Vyberte sekci',
                  placeholder_text_multiple: 'Vyberte několik možností',
               });
            }

            $('.selecter-categories[data-type]').each(function (index, el) {
               applyChosen($(el));
            });
         </script>
      </div>
   {/if}

   {if {find_module name="photos"}}
      <div id="flapPhotos" class="tab-pane fade boxFlex box iframe-box">
         {if $body.acn == "edit"}
            <iframe class='on-demand boxFlex' src="" data-src="launch.php?s=sections.photos.php&amp;ID={$body.data.id}"></iframe>
         {else}
            <div class="row">
               <div class="col-xs-12">
                  <div class="alert alert-warning">
                     {'saveToAddImg'|translate:'base'}
                  </div>
               </div>
            </div>
         {/if}
      </div>
   {/if}

   {if $body.acn =="edit"}
      <div id="flapProducts" class="tab-pane fade boxFlex box iframe-box">
         <iframe class='on-demand boxFlex' src="" data-src="launch.php?s=sections.products.php&amp;ID={$body.data.id}"></iframe>
      </div>
   {/if}
{/block}

{block buttonsRight append}
   <script>
      $('#buttonDelete').removeClass('confirm').click(function (e) {
         window.location = "launch.php?s=sections.php&acn=remove&ID={$body.data.id}";
         return false;
      });
   </script>
{/block}
