<script type="text/javascript">
    $(function () {
        $("#navigation_cat").on("change", function (e) {
          let value = $(this).val();
          if (value)
              location.href = 'edit_tabrep.php?cat=' + value;
          else
              location.href = 'edit_cat.php';
        })
        $('#navigation_cat').chosen();

        $("#navigation_table").on("change", function (e) {
            let cat = $("#navigation_cat").val(),
              // в переменной table в значении отрезаю префикс
              table = ($("#navigation_table").val().slice(2)),
              selected_table = $("#navigation_table").find('option:selected'),
              table_type = selected_table.data('type'),
              param = '{$navigation_data.now_param}';

            if (!param && table_type == 'table') {
                location.href = 'edit_field.php?table=' + table;
            }
            else if (param && table_type == 'table') {
                switch (param) {
                {foreach from=$navigation_data.param_array item=param_data key=param_name}
                    case "{$param_name}":
                        location.href = '{$param_data.file_name}?table=' + table + '{$param_data.add_params}';
                        break;
                {/foreach}
                    case "{$lang.access}":
                        location.href = 'edit_group.php?group={$user.group_id}&cat=' + cat + '&cat_item=t' + table + '{$back_url_prm}';
                        break;
                }
            }
            else if (table_type == 'report') {
                location.href = 'edit_report.php?report=' + table;
            }
            else if (table_type == 'calendar') {
                location.href = 'edit_calendar.php?calendar=' + table;
            }
            else {
                location.href = 'edit_tabrep.php?cat=' + cat;
            }
        })
        $('#navigation_table').chosen();
    });
</script>

<div id="conf_navigation_wrapper">
    <div id="conf_navigation" class="search_bar" width="100%">
        <table>
            <tr class="conf_navigation_top_text">
                <td>&nbsp;</td>
                <td><b>{$lang.Category}</b></td>
                <td><b>{$lang.Table}</b></td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td width="20%" class="conf_navigation_img_cell">
                    <a href="edit_cat.php">
                        <img src="images/dom.png">
                    </a>
                </td>
                <td>
                  <span class="grey_next">
                    {if $cat_id}<a href="edit_tabrep.php?cat={$cat_id}">{/if}&gt;{if $cat_id}</a>{/if}
                  </span>

                  <select
                    class="form-control select-cat acc_sel_item{if $cat_id} conf_navigation_black_text{else} conf_navigation_gray_text{/if}"
                    name="navigation_cat"
                    id="navigation_cat"
                  >
                    <option class="conf_navigation_black_text" value="">- {$lang.All_categories} -</option>
                    {foreach from=$navigation_data.cats item=nav_cat key=nav_cat_id}
                      <option value="{$nav_cat_id}"{if $nav_cat_id==$cat_id} selected{/if}>{$nav_cat}</option>
                    {/foreach}
                  </select>

                  <span class="grey_next">
                    {if $table_id || $sel_table}<a
                              href="{$navigation_data.param_array[$navigation_data.now_param].file_name}?table={if $table_id}{$table_id}{else}{$sel_table}{/if}{$navigation_data.param_array[$navigation_data.now_param].add_params}">{/if}
                          &gt;
                          {if $table_id || $sel_table}</a>{/if}
                  </span>
                </td>

                <td>
                  <select
                    class="form-control select-cat acc_sel_item{if !$table_id && !$sel_table && !$calendar_id} conf_navigation_gray_text{else} conf_navigation_black_text{/if}"
                    name="navigation_table"
                    id="navigation_table"
                  >
                    <option class="conf_navigation_black_text" value="">- {$lang.All} -</option>
                    {if $navigation_data.tables|count_cb > 0}
                      <optgroup label="{$lang.Tables}">
                        {* добавил префикс t = table *}
                        {foreach from=$navigation_data.tables item=nav_table key=nav_table_id}
                          <option value="t_{$nav_table_id}"{if $nav_table_id==$table_id || $sel_table==$nav_table_id} selected{/if} data-type="table">{$nav_table}</option>
                        {/foreach}
                      </optgroup>
                    {/if}

                    {if $navigation_data.reports|count_cb > 0}
                      <optgroup label="{$lang.Reports}">
                        {* добавил префикс r = report *}
                        {foreach from=$navigation_data.reports item=nav_report key=nav_report_id}
                          <option value="r_{$nav_report_id}" data-type="report">{$nav_report}</option>
                        {/foreach}
                      </optgroup>
                    {/if}

                    {if $navigation_data.calendars|count_cb > 0}
                      <optgroup label="{$lang.Calendars}">
                        {* добавил префикс c = calendar *}
                        {foreach from=$navigation_data.calendars item=nav_calend key=nav_calend_id}
                          <option value="c_{$nav_calend_id}"{if $nav_calend_id==$calendar_id} selected{/if} data-type="calendar">{$nav_calend}</option>
                        {/foreach}
                      </optgroup>
                    {/if}
                  </select>
                </td>

                <td width="20%" class="conf_navigation_access_cell">
                  {if ($table_id || $sel_table) && ($user.group_id==1 || ($user.sub_admin_rights.access && $user.sub_admin_rights.set_rights.tables[$table_id] == 2))}
                    <span>
                      <a href="edit_group.php?group={$user.group_id}&cat={$cat_id}&cat_item=t{if $table_id}{$table_id}{else}{$sel_table}{/if}&menu={if $script_name=='edit_filter.php'}filters{elseif $script_name=='edit_tip.php'}tips{elseif $script_name=='forms.php'}templates{elseif $script_name=='edit_button.php'}buttons{elseif $script_name=='edit_subtable.php'}subtables{elseif $script_name=='edit_addittable.php'}addittables{else}common{/if}{if $mode}&type={$mode}{/if}{$back_url_prm}"
                        class="conf_navigation_href_top_menu">{$lang.Access}</a>
                    </span>
                  {/if}
                </td>
            </tr>
        </table>
    </div>
    {if $navigation_data.param_array|count_cb>0}
    <div id="conf_navigation_param" class="search_bar">
        <table>
            <tbody>
            <tr>
                <td align="center" colspan="4">
                    {foreach from=$navigation_data.param_array item=param_data key=param_name name=param_iter}
                        <span>{if $param_name!=$navigation_data.now_param}<a
                                    href="{$param_data.file_name}?table={if $table_id}{$table_id}{else}{$sel_table}{/if}{$param_data.add_params}"
                                    class="conf_navigation_href_top_menu">{else}
                                <b>{/if}{$param_name|mb_ucfirst}{if $param_data.count}&nbsp;({$param_data.count}){/if}{if $param_name!=$navigation_data.now_param}</a>{else}</b>{/if}</span>
                        {if $smarty.foreach.param_iter.iteration == 8}<br/>{/if}
                    {/foreach}
                </td>
            </tr>
            </tbody>
        </table>
    </div>
</div>
{/if}
<br/>
