<script src="themes/clientbase/libs/fixedTable/fixedTable.js?{$revision}"></script>
<script type="text/javascript">
    var line = '{$smarty.get.line}';
</script>
<a name="view_subtables"></a>
{if $all_subtables[0].name_table and $line_id!="new" and $line_id!="array"}
    {if $config.fix_subtables_headers}
        <div class="fixed-subtable-header" style="display:none;" id="fixed_subtable_header">
            <header class="subtable__head--fixed">
                <ul class="subtable__tab-list">
                    {foreach from=$all_subtables item=one_subtable}
                        <li class="subtable__tab-item{if $one_subtable.id==$cur_subtable_id} fix-subtable__tab-item--active{/if} {if $one_subtable.all_values|count_cb}subtable_header{else}subtable_empty_header{/if}"
                                id="fix-tab_{$one_subtable.id}" table_id="{$one_subtable.table_id}">
                            {if $act_bp_step.action=='add_subtable'}
                                {if $one_subtable.id == $act_bp_step.subtable_id}
                                    <span style="font-size:15px;">
                                        <b>{$one_subtable.name_table}({$one_subtable.lines_count})</b>
                                    </span>
                                {else}
                                    <span style="font-size:14px;color: gray;">
                                        <b>{$one_subtable.name_table}({$one_subtable.lines_count})</b>
                                    </span>
                                {/if}

                            {else}
                                <button type="button" href="fields.php?table={$one_subtable.table_id}{$one_subtable.status_line}&rel_search&rel_table={$one_subtable.rel_table}&rel_line={$one_subtable.rel_line}&rel_field={$one_subtable.rel_field}{if $one_subtable.filter_id}&filter={$one_subtable.filter_id}{/if}"
                                    onclick="if (cur_subtable_id!={$one_subtable.id}) { switch_subtable({$one_subtable.id}, '', true); } else { scroll_to_subtables() } return false;">
                                        {if $lang.conf.{$one_subtable.name_table}}{$lang.conf.{$one_subtable.name_table}}({$one_subtable.lines_count}){else}{$one_subtable.name_table}&nbsp;({$one_subtable.lines_count}){/if}
                                </button>
                            {/if}
                        </li>
                    {/foreach}
                </ul>
                <div class="subtable__settings">
                    <a id="fix-subtable_to_table_link"
                        href="fields.php?table={$cur_subtable.table_id}{$cur_subtable.status_line}&rel_search&rel_table={$table_id}&rel_line={$line_id}&rel_field={$cur_subtable.rel_field}{if $cur_subtable.filter_id}&filter={$cur_subtable.filter_id}{/if}"
                        target="_blank" class="subtable__setting-btn subtable__setting-btn--humburger"></a>
                    {if ($user.group_id == 1 || $user.sub_admin_rights.tables.{$cur_subtable.table_id} == 2) and $user.developer_mode}
                        <a id="fix-setting_t"
                            href="{if $cur_subtable.url===0}edit_field.php?table={$cur_subtable.table_id}{else}{$cur_subtable.url}{/if}"
                            target="_blank"
                            class="subtable__setting-btn subtable__setting-btn--settings">
                        </a>
                    {/if}
                </div>
            </header>
        </div>
    {/if}
    <form
      autocomplete="off"
      onsubmit="return false;"
      class="form"
      id="subtables_form"
      {if $config['disable_full_edit'] && $recording_status == 'pre-created' && $table['auto_save'] != "1"}style="display:none;"{/if}
    >
        <div class="subtable__outer-wrap">
            <div class="subtable__border subtable__border-main"></div>
            <div class="subtable">
                <header class="subtable__head">
                    <ul class="subtable__tab-list">
                        {foreach from=$all_subtables item=one_subtable}
                            <li class="subtable__tab-item{if $one_subtable.id==$cur_subtable_id} subtable__tab-item--active{/if} {if $one_subtable.all_values|count_cb}subtable_header{else}subtable_empty_header{/if}"
                                 id="tab_{$one_subtable.id}" table_id="{$one_subtable.table_id}">
                                {if $act_bp_step.action=='add_subtable'}
                                    {if $one_subtable.id == $act_bp_step.subtable_id}
                                        <span style="font-size:15px;"><b>{$one_subtable.name_table}({$one_subtable.lines_count})</b></span>
                                    {else}
                                        <span style="font-size:14px;color: gray;"><b>{$one_subtable.name_table}({$one_subtable.lines_count})</b></span>
                                    {/if}

                                {else}
                                    <button type="button" href="fields.php?table={$one_subtable.table_id}{$one_subtable.status_line}&rel_search&rel_table={$one_subtable.rel_table}&rel_line={$one_subtable.rel_line}&rel_field={$one_subtable.rel_field}{if $one_subtable.filter_id}&filter={$one_subtable.filter_id}{/if}"
                                            onclick="if (cur_subtable_id!={$one_subtable.id}) switch_subtable({$one_subtable.id}); return false;">{if $lang.conf.{$one_subtable.name_table}}{$lang.conf.{$one_subtable.name_table}}({$one_subtable.lines_count}){else}{$one_subtable.name_table}&nbsp;(<span id="tab_count_{$one_subtable.id}">{$one_subtable.lines_count}</span>){/if}</button>
                                {/if}
                            </li>
                        {/foreach}
                    </ul>
                    <div class="subtable__settings">
                        <a id="subtable_to_table_link"
                           href="fields.php?table={$cur_subtable.table_id}{$cur_subtable.status_line}&rel_search&rel_table={$table_id}&rel_line={$line_id}&rel_field={$cur_subtable.rel_field}{if $cur_subtable.filter_id}&filter={$cur_subtable.filter_id}{/if}"
                           target="_blank" class="subtable__setting-btn subtable__setting-btn--humburger"></a>
                        {if $user.group_id eq 1 and $user.developer_mode}
                            <a id="setting_t"
                               href="{if $cur_subtable.url===0}edit_field.php?table={$cur_subtable.table_id}{else}{$cur_subtable.url}{/if}"
                               target="_blank"
                               class="subtable__setting-btn subtable__setting-btn--settings">
                            </a>
                        {/if}
                    </div>
                </header>
                <div class="preloader__block hidden">
                    <div class="preloader">
                        <div class="lds-css ng-scope">
                            <div style="width:100%;height:100%" class="lds-ellipsis">
                                <div>
                                    <div></div>
                                </div>
                                <div>
                                    <div></div>
                                </div>
                                <div>
                                    <div></div>
                                </div>
                                <div>
                                    <div></div>
                                </div>
                                <div>
                                    <div></div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
    </form>
{/if}
<script src="themes/clientbase/js/subtable.js?{$revision}"></script>
