{include file="./index_top.tpl"}

{include file="./acc_top.tpl"}

{include file="./acc_condition.tpl"}

<script>
    var change_flag = {};
    function del_copy(rule_id) {
        var group_copy = $("select#copy_table_" + rule_id + " [value='" + rule_id + "']").attr('group');
        $("select#copy_table_" + rule_id + " [value='" + rule_id + "']").remove();
        if ($('#copy_table_' + rule_id + ' [value="' + group_copy + '"]').html() == '') $('#copy_table_' + rule_id + ' [value="' + group_copy + '"]').remove();
    }
    function mouseBlue(obj, val) {
        if (val == 1) $(obj).css('backgroundColor', '#C0DDF3');
        else $(obj).css('backgroundColor', 'transparent');
    }
    function set_val(obj_id) {
        {if $parent}par = 1;
        {else}par = 0;{/if}
        {if $rules_id>0}rid = 1;
        {else}rid = 0;{/if}

        if ($('#' + obj_id).val() == 0 && par) {
            $('#' + obj_id).css('display', 'none');
            $('#par_' + obj_id).css('display', '');
            if ($('#par_' + obj_id).attr('o_value') == 2) {
                $('#' + obj_id).val('2');
                $('#par_' + obj_id).attr('src', 'images/check_dis_on_m.png');
                $('#bor_' + obj_id).css('display', 'none');
            }
            if ($('#par_' + obj_id).attr('o_value') == 3) {
                $('#' + obj_id).val('3');
                $('#par_' + obj_id).attr('src', 'images/check_dis_off_m.png');
                $('#bor_' + obj_id).css('display', 'none');
            }
        }
        else if ($('#' + obj_id).val() == 2 || $('#' + obj_id).val() == 3 || $('#' + obj_id).val() == 0) {
            $('#' + obj_id).val('1');
            if ($('#par_' + obj_id).attr('src') == 'images/radio_on_m.png' || $('#par_' + obj_id).attr('src') == 'images/radio_off_m.png') $('#par_' + obj_id).attr('src', 'images/radio_on_m.png');
            else $('#par_' + obj_id).attr('src', 'images/check_on_m.png');
            $('#bor_' + obj_id).css('display', '');
        }
        else {
            $('#' + obj_id).val('0');
            if ($('#par_' + obj_id).attr('src') == 'images/radio_on_m.png' || $('#par_' + obj_id).attr('src') == 'images/radio_off_m.png') $('#par_' + obj_id).attr('src', 'images/radio_off_m.png');
            else $('#par_' + obj_id).attr('src', 'images/check_off_m.png');
            $('#bor_' + obj_id).css('display', '');
        }
        if ($('#' + obj_id).val() != $('#' + obj_id).attr('o_value')) {
            change_flag[obj_id] = 1;
            $('#yellow_' + obj_id).css('backgroundColor', 'rgb(255, 255, 153)');
        }
        else {
            change_flag[obj_id] = 0;
            $('#yellow_' + obj_id).css('backgroundColor', 'transparent');
        }

        if (rid && $('#' + obj_id).attr('o_set')) {
            if ($('#' + obj_id).val() != $('#' + obj_id).attr('o_set')) {
                $('#yellow_' + obj_id).css('backgroundColor', 'rgb(255, 255, 153)');
            }
            else {
                $('#yellow_' + obj_id).css('backgroundColor', 'transparent');
            }
        }

        set_name($('#' + obj_id));
    }
    function set_name(obj)
    {
        if (obj.attr('data-name') != '') {
            if (obj.val() != obj.attr('data-value'))
                obj.attr('name', obj.attr('data-name'));
            else
                obj.attr('name', '');
        }
    }
    function check_all(type, obj) {
        {if $parent}par = 1;
        {else}par = 0;{/if}

        if ($(obj).attr("o_value") == "2") {
            $(obj).attr("src", "images/check_on_m.png");
            $(obj).attr("o_value", "1");
            on_off = "on";
        }
        else if ($(obj).attr("o_value") == "1") {
            $(obj).attr("src", "images/check_off_m.png");
            $(obj).attr("o_value", "0");
            on_off = "off";
        }
        else if (par) {
            $(obj).attr("src", "images/check_dis_off_m.png");
            $(obj).attr("o_value", "2");
            on_off = "dis_on";
        }
        else {
            $(obj).attr("src", "images/check_on_m.png");
            $(obj).attr("o_value", "1");
            on_off = "on";
        }

        $('[id^="par_' + type + '_"]').each(function () {
            $(this).attr("src", "images/check_" + on_off + "_m.png");
            if ($(this).attr("o_value") == 3 && on_off == "dis_on") {
                $(this).attr("src", "images/check_dis_off_m.png");
            }
        });

        $('[id^="bor_' + type + '_"]').each(function () {
            if (on_off == "dis_on") $(this).css('display', 'none');
            else  $(this).css('display', '');
        });

        $('[id^="' + type + '_"]').each(function () {
            if (on_off == 'on') $(this).val('1');
            else if (on_off == 'dis_on') {
                if ($('#par_' + this.id).attr('o_value') == '2') $(this).val('2');
                if ($('#par_' + this.id).attr('o_value') == '3') $(this).val('3');
            }
            else $(this).val('0');

            if ($(this).val() != $(this).attr('o_value')) {
                change_flag[obj] = 1;
                $('#yellow_' + this.id).css('backgroundColor', 'rgb(255, 255, 153)');
            }
            else {
                change_flag[obj] = 0;
                $('#yellow_' + this.id).css('backgroundColor', 'transparent');
            }
            set_name($(this));
        });
    }

    function checkGroup(obj) {
        let set_value

        if (!obj.hasAttribute('value')) {
            obj.setAttribute('value', '0')
        }

        if (obj.value == 0) {
            set_value = 2
            obj.value = 2
        } else if (obj.value == 1) {
            obj.value = 0
            set_value = 0
        } else if (obj.value == 2) {
            set_value = 1
            obj.value = 1
        }

        let group_row = obj.closest('.acc-group-row')
        let access_check_cell = obj.closest('td')
        let row_index = $(group_row).index()
        let cell_index = $(access_check_cell).index()
        let all_rows = $(group_row.parentNode).children('tr')

        let stopIteration = false
        let next_field_rows = []
        for (let i = row_index + 1; stopIteration == false; i++) {
            if (all_rows[i]) {
              if (all_rows[i].classList.contains('acc-field-row')) {
                next_field_rows.push(all_rows[i])
              } else if (all_rows[i].classList.contains('acc-group-row')) {
                  stopIteration = true
              } else if (!all_rows[i]) {
                  stopIteration = true
              } else if (!all_rows[i].classList.contains('acc-field-row') && !all_rows[i].classList.contains('acc-group-row')) {
                  stopIteration = true
              }
            } else {
              stopIteration = true
            }

        }
        next_field_rows.forEach( (row) => {

            let cell = $(row).children().eq(cell_index)[0]
            let checkboxDiv = cell.querySelector('img[onclick]')

            if (set_value == 1) {
                if ($(checkboxDiv).siblings('[value]').val() == 2 || $(checkboxDiv).siblings('[value]').val() == 3) {
                    checkboxDiv.click()
                }
            } else if (set_value == 0) {
                if ($(checkboxDiv).siblings('[value]').val() == 1) {
                    checkboxDiv.click()
                }
            } else if (set_value == 2) {
                if ($(checkboxDiv).siblings('[value]').val() == 0) {
                    checkboxDiv.click()
                }
            }
        })

        if (set_value == 2) {
            set_value = 1
        } else if (set_value == 1) {
            set_value = 0
        } else if (set_value == 0) {
            set_value = 2
        }
    }
    function show_add() {
        if ($('#tr_add').css('display') == 'none')
            $('#tr_add').css('display', '');
        else $('#tr_add').css('display', 'none');
    }
    function set_val_table(obj_id) {
        if ($('#' + obj_id).val() == 0) {
            $('#' + obj_id).val(1);
            $('#par_' + obj_id).attr('src', 'images/check_on_m.png');
            $('#bor_tab_' + obj_id).css('display', '');
        }
        else if ($('#' + obj_id).val() == 1) {
            if ($('#' + obj_id).attr('o_value') == 2) {
                $('#' + obj_id).val(2);
                $('#par_' + obj_id).attr('src', 'images/check_dis_on_m.png');
                $('#bor_tab_' + obj_id).css('display', 'none');
            }
            else {
                $('#' + obj_id).val(3);
                $('#par_' + obj_id).attr('src', 'images/check_dis_off_m.png');
                $('#bor_tab_' + obj_id).css('display', 'none');
            }
        }
        else if ($('#' + obj_id).val() == 2 || $('#' + obj_id).val() == 3) {
            $('#' + obj_id).val(0);
            $('#par_' + obj_id).attr('src', 'images/check_off_m.png');
            $('#bor_tab_' + obj_id).css('display', '');
        }

        if ($('#' + obj_id).val() != $('#' + obj_id).attr('o_set')) {
            change_flag[obj_id] = 1;
            $('#yellow_' + obj_id).css('backgroundColor', 'rgb(255, 255, 153)');
        }
        else if ($('#' + obj_id).val() != 1 && $('#' + obj_id).val() != 2) {
            change_flag[obj_id] = 0;
            $('#yellow_' + obj_id).css('backgroundColor', '#F9F9F9');
        }
        else {
            change_flag[obj_id] = 0;
            $('#yellow_' + obj_id).css('backgroundColor', '#EBF9D3');
        }
    }
    $(function () {
        $("a").click(function (event) {
            var a_href = this;
            for (var temp_flag in change_flag) {
                if (change_flag[temp_flag] == 1 && $(a_href).attr("id") !== "goto") {
                    jconfirm('{$lang.lost_page}', function () {
                        location.href = a_href;
                    }, function () {
                    });
                    event.preventDefault();
                    break;
                }
            }
        });
    });

    let ajaxObj = new XMLHTTP("edit_group.php");
    ajaxObj.format = 0;
    ajaxObj.method = "POST";
    function switchOnObjectRules(rule_id) {
        $('#switch-on-btn_'+rule_id).toggleClass('switch-on');
        $('#switch-on-btn_'+rule_id).trigger('on.switch');
        ajaxObj.call('group={$group_id}&cat_item=t{$table_id}&menu=rules&save=rules&rules_id='+rule_id+'&disable='+($('#switch-on-btn_'+rule_id).hasClass('switch-on')?0:1)+'&csrf={$csrf}',()=>{});
    }

    function checkInput() {
    var input = document.getElementById('nameInput');
    if (input.value.trim() === '') {
        input.value = input.getAttribute('value');
    }
    return true;
    }
</script>
{if $rules_list==1}
    <p style="font-size:14px;">
        {if $archive}<a style="font-size:14px;" href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules">{/if}
            {$lang.active}
        {if $archive}</a>{/if}
        /
        {if !$archive}
            {if $has_archive}
                <a style="font-size:14px;" href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&archive">
            {else}
                <span style="color:gray" title="{$lang.Empty_archive}">
            {/if}
        {/if}
            {$lang.archive}
        {if !$archive}{if $has_archive}</a>{else}</span>{/if}{/if}
    </p>
    <form action="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules" method="post">
        <table {if !$archive}class='sortableTable'{/if}>
            {foreach from=$all_rules item=one_rule}
                {if $config.display_protected_elements || $one_rule.blocked != 2}
                <tr>
                    {if !$archive}
                        <td><span class="draggableImg">&nbsp;</span></td>
                        <td>
                            {if !$one_rule.blocked}
                            <a class='href_post'
                                href="edit_group.php?group={$one_rule.group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&save=rules&rules_id={$one_rule.id}&archive{if $back_url}&back_url={$base64_current_url}{/if}"><img
                                alt="{$lang.into_archive}" title="{$lang.send_in_archive}"
                                src="images/b_archive.png" border=0></a>
                            {/if}
                        </td>
                    {else}
                        <td>
                            {if !$one_rule.blocked}
                            <a class='href_post'
                                href="edit_group.php?group={$one_rule.group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&save=rules&rules_id={$one_rule.id}&restore{if $back_url}&back_url={$base64_current_url}{/if}"><img
                                alt="{$lang.restore}" title="{$lang.restore_from_archive}"
                                src="images/b_restore.png" border=0></a>
                            {/if}
                        </td>
                    {/if}
                    <td>
                        {if !$one_rule.blocked}
                        <a class='href_post'
                           href="edit_group.php?group={$one_rule.group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&save=rules&rules_id={$one_rule.id}&delete{if $back_url}&back_url={$base64_current_url}{/if}"
                           onClick="return href_post=jconfirm('{if $one_rule.global}{$lang.alert_global_rule}{else}{$lang.alert_delete_rule}{/if}', this);">
                            <img alt="{$lang.delete}" title="{$lang.Delete_rule}" src="images/b_drop.png" border=0>
                        </a>
                        {/if}
                    </td>
                    {if !$archive}
                        <td>
                            {if $one_rule.blocked != 2}
                            <a class='href_post'
                               href="edit_group.php?group={$one_rule.group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&save=rules&rules_id={$one_rule.id}{if $back_url}&back_url={$base64_current_url}{/if}"
                               onClick="if (copy_name=prompt('{$lang.Copy_as}','{$one_rule.name} {$lang['(copy)']}')) {ldelim}this.href=this.href+'&copy='+copy_name; href_post=true;{rdelim} else href_post=false;">
                                <img alt="{$lang.copy}" title="{$lang.Copy_rule}" src="images/b_copy.png" border=0>
                            </a>
                            {/if}
                        </td>
                        <td>
                            {if !$one_rule.blocked}
                            <div style="left: 0; top: 2px; margin: 0 5px;"
                                onclick="switchOnObjectRules('{$one_rule.id}')"
                                class="switch-btn {if !$one_rule.disabled}switch-on{/if}"
                                id="switch-on-btn_{$one_rule.id}"><div></div></div>
                            {/if}
                        </td>
                        <td>
                            <input class="acc_rules__rules-num" type=text size=1 name=num[{$one_rule.id}] value={$one_rule.num}>
                            {if $one_rule.global}<input type=hidden size=1 name=global[{$one_rule.id}] value=1>{/if}
                        </td>
                    {/if}
                    <td>
                        {if $one_rule.blocked != 2}
                            <a href="edit_group.php?group={$one_rule.group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&rules_id={$one_rule.id}{if $back_url}&back_url={$smarty.get.back_url}{/if}{if $one_rule.global}&to_back={$group_id}{/if}"
                               {if $one_rule.blocked}class="gray_link"{/if}>
                                <b>{$one_rule.name}</b>
                            </a>
                        {else}
                            <b style="color:gray;">{$one_rule.name}</b>
                        {/if}
                    </td>
                    <td>
                        {if $one_rule.protected}<img src="images/lock.svg" style="padding-left:10px;width:13px" title="{$one_tip.protect_comment}">{/if}
                    </td>
                    <td>
                        {if $one_rule.global}<div style="padding-left:10px;width:16px;font-style:italic;color:gray;">{$lang.rule_global}<div>{/if}
                    </td>
                </tr>
                {/if}
            {/foreach}
            {if !$archive}
                {foreach from=$subtables_rules item=one_rule}
                    {if $config.display_protected_elements || $one_rule.blocked != 2}
                    <tr>
                        <td colspan=6></td>
                        <td>
                            {if $one_rule.blocked != 2}
                                <a href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&subtable_id={$one_rule.id}{if $back_url}&back_url={$smarty.get.back_url}{/if}"
                                   {if $one_rule.blocked}class="gray_link"{/if}>
                                    <b>{$one_rule.name}</b>
                                </a>
                            {else}
                                <b style="color:gray;">{$one_rule.name}</b>
                            {/if}
                        </td>
                        <td>
                            {if $one_rule.protected}<img src="images/lock.svg" style="padding-left:10px;width:13px" title="{$one_tip.protect_comment}">{/if}
                        </td>
                        <td>
                            <div style="padding: 5px 10px; font-style:italic; color:gray;">{$lang.subtable}<div>
                        </td>
                    </tr>
                    {/if}
                {/foreach}
            {/if}
            {if !$all_rules && !$subtables_rules}
                <tr>
                    <td>{$lang.No_rules}</td>
                </tr>
            {/if}
        </table>
        <br>
        <input type=hidden name=csrf value={$csrf}>
        <input type=hidden name=back_url value='{$base64_back_url}'>
        {if !$archive}<input class="btn btn-default btn-sm" type=button value="{$lang.Add_rule}"
               onClick="location.href='edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules&rules_id=-1{if $back_url}&back_url={$smarty.get.back_url}{/if}';">{/if}
    </form>
    <br>
    <a href="edit_group.php?group={$group_id}&cat={$cat_id}">{$lang.return_to_tables}</a>
    <br/>
    <br/>
{elseif $rules_list==2}
    <form action="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item={$cat_item}" method="post">

        {include file="./acc_menu.tpl"}
        <table border=0 cellpadding=0 align="center" width="800px" style="border-collapse:collapse">
            <tr>
                <td id="tr_add" align="left" colspan="4">
                    <table>
                        <tr>
                            <td align="right">{$lang.Name}:</td>
                            <td>
                                <input class="form-control form-control-160" name="add_name" value="{$add_name}"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">{$lang.Rule_global}:</td>
                            <td>
                                <input type="checkbox" name="global"/>
                            </td>
                        </tr>
                        <tr>
                            <td align="right">{$lang.Help}:</td>
                            <td><textarea class="form-control" name="help" rows="5" cols="38">{$help}</textarea></td>
                        </tr>
                        <tr>
                            <td align="right" valign="top" style="padding-top:4px">{$lang.Conditions}:</td>
                            <td id="wizard_set999" nowrap></td>
                        </tr>
                        <tr>
                            <td colspan="2"><br/></td>
                        </tr>
                    </table>

                    <table border=0 cellpadding=0 align="center" width="800px" style="border-collapse:collapse">
                        <tr>
                            {foreach from=$table_acc item=one_acc key=acc_key}
                                <td id="yellow_{$acc_key}" align="left"
                                    style="padding:8px 8px 8px 11px;background-color:{if $one_acc.blocked}#f3f3f3{elseif $one_acc.val==2 || $one_acc.val==1}#EBF9D3{else}#F9F9F9{/if}"
                                    o_bg="{if $one_acc.val==2 || $one_acc.val==1}#EBF9D3{else}#F9F9F9{/if}">
                                    <div>
                                        <input id="{$acc_key}" type="hidden" name="{$acc_key}"
                                               {if $one_acc.val}checked{/if} value="{$one_acc.val}"
                                               o_value='{$one_acc.val}'/>
                                        <div id="bor_tab_{$acc_key}" onclick="set_val_table('{$acc_key}')"
                                             style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin-top:1px;"></div>
                                        <img style="float:left;margin-top:1px;margin-right:6px" id="par_{$acc_key}"
                                             src="images/check_{if $one_acc.val==2}dis_on{elseif $one_acc.val==3}dis_off{elseif $one_acc.val}on{else}off{/if}_m.png"
                                             {if !$one_acc.blocked}onclick="set_val_table('{$acc_key}')"{/if}> {$one_acc.name}
                                    </div>
                                </td>
                                <td style="width:5px"></td>
                            {/foreach}
                        </tr>
                    </table>

                    <table border=0 cellpadding=0 align="center" width="800px" style="border-collapse:collapse">
                        <tr>
                            <td colspan="6"><br/></td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" style="border-bottom:1px solid #BBBBBB" width="227px">
                                <span style="color:gray">{$lang.Mode}:</span> {if $expert_mode}<a
                                    href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu={if $fields}common{else}rules{/if}{if $res_rule}&rules_id={$res_rule}{elseif $rules_id}&rules_id={$rules_id}{/if}&expert=2">{$lang.Simple}</a>{else}{$lang.Simple}{/if}
                                / {if !$expert_mode}<a
                                    href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu={if $fields}common{else}rules{/if}{if $res_rule}&rules_id={$res_rule}{elseif $rules_id}&rules_id={$rules_id}{/if}&expert=1">{$lang.Experts}</a>{else}{$lang.Experts}{/if}
                            </td>
                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {$lang.Table}<br/>
                                <img style="margin-top:4px" id="all_read" src="images/check_off_m.png"
                                     onclick="check_all('read', this)" o_value="{if $parent}2{else}0{/if}">
                            </td>
                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {$lang.View}<br/>
                                <img style="margin-top:4px" id="all_view" src="images/check_off_m.png"
                                     onclick="check_all('view', this)" o_value="{if $parent}2{else}0{/if}">
                            </td>
                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {$lang.Edit2}<br/>
                                <img style="margin-top:4px" id="all_write" src="images/check_off_m.png"
                                     onclick="check_all('write', this)" o_value="{if $parent}2{else}0{/if}">
                            </td>

                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {if $expert_mode}
                                    {$lang.Add2}
                                    <br/>
                                    <img style="margin-top:4px" id="all_exp_add_acc" src="images/check_off_m.png"
                                         onclick="check_all('exp_add_acc', this)" o_value="{if $parent}2{else}0{/if}">
                                {/if}
                            </td>
                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {if $expert_mode}
                                    {$lang.Subtable}
                                    <br/>
                                    <img style="margin-top:4px" id="all_exp_add_acc" src="images/check_off_m.png"
                                         onclick="check_all('exp_sub_acc', this)" o_value="{if $parent}2{else}0{/if}">
                                {/if}
                            </td>
                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {if $expert_mode}
                                    {$lang.Export}
                                    <br/>
                                    <img style="margin-top:4px" id="all_exp_read_acc" src="images/check_off_m.png"
                                         onclick="check_all('exp_read_acc', this)" o_value="{if $parent}2{else}0{/if}">
                                {/if}
                            </td>
                            <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                                {if $expert_mode}
                                    {$lang.Import}
                                    <br/>
                                    <img style="margin-top:4px" id="all_exp_write_acc" src="images/check_off_m.png"
                                         onclick="check_all('exp_write_acc', this)" o_value="{if $parent}2{else}0{/if}">
                                {/if}
                            </td>

                        </tr>
                        {foreach from=$rules_fields item=one_rule_field}
                            <tr class="{if $one_rule_field.name_field}acc-field-row{else}acc-group-row{/if}" onmouseover="mouseBlue(this,1);" onmouseout="mouseBlue(this,0);">
                                {if $one_rule_field.name_field}
                                    <td align="left" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        {$one_rule_field.name_field}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        <div id="yellow_read_{$one_rule_field.id}"
                                            style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.tab_acc_blocked}background-color:#f3f3f3;{/if}">
                                            <input id="read_{$one_rule_field.id}" type="hidden" name=""
                                                data-name='fields[{$one_rule_field.id}][read]'
                                                data-value='{$one_rule_field.read_acc}'
                                                {if $one_rule_field.read_acc}checked{/if}
                                                value="{$one_rule_field.read_acc}"
                                                o_value='{$one_rule_field.read_acc}'/>
                                            <div id="bor_read_{$one_rule_field.id}"
                                                onclick="set_val('read_{$one_rule_field.id}')"
                                                style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>
                                            <img id="par_read_{$one_rule_field.id}"
                                                src="images/check_{if $one_rule_field.read_acc==2}dis_on{elseif $one_rule_field.read_acc==3}dis_off{elseif $one_rule_field.read_acc}on{else}off{/if}_m.png"
                                                {if !$one_rule_field.blocked && !$one_rule_field.tab_acc_blocked}onclick="set_val('read_{$one_rule_field.id}')"{/if}
                                                o_value='{$one_rule_field.read_acc}'>
                                        </div>
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        <div id="yellow_view_{$one_rule_field.id}"
                                            style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.view_acc_blocked}background-color:#f3f3f3;{/if}">
                                            <input id="view_{$one_rule_field.id}" type="hidden" name=""
                                                data-name='fields[{$one_rule_field.id}][view]'
                                                data-value='{$one_rule_field.view_acc}'
                                                {if $one_rule_field.view_acc}checked{/if}
                                                value="{$one_rule_field.view_acc}"
                                                o_value='{$one_rule_field.view_acc}'/>
                                            <div id="bor_view_{$one_rule_field.id}"
                                                onclick="set_val('view_{$one_rule_field.id}')"
                                                style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>
                                            <img id="par_view_{$one_rule_field.id}"
                                                src="images/check_{if $one_rule_field.view_acc==2}dis_on{elseif $one_rule_field.view_acc==3}dis_off{elseif $one_rule_field.view_acc}on{else}off{/if}_m.png"
                                                {if !$one_rule_field.blocked && !$one_rule_field.view_acc_blocked}onclick="set_val('view_{$one_rule_field.id}')"{/if}
                                                o_value='{$one_rule_field.view_acc}'>
                                        </div>
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        <div id="yellow_write_{$one_rule_field.id}"
                                            style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.edit_acc_blocked}background-color:#f3f3f3;{/if}">
                                            {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}<input id="write_{$one_rule_field.id}" type="hidden" name=""
                                                data-name='fields[{$one_rule_field.id}][write]'
                                                data-value='{$one_rule_field.write_acc}'
                                                {if $one_rule_field.write_acc}checked{/if}
                                                value="{$one_rule_field.write_acc}"
                                                o_value='{$one_rule_field.write_acc}'/>
                                            <div id="bor_write_{$one_rule_field.id}"
                                                onclick="set_val('write_{$one_rule_field.id}')"
                                                style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>{/if}
                                            <img {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}id="par_write_{$one_rule_field.id}"{/if}
                                                src="images/check_{if $one_rule_field.write_acc==2}dis_on{elseif $one_rule_field.write_acc==3}dis_off{elseif $one_rule_field.write_acc}on{else}off{/if}_m.png"
                                                {if ($one_rule_field.type_field < 10 || $one_rule_field.type_field > 13) && !$one_rule_field.blocked && !$one_rule_field.edit_acc_blocked}onclick="set_val('write_{$one_rule_field.id}')"{/if}
                                                o_value='{$one_rule_field.write_acc}'>
                                        </div>
                                    </td>

                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        {if $expert_mode}
                                            <div id="yellow_exp_add_acc_{$one_rule_field.id}"
                                                style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.add_acc_blocked}background-color:#f3f3f3;{/if}">
                                                {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}<input id="exp_add_acc_{$one_rule_field.id}" type="hidden" name=""
                                                    data-name='fields[{$one_rule_field.id}][exp_add_acc]'
                                                    data-value='{$one_rule_field.exp_add_acc}'
                                                    {if $one_rule_field.exp_add_acc}checked{/if}
                                                    value="{$one_rule_field.exp_add_acc}"
                                                    o_value='{$one_rule_field.exp_add_acc}'/>
                                                <div id="bor_exp_add_{$one_rule_field.id}"
                                                    onclick="set_val('exp_add_{$one_rule_field.id}')"
                                                    style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>{/if}
                                                <img {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}id="par_exp_add_acc_{$one_rule_field.id}"{/if}
                                                    src="images/check_{if $one_rule_field.exp_add_acc==2}dis_on{elseif $one_rule_field.exp_add_acc==3}dis_off{elseif $one_rule_field.exp_add_acc}on{else}off{/if}_m.png"
                                                    {if ($one_rule_field.type_field < 10 || $one_rule_field.type_field > 13) && !$one_rule_field.blocked && !$one_rule_field.add_acc_blocked}onclick="set_val('exp_add_acc_{$one_rule_field.id}')"{/if}
                                                    o_value='{$one_rule_field.exp_add_acc}'>
                                            </div>
                                        {/if}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        {if $expert_mode}
                                            <div id="yellow_exp_sub_acc_{$one_rule_field.id}"
                                                style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.sub_acc_blocked}background-color:#f3f3f3;{/if}">
                                                <input id="exp_sub_acc_{$one_rule_field.id}" type="hidden" name=""
                                                    data-name='fields[{$one_rule_field.id}][exp_sub_acc]'
                                                    data-value='{$one_rule_field.exp_sub_acc}'
                                                    {if $one_rule_field.exp_sub_acc}checked{/if}
                                                    value="{$one_rule_field.exp_sub_acc}"
                                                    o_value='{$one_rule_field.exp_sub_acc}'/>
                                                <div id="bor_exp_sub_{$one_rule_field.id}"
                                                    onclick="set_val('exp_sub_{$one_rule_field.id}')"
                                                    style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>
                                                <img id="par_exp_sub_acc_{$one_rule_field.id}"
                                                    src="images/check_{if $one_rule_field.exp_sub_acc==2}dis_on{elseif $one_rule_field.exp_sub_acc==3}dis_off{elseif $one_rule_field.exp_sub_acc}on{else}off{/if}_m.png"
                                                    {if !$one_rule_field.blocked && !$one_rule_field.sub_acc_blocked}onclick="set_val('exp_sub_acc_{$one_rule_field.id}')"{/if}
                                                    o_value='{$one_rule_field.exp_sub_acc}'>
                                            </div>
                                        {/if}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        {if $expert_mode}
                                            <div id="yellow_exp_read_acc_{$one_rule_field.id}"
                                                style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.exp_acc_blocked}background-color:#f3f3f3;{/if}">
                                                <input id="exp_read_acc_{$one_rule_field.id}" type="hidden" name=""
                                                    data-name='fields[{$one_rule_field.id}][exp_read_acc]'
                                                    data-value='{$one_rule_field.exp_read_acc}'
                                                    {if $one_rule_field.exp_read_acc}checked{/if}
                                                    value="{$one_rule_field.exp_read_acc}"
                                                    o_value='{$one_rule_field.exp_read_acc}'/>
                                                <div id="bor_exp_read_{$one_rule_field.id}"
                                                    onclick="set_val('exp_read_{$one_rule_field.id}')"
                                                    style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>
                                                <img id="par_exp_read_acc_{$one_rule_field.id}"
                                                    src="images/check_{if $one_rule_field.exp_read_acc==2}dis_on{elseif $one_rule_field.exp_read_acc==3}dis_off{elseif $one_rule_field.exp_read_acc}on{else}off{/if}_m.png"
                                                    {if !$one_rule_field.blocked && !$one_rule_field.exp_acc_blocked}onclick="set_val('exp_read_acc_{$one_rule_field.id}')"{/if}
                                                    o_value='{$one_rule_field.exp_read_acc}'>
                                            </div>
                                        {/if}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                                        {if $expert_mode}
                                            <div id="yellow_exp_write_acc_{$one_rule_field.id}"
                                                style="width:31px;padding-top:8px;padding-bottom:6px;text-align:center;{if $one_rule_field.imp_acc_blocked}background-color:#f3f3f3;{/if}">
                                                <input id="exp_write_acc_{$one_rule_field.id}" type="hidden" name=""
                                                    data-name='fields[{$one_rule_field.id}][exp_write_acc]'
                                                    data-value='{$one_rule_field.exp_write_acc}'
                                                    {if $one_rule_field.exp_write_acc}checked{/if}
                                                    value="{$one_rule_field.exp_write_acc}"
                                                    o_value='{$one_rule_field.exp_write_acc}'/>
                                                <div id="bor_exp_write_{$one_rule_field.id}"
                                                    onclick="set_val('exp_write_{$one_rule_field.id}')"
                                                    style="display:none;border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:4px 0 0 9px"></div>
                                                <img id="par_exp_write_acc_{$one_rule_field.id}"
                                                    src="images/check_{if $one_rule_field.exp_write_acc==2}dis_on{elseif $one_rule_field.exp_write_acc==3}dis_off{elseif $one_rule_field.exp_write_acc}on{else}off{/if}_m.png"
                                                    {if !$one_rule_field.blocked && !$one_rule_field.imp_acc_blocked}onclick="set_val('exp_write_acc_{$one_rule_field.id}')"{/if}
                                                    o_value='{$one_rule_field.exp_write_acc}'>
                                            </div>
                                        {/if}
                                    </td>
                                {else}
                                    <td align="left" style="border-bottom:1px solid #BBBBBB">
                                        <div style="padding-top: 4px;padding-bottom: 6px;">
                                            <b>{$lang.Group}:</b>
                                            <a href="edit_fgroup.php?table={$one_rule_field.table_id}&group={$one_rule_field.id}">
                                                <b style="color:black">{$one_rule_field.group_name}</b>
                                            </a>
                                        </div>
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB;">

                                      <input type="checkbox" id="{$one_rule_field.id}_1" onclick="checkGroup(this)" class="fgroup-checkbox">

                                      <label for="{$one_rule_field.id}_1" class="label-for-fgroup-checkbox on">
                                          <img src="images/check_on_m.png"/>
                                      </label>
                                      <label for="{$one_rule_field.id}_1" class="label-for-fgroup-checkbox off">
                                          <img src="images/check_off_m.png"/>
                                      </label>
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB">
                                      <input type="checkbox" id="{$one_rule_field.id}_2" onclick="checkGroup(this)" class="fgroup-checkbox">

                                      <label for="{$one_rule_field.id}_2" class="label-for-fgroup-checkbox on">
                                          <img src="images/check_on_m.png"/>
                                      </label>
                                      <label for="{$one_rule_field.id}_2" class="label-for-fgroup-checkbox off">
                                          <img src="images/check_off_m.png"/>
                                      </label>
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB">
                                      <input type="checkbox" id="{$one_rule_field.id}_3" onclick="checkGroup(this)" class="fgroup-checkbox">

                                      <label for="{$one_rule_field.id}_3" class="label-for-fgroup-checkbox on">
                                          <img src="images/check_on_m.png"/>
                                      </label>
                                      <label for="{$one_rule_field.id}_3" class="label-for-fgroup-checkbox off">
                                          <img src="images/check_off_m.png"/>
                                      </label>
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB;">
                                      {if $expert_mode}
                                        <input type="checkbox" id="{$one_rule_field.id}_4" onclick="checkGroup(this)" class="fgroup-checkbox">

                                        <label for="{$one_rule_field.id}_4" class="label-for-fgroup-checkbox on">
                                            <img src="images/check_on_m.png"/>
                                        </label>
                                        <label for="{$one_rule_field.id}_4" class="label-for-fgroup-checkbox off">
                                            <img src="images/check_off_m.png"/>
                                        </label>
                                      {/if}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB;">
                                      {if $expert_mode}
                                        <input type="checkbox" id="{$one_rule_field.id}_5" onclick="checkGroup(this)" class="fgroup-checkbox">

                                        <label for="{$one_rule_field.id}_5" class="label-for-fgroup-checkbox on">
                                            <img src="images/check_on_m.png"/>
                                        </label>
                                        <label for="{$one_rule_field.id}_5" class="label-for-fgroup-checkbox off">
                                            <img src="images/check_off_m.png"/>
                                        </label>
                                      {/if}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB">
                                      {if $expert_mode}
                                        <input type="checkbox" id="{$one_rule_field.id}_6" onclick="checkGroup(this)" class="fgroup-checkbox">

                                        <label for="{$one_rule_field.id}_6" class="label-for-fgroup-checkbox on">
                                            <img src="images/check_on_m.png"/>
                                        </label>
                                        <label for="{$one_rule_field.id}_6" class="label-for-fgroup-checkbox off">
                                            <img src="images/check_off_m.png"/>
                                        </label>
                                      {/if}
                                    </td>
                                    <td align="center" style="border-bottom:1px solid #BBBBBB">
                                      {if $expert_mode}
                                        <input type="checkbox" id="{$one_rule_field.id}_7" onclick="checkGroup(this)" class="fgroup-checkbox">

                                        <label for="{$one_rule_field.id}_7" class="label-for-fgroup-checkbox on">
                                            <img src="images/check_on_m.png"/>
                                        </label>
                                        <label for="{$one_rule_field.id}_7" class="label-for-fgroup-checkbox off">
                                            <img src="images/check_off_m.png"/>
                                        </label>
                                      {/if}
                                    </td>
                                {/if}
                            </tr>
                        {/foreach}
                        <tr>
                            <td>
                                {if $config.protect_of_elements && $user.id == 1}
                                    <br>
                                    <a href=""
                                       onclick="$('#protect_block').toggle();
                                                this.innerHTML = this.innerHTML == '{$lang.Protect}' ? '{$lang.Hide}' : '{$lang.Protect}';
                                                return false;">{$lang.Protect}</a>
                                {/if}
                            </td>
                        </tr>
                        {if $config.protect_of_elements && $user.id == 1}
                        <tr id="protect_block" style="display:none">
                            <td colspan="8">
                                <table>
                                    <tr>
                                        <td align="right">{$lang.Protected}<span class='help_bt' h_id='Protect_of_element'></span>:</td>
                                        <td>
                                            <input type="checkbox" name="protected" {if $protected}checked{/if} onclick="$('[id^=pr_]').prop('disabled', !this.checked)">
                                            <span class="access_param_wrapper">{$lang.View2}<span class='help_bt' h_id='protect_of_view'></span></span>
                                            <span class="access_param_wrapper">{$lang.Edit3}<span class='help_bt' h_id='protect_of_edit'></span></span>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td align="right"></td>
                                        <td>
                                            <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 15px; text-align: center;">
                                                <input type="checkbox" id="pr_view_all" {if !$protected}disabled{/if}
                                                       onclick="$('[id^=pr_view]').prop('checked', this.checked); if (!this.checked) $('[id^=pr_edit]').prop('checked', 0);">
                                            </div>
                                            <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 0; text-align: center;">
                                                <input type="checkbox" id="pr_edit_all" {if !$protected}disabled{/if}
                                                       onclick="$('[id^=pr_edit]').prop('checked', this.checked); if ( this.checked) $('[id^=pr_view]').prop('checked', 1);">
                                            </div>
                                        </td>
                                    </tr>
                                    {foreach from=$protect key=gid item=acc}
                                        <tr>
                                            <td align="right" style="padding-top: 11px;">{$acc.name}:</td>
                                            <td style="display: flex; flex-wrap: nowrap;">
                                                <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 15px; text-align: center;">
                                                    <input type="checkbox" name="protect_rights[{$gid}][view]" id="pr_view{$gid}" value="1"
                                                           {if $acc.view}checked{/if} {if !$protected}disabled{/if}
                                                           onclick="if (!this.checked) $('#pr_edit{$gid}').prop('checked', 0)">
                                                </div>
                                                <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 0; text-align: center;">
                                                    <input type="checkbox" name="protect_rights[{$gid}][edit]" id="pr_edit{$gid}" value="1"
                                                           {if $acc.edit}checked{/if} {if !$protected}disabled{/if}
                                                           onclick="if ( this.checked) $('#pr_view{$gid}').prop('checked', 1)">
                                                </div>
                                            </td>
                                        </tr>
                                    {/foreach}
                                    <tr><td></td></tr>
                                    <tr>
                                        <td align=right>{$lang.Comment}<span class='help_bt' h_id='protect_comment'></span>:</td>
                                        <td><textarea class="form-control form-control-250" name="protect_comment" rows=5>{$protect_comment}</textarea></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        {/if}
                    </table>
                    <br/><br/>

                    <center>
                        <input type="hidden" value="{$group_pid}" name="group_pid"/>
                        <input type="hidden" value="{$parent}" name="parent"/>
                        <input type="hidden" value="1" name="add"/>
                        <input type="hidden" value="{$table_id}" name="table_id"/>
                        <input type="hidden" value="{$expert_mode}" name="expert"/>
                        <input type="hidden" value="{$csrf}" name="csrf"/>
                        <input type="hidden" value="rules" name="save"/>
                        <input class="btn btn-default btn-sm" type="submit" value="{$lang.Add}" style="margin-right:10px"/>
                        <input class="btn btn-default btn-sm" type="button" value="{$lang.Cancel}"
                               onclick="location.href='edit_group.php?group={$group_id}&cat={$cat_id}&cat_item={$cat_item}{if $menu}&menu={$menu}{/if}'"/>
                    </center>
                </td>
            </tr>
        </table>
    </form>
    <br>
    <a href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules">{$lang.return_to_rules}</a>
    <br/>
    <br/>
{else}
    {if $error}
        <div style="text-align:center;font-size: 13px;">
            <span id="edit_config__info-maessage" style="color:red">{$error}</span><br><br>
        </div>
    {/if}
    {if !$blocked_rule}
    <form action="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item={$cat_item}{if $rules[$rules_id].global}&to_back={$to_back}{/if}"
          method="post"  onsubmit="return checkInput()">

        {include file="./acc_menu.tpl"}

        <table id="tbl_main_{$rule.id}">
            <tr>
                <td align="right">{$lang.Name}:</td>
                <td>
                    <input class="form-control form-control-250" id="nameInput" name="name" value="{$add_name}"/>
                </td>
            </tr>
            <tr>
                <td align="right">{$lang.Rule_global}:</td>
                <td>
                    <input type="checkbox" name="global" {if $rules[$rules_id].global}checked{/if}/>
                </td>
            </tr>
            <tr>
                <td align="right">{$lang.Help}:</td>
                <td>
                    <a href="" onclick="$(this).hide(); $('#help_area').show(); return false;">{$lang.open}</a>
                    <textarea class="form-control" name="help" rows="5" cols="38" id="help_area" style="display:none">{$rules[$rules_id].help}</textarea>
                </td>
            </tr>
            <tr>
                <td align="right" valign="top" style="padding-top:4px">{$lang.Conditions}:</td>
                <td id="wizard_set{if $set_cond_array}{$rules_id}{else}999{/if}"></td>
            </tr>
            <tr>
                <td colspan="2"><br/></td>
            </tr>
        </table>

        <br>

        <table border=0 cellpadding=0 align="center" width="800px" style="border-collapse:collapse">
            <tr>
                {foreach from=$table_acc item=one_acc key=acc_key}
                    <td id="yellow_{$rules_id}_{$acc_key}" align="left"
                        style="padding:8px 8px 8px 11px;background-color:{if $one_acc.blocked}#f3f3f3{elseif $rules[$rules_id].table_acc.$acc_key.val==2 || $rules[$rules_id].table_acc.$acc_key.val==1}#EBF9D3{else}#F9F9F9{/if}"
                        o_bg="{if $rules[$rules_id].table_acc.$acc_key.val==2 || $rules[$rules_id].table_acc.$acc_key.val==1}#EBF9D3{else}#F9F9F9{/if}">
                        <div>
                            <input id="{$rules_id}_{$acc_key}" type="hidden" name="{$acc_key}"
                                   {if $one_acc.val}checked{/if} value="{$rules[$rules_id].table_acc.$acc_key.val}"
                                   o_value='{$rules[$rules_id].table_acc.$acc_key.val_o}'
                                   o_green="{$rules[$rules_id].table_acc.$acc_key.flag}"
                                   o_set="{$rules[$rules_id].table_acc.$acc_key.val}"/>
                            <div id="bor_tab_{$rules_id}_{$acc_key}" {if !$one_acc.blocked}onclick="set_val_table('{$rules_id}_{$acc_key}')"{/if}
                                 style="{if !$rules[$rules_id].table_acc.$acc_key.flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin-top:1px;"></div>
                            <img style="float:left;margin-top:1px;margin-right:6px" id="par_{$rules_id}_{$acc_key}"
                                 src="images/check_{if $rules[$rules_id].table_acc.$acc_key.val==2}dis_on{elseif $rules[$rules_id].table_acc.$acc_key.val==3}dis_off{elseif $rules[$rules_id].table_acc.$acc_key.val}on{else}off{/if}_m.png"
                                 {if !$one_acc.blocked}onclick="set_val_table('{$rules_id}_{$acc_key}')"{/if}
                                 o_value='{$rules[$rules_id].table_acc.$acc_key.val}'> {$one_acc.name}
                        </div>
                    </td>
                    <td style="width:5px"></td>
                {/foreach}
            </tr>
        </table>
        <table border=0 cellpadding=0 align="center" width="800px" style="border-collapse:collapse;"
               id="tbl_child_{$rules_id}">
            <tr>
                <td colspan="6"><br/></td>
            </tr>
            <tr>
                <td align="left" valign="top" style="border-bottom:1px solid #BBBBBB" width="227px">
                    <span style="color:gray">{$lang.Mode}:</span> {if $expert_mode}<a
                        href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu={if $fields}common{else}rules{/if}{if $res_rule}&rules_id={$res_rule}{elseif $rules_id}&rules_id={$rules_id}{/if}&expert=2">{$lang.Simple}</a>{else}{$lang.Simple}{/if}
                    / {if !$expert_mode}<a
                        href="edit_group.php?group={$group_id}&cat={$cat_id}&cat_item=t{$table_id}&menu={if $fields}common{else}rules{/if}{if $res_rule}&rules_id={$res_rule}{elseif $rules_id}&rules_id={$rules_id}{/if}&expert=1">{$lang.Experts}</a>{else}{$lang.Experts}{/if}
                </td>
                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {$lang.Table}<br/>
                    <img style="margin-top:4px" id="all_{$rules_id}_read" src="images/check_off_m.png"
                         onclick="check_all('{$rules_id}_read', this)" o_value="{if $parent}2{else}0{/if}">
                </td>
                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {$lang.View}<br/>
                    <img style="margin-top:4px" id="all_{$rules_id}_view" src="images/check_off_m.png"
                         onclick="check_all('{$rules_id}_view', this)" o_value="{if $parent}2{else}0{/if}">
                </td>
                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {$lang.Edit2}<br/>
                    <img style="margin-top:4px" id="all_{$rules_id}_write" src="images/check_off_m.png"
                         onclick="check_all('{$rules_id}_write', this)" o_value="{if $parent}2{else}0{/if}">
                </td>

                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {if $expert_mode}
                        {$lang.Add2}
                        <br/>
                        <img style="margin-top:4px" id="all_{$rules_id}_exp_add_acc" src="images/check_off_m.png"
                             onclick="check_all('{$rules_id}_exp_add_acc', this)" o_value="{if $parent}2{else}0{/if}">
                    {/if}
                </td>
                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {if $expert_mode}
                        {$lang.Subtable}
                        <br/>
                        <img style="margin-top:4px" id="all_{$rules_id}_exp_sub_acc" src="images/check_off_m.png"
                             onclick="check_all('{$rules_id}_exp_sub_acc', this)" o_value="{if $parent}2{else}0{/if}">
                    {/if}
                </td>
                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {if $expert_mode}
                        {$lang.Export}
                        <br/>
                        <img style="margin-top:4px" id="all_{$rules_id}_exp_read_acc" src="images/check_off_m.png"
                             onclick="check_all('{$rules_id}_exp_read_acc', this)" o_value="{if $parent}2{else}0{/if}">
                    {/if}
                </td>
                <td align="center" width="95px" style="border-bottom:1px solid #BBBBBB;padding-bottom:4px">
                    {if $expert_mode}
                        {$lang.Import}
                        <br/>
                        <img style="margin-top:4px" id="all_{$rules_id}_exp_write_acc" src="images/check_off_m.png"
                             onclick="check_all('{$rules_id}_exp_write_acc', this)" o_value="{if $parent}2{else}0{/if}">
                    {/if}
                </td>

            </tr>
            {foreach from=$rules[$rules_id].rules_fields item=one_rule_field}
                {if $one_rule_field.name_field || $one_rule_field.name}
                    <tr onmouseover="mouseBlue(this,1);" onmouseout="mouseBlue(this,0);" class="{if $one_rule_field.type=="fgroup"}acc-group-row{else}acc-field-row{/if}">
                        {*<td align="left" style="border-bottom:1px solid #BBBBBB">{$one_rule_field.name_field}</td>*}
                        <td align="left" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            {if $one_rule_field.type=="fgroup"}
                                <div style="padding-top:4px;padding-bottom:6px;">
                                    <b>{$lang.Group}:</b>
                                    <a href="edit_fgroup.php?table={$table_id}&group={$one_rule_field.id}{if $back_url}&back_url={$base64_current_url}{/if}">
                                        <b style="color: black">{$one_rule_field.name}</b>
                                    </a>
                                </div>
                            {else}
                                <span>{$one_rule_field.name_field}</span>
                            {/if}
                        </td>
                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            <div id="yellow_{$rules_id}_read_{$one_rule_field.id}"
                                 style="{if $one_rule_field.type=="fgroup"}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.read_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.tab_acc_blocked}#f3f3f3{/if}">
                                <input id="{$rules_id}_read_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.read_acc < 2}fields[{$one_rule_field.id}][read]{/if}"
                                       data-name='fields[{$one_rule_field.id}][read]'
                                       data-value='{$one_rule_field.read_acc}'
                                       {if $one_rule_field.read_acc}checked{/if}
                                       value="{$one_rule_field.read_acc}"
                                       {if $one_rule_field.type=="fgroup"}disabled{/if}
                                       o_value='{$one_rule_field.read_acc}'
                                       o_green="{$one_rule_field.read_acc_flag}"/>
                                <div id="bor_{$rules_id}_read_{$one_rule_field.id}"
                                     {if !$one_rule_field.blocked && !$one_rule_field.tab_acc_blocked}onclick="set_val('{$rules_id}_read_{$one_rule_field.id}')"{/if}
                                     style="{if !$one_rule_field.read_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>
                                <img id="par_{$rules_id}_read_{$one_rule_field.id}"
                                     src="images/check_{if $one_rule_field.read_acc==2}dis_on{elseif $one_rule_field.read_acc==3}dis_off{elseif $one_rule_field.read_acc}on{else}off{/if}_m.png"
                                     {if !$one_rule_field.blocked && !$one_rule_field.tab_acc_blocked}onclick="set_val('{$rules_id}_read_{$one_rule_field.id}')"{/if}
                                     o_value='{$one_rule_field.read_acc_o}'>
                            </div>
                            {if $selected_right_info and $one_rule_field.read_acc < 2}
                            <script>change_flag['{$rules_id}_read_{$one_rule_field.id}'] = 1</script>
                            {/if}
                            {if $one_rule_field.type == 'fgroup'}
                              <input type="checkbox" id="{$one_rule_field.id}_1" onclick="checkGroup(this)" class="fgroup-checkbox">

                              <label for="{$one_rule_field.id}_1" class="label-for-fgroup-checkbox on">
                                  <img src="images/check_on_m.png"/>
                              </label>
                              <label for="{$one_rule_field.id}_1" class="label-for-fgroup-checkbox off">
                                  <img src="images/check_off_m.png"/>
                              </label>
                            {/if}
                        </td>
                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            <div id="yellow_{$rules_id}_view_{$one_rule_field.id}"
                                 style="{if $one_rule_field.type=="fgroup"}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.view_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.view_acc_blocked}#f3f3f3{/if}">
                                <input id="{$rules_id}_view_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.view_acc < 2}fields[{$one_rule_field.id}][view]{/if}"
                                       data-name='fields[{$one_rule_field.id}][view]'
                                       data-value='{$one_rule_field.view_acc}'
                                       {if $one_rule_field.view_acc}checked{/if}
                                       value="{$one_rule_field.view_acc}"
                                       {if $one_rule_field.type=="fgroup"}disabled{/if}
                                       o_value='{$one_rule_field.view_acc}'
                                       o_green="{$one_rule_field.view_acc_flag}"/>
                                <div id="bor_{$rules_id}_view_{$one_rule_field.id}"
                                     {if !$one_rule_field.blocked && !$one_rule_field.view_acc_blocked}onclick="set_val('{$rules_id}_view_{$one_rule_field.id}')"{/if}
                                     style="{if !$one_rule_field.view_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>
                                <img id="par_{$rules_id}_view_{$one_rule_field.id}"
                                     src="images/check_{if $one_rule_field.view_acc==2}dis_on{elseif $one_rule_field.view_acc==3}dis_off{elseif $one_rule_field.view_acc}on{else}off{/if}_m.png"
                                     {if !$one_rule_field.blocked && !$one_rule_field.view_acc_blocked}onclick="set_val('{$rules_id}_view_{$one_rule_field.id}')"{/if}
                                     o_value='{$one_rule_field.view_acc_o}'>
                            </div>
                            {if $selected_right_info and $one_rule_field.view_acc < 2}
                            <script>change_flag['{$rules_id}_view_{$one_rule_field.id}'] = 1</script>
                            {/if}
                            {if $one_rule_field.type == 'fgroup'}
                                <input type="checkbox" id="{$one_rule_field.id}_2" onclick="checkGroup(this)" class="fgroup-checkbox">

                                <label for="{$one_rule_field.id}_2" class="label-for-fgroup-checkbox on">
                                    <img src="images/check_on_m.png"/>
                                </label>
                                <label for="{$one_rule_field.id}_2" class="label-for-fgroup-checkbox off">
                                    <img src="images/check_off_m.png"/>
                                </label>
                            {/if}
                        </td>
                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            <div id="yellow_{$rules_id}_write_{$one_rule_field.id}"
                                 style="{if $one_rule_field.type=='fgroup'}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.write_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.edit_acc_blocked}#f3f3f3{/if}">
                                {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}<input id="{$rules_id}_write_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.write_acc < 2}fields[{$one_rule_field.id}][write]{/if}"
                                       data-name='fields[{$one_rule_field.id}][write]'
                                       data-value='{$one_rule_field.write_acc}'
                                       {if $one_rule_field.write_acc}checked{/if}
                                       value="{$one_rule_field.write_acc}"
                                       {if $one_rule_field.type=="fgroup"}disabled{/if}
                                       o_value='{$one_rule_field.write_acc}'
                                       o_green="{$one_rule_field.write_acc_flag}"/>
                                <div id="bor_{$rules_id}_write_{$one_rule_field.id}"
                                     {if !$one_rule_field.blocked && !$one_rule_field.edit_acc_blocked}onclick="set_val('{$rules_id}_write_{$one_rule_field.id}')"{/if}
                                     style="{if !$one_rule_field.write_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>{/if}
                                <img {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}id="par_{$rules_id}_write_{$one_rule_field.id}"{/if}
                                     src="images/check_{if $one_rule_field.write_acc==2}dis_on{elseif $one_rule_field.write_acc==3}dis_off{elseif $one_rule_field.write_acc}on{else}off{/if}_m.png"
                                     {if ($one_rule_field.type_field < 10 || $one_rule_field.type_field > 13) && !$one_rule_field.blocked && !$one_rule_field.edit_acc_blocked}onclick="set_val('{$rules_id}_write_{$one_rule_field.id}')"{/if}
                                     o_value='{$one_rule_field.write_acc_o}'>
                            </div>
                            {if $selected_right_info and $one_rule_field.write_acc < 2}
                            <script>change_flag['{$rules_id}_write_{$one_rule_field.id}'] = 1</script>
                            {/if}
                            {if $one_rule_field.type == 'fgroup'}
                              <input type="checkbox" id="{$one_rule_field.id}_3" onclick="checkGroup(this)" class="fgroup-checkbox">

                              <label for="{$one_rule_field.id}_3" class="label-for-fgroup-checkbox on">
                                  <img src="images/check_on_m.png"/>
                              </label>
                              <label for="{$one_rule_field.id}_3" class="label-for-fgroup-checkbox off">
                                  <img src="images/check_off_m.png"/>
                              </label>
                            {/if}
                        </td>

                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            {if $expert_mode}
                                <div id="yellow_{$rules_id}_exp_add_acc_{$one_rule_field.id}"
                                     style="{if $one_rule_field.type=='fgroup'}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.exp_add_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.add_acc_blocked}#f3f3f3{/if}">
                                    {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}<input id="{$rules_id}_exp_add_acc_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.exp_add_acc < 2}fields[{$one_rule_field.id}][exp_add_acc]{/if}"
                                           data-name='fields[{$one_rule_field.id}][exp_add_acc]'
                                           data-value='{$one_rule_field.exp_add_acc}'
                                           {if $one_rule_field.exp_add_acc}checked{/if}
                                           value="{$one_rule_field.exp_add_acc}"
                                           {if $one_rule_field.type=="fgroup"}disabled{/if}
                                           o_value='{$one_rule_field.exp_add_acc}'
                                           o_green="{$one_rule_field.exp_add_acc_flag}"/>
                                    <div id="bor_{$rules_id}_exp_add_acc_{$one_rule_field.id}"
                                         {if !$one_rule_field.blocked && !$one_rule_field.add_acc_blocked}onclick="set_val('{$rules_id}_exp_add_acc_{$one_rule_field.id}')"{/if}
                                         style="{if !$one_rule_field.exp_add_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>{/if}
                                    <img {if $one_rule_field.type_field < 10 || $one_rule_field.type_field > 13}id="par_{$rules_id}_exp_add_acc_{$one_rule_field.id}"{/if}
                                         src="images/check_{if $one_rule_field.exp_add_acc==2}dis_on{elseif $one_rule_field.exp_add_acc==3}dis_off{elseif $one_rule_field.exp_add_acc}on{else}off{/if}_m.png"
                                         {if ($one_rule_field.type_field < 10 || $one_rule_field.type_field > 13) && !$one_rule_field.blocked && !$one_rule_field.add_acc_blocked}onclick="set_val('{$rules_id}_exp_add_acc_{$one_rule_field.id}')"{/if}
                                         o_value='{$one_rule_field.exp_add_acc_o}'>
                                </div>
                                {if $selected_right_info and $one_rule_field.exp_add_acc < 2}
                                <script>change_flag['{$rules_id}_exp_add_acc_{$one_rule_field.id}'] = 1</script>
                                {/if}
                                {if $one_rule_field.type == 'fgroup'}
                                  <input type="checkbox" id="{$one_rule_field.id}_4" onclick="checkGroup(this)" class="fgroup-checkbox">

                                  <label for="{$one_rule_field.id}_4" class="label-for-fgroup-checkbox on">
                                      <img src="images/check_on_m.png"/>
                                  </label>
                                  <label for="{$one_rule_field.id}_4" class="label-for-fgroup-checkbox off">
                                      <img src="images/check_off_m.png"/>
                                  </label>
                                {/if}
                            {/if}
                        </td>
                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            {if $expert_mode}
                                <div id="yellow_{$rules_id}_exp_sub_acc_{$one_rule_field.id}"
                                     style="{if $one_rule_field.type=="fgroup"}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.exp_sub_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.sub_acc_blocked}#f3f3f3{/if}">
                                    <input id="{$rules_id}_exp_sub_acc_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.exp_sub_acc < 2}fields[{$one_rule_field.id}][exp_sub_acc]{/if}"
                                           data-name='fields[{$one_rule_field.id}][exp_sub_acc]'
                                           data-value='{$one_rule_field.exp_sub_acc}'
                                           {if $one_rule_field.exp_sub_acc}checked{/if}
                                           value="{$one_rule_field.exp_sub_acc}"
                                           {if $one_rule_field.type=="fgroup"}disabled{/if}
                                           o_value='{$one_rule_field.exp_sub_acc}'
                                           o_green="{$one_rule_field.exp_sub_acc_flag}"/>
                                    <div id="bor_{$rules_id}_exp_sub_acc_{$one_rule_field.id}"
                                         {if !$one_rule_field.blocked && !$one_rule_field.sub_acc_blocked}onclick="set_val('{$rules_id}_exp_sub_acc_{$one_rule_field.id}')"{/if}
                                         style="{if !$one_rule_field.exp_sub_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>
                                    <img id="par_{$rules_id}_exp_sub_acc_{$one_rule_field.id}"
                                         src="images/check_{if $one_rule_field.exp_sub_acc==2}dis_on{elseif $one_rule_field.exp_sub_acc==3}dis_off{elseif $one_rule_field.exp_sub_acc}on{else}off{/if}_m.png"
                                         {if !$one_rule_field.blocked && !$one_rule_field.sub_acc_blocked}onclick="set_val('{$rules_id}_exp_sub_acc_{$one_rule_field.id}')"{/if}
                                         o_value='{$one_rule_field.exp_sub_acc_o}'>
                                </div>
                                {if $selected_right_info and $one_rule_field.exp_sub_acc < 2}
                                <script>change_flag['{$rules_id}_exp_sub_acc_{$one_rule_field.id}'] = 1</script>
                                {/if}
                                {if $one_rule_field.type == 'fgroup'}
                                  <input type="checkbox" id="{$one_rule_field.id}_5" onclick="checkGroup(this)" class="fgroup-checkbox">

                                  <label for="{$one_rule_field.id}_5" class="label-for-fgroup-checkbox on">
                                      <img src="images/check_on_m.png"/>
                                  </label>
                                  <label for="{$one_rule_field.id}_5" class="label-for-fgroup-checkbox off">
                                      <img src="images/check_off_m.png"/>
                                  </label>
                                {/if}
                            {/if}
                        </td>
                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            {if $expert_mode}
                                <div id="yellow_{$rules_id}_exp_read_acc_{$one_rule_field.id}"
                                     style="{if $one_rule_field.type=="fgroup"}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.exp_read_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.exp_acc_blocked}#f3f3f3{/if}">
                                    <input id="{$rules_id}_exp_read_acc_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.exp_read_acc < 2}fields[{$one_rule_field.id}][exp_read_acc]{/if}"
                                           data-name='fields[{$one_rule_field.id}][exp_read_acc]'
                                           data-value='{$one_rule_field.exp_read_acc}'
                                           {if $one_rule_field.exp_read_acc}checked{/if}
                                           value="{$one_rule_field.exp_read_acc}"
                                           {if $one_rule_field.type=="fgroup"}disabled{/if}
                                           o_value='{$one_rule_field.exp_read_acc}'
                                           o_green="{$one_rule_field.exp_read_acc_flag}"/>
                                    <div id="bor_{$rules_id}_exp_read_acc_{$one_rule_field.id}"
                                         {if !$one_rule_field.blocked && !$one_rule_field.exp_acc_blocked}onclick="set_val('{$rules_id}_exp_read_acc_{$one_rule_field.id}')"{/if}
                                         style="{if !$one_rule_field.exp_read_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>
                                    <img id="par_{$rules_id}_exp_read_acc_{$one_rule_field.id}"
                                         src="images/check_{if $one_rule_field.exp_read_acc==2}dis_on{elseif $one_rule_field.exp_read_acc==3}dis_off{elseif $one_rule_field.exp_read_acc}on{else}off{/if}_m.png"
                                         {if !$one_rule_field.blocked && !$one_rule_field.exp_acc_blocked}onclick="set_val('{$rules_id}_exp_read_acc_{$one_rule_field.id}')"{/if}
                                         o_value='{$one_rule_field.exp_read_acc_o}'>
                                </div>
                                {if $selected_right_info and $one_rule_field.exp_read_acc < 2}
                                <script>change_flag['{$rules_id}_exp_read_acc_{$one_rule_field.id}'] = 1</script>
                                {/if}
                                {if $one_rule_field.type == 'fgroup'}
                                  <input type="checkbox" id="{$one_rule_field.id}_6" onclick="checkGroup(this)" class="fgroup-checkbox">

                                  <label for="{$one_rule_field.id}_6" class="label-for-fgroup-checkbox on">
                                      <img src="images/check_on_m.png"/>
                                  </label>
                                  <label for="{$one_rule_field.id}_6" class="label-for-fgroup-checkbox off">
                                      <img src="images/check_off_m.png"/>
                                  </label>
                                {/if}
                            {/if}
                        </td>
                        <td align="center" style="border-bottom:1px solid #BBBBBB; {if $one_rule_field.blocked}background-color:#f3f3f3;{/if}">
                            {if $expert_mode}
                                <div id="yellow_{$rules_id}_exp_write_acc_{$one_rule_field.id}"
                                     style="{if $one_rule_field.type=="fgroup"}display:none;{/if}width:31px;padding-top:8px;padding-bottom:6px;text-align:center;background-color:{if $selected_right_info and $one_rule_field.exp_write_acc < 2}rgb(255, 255, 153){elseif $one_rule_field.imp_acc_blocked}#f3f3f3{/if}">
                                    <input id="{$rules_id}_exp_write_acc_{$one_rule_field.id}" type="hidden" name="{if $selected_right_info and $one_rule_field.exp_write_acc < 2}fields[{$one_rule_field.id}][exp_write_acc]{/if}"
                                           data-name='fields[{$one_rule_field.id}][exp_write_acc]'
                                           data-value='{$one_rule_field.exp_write_acc}'
                                           {if $one_rule_field.exp_write_acc}checked{/if}
                                           value="{$one_rule_field.exp_write_acc}"
                                           {if $one_rule_field.type=="fgroup"}disabled{/if}
                                           o_value='{$one_rule_field.exp_write_acc}'
                                           o_green="{$one_rule_field.exp_write_acc_flag}"/>
                                    <div id="bor_{$rules_id}_exp_write_acc_{$one_rule_field.id}"
                                         {if !$one_rule_field.blocked && !$one_rule_field.imp_acc_blocked}onclick="set_val('{$rules_id}_exp_write_acc_{$one_rule_field.id}')"{/if}
                                         style="{if !$one_rule_field.exp_write_acc_flag}display:none;{/if}border: 1px solid #FF7F7F;width:11px;height:11px;position:absolute;margin:5px 0 0 9px"></div>
                                    <img id="par_{$rules_id}_exp_write_acc_{$one_rule_field.id}"
                                         src="images/check_{if $one_rule_field.exp_write_acc==2}dis_on{elseif $one_rule_field.exp_write_acc==3}dis_off{elseif $one_rule_field.exp_write_acc}on{else}off{/if}_m.png"
                                         {if !$one_rule_field.blocked && !$one_rule_field.imp_acc_blocked}onclick="set_val('{$rules_id}_exp_write_acc_{$one_rule_field.id}')"{/if}
                                         o_value='{$one_rule_field.exp_write_acc_o}'>
                                </div>
                                {if $selected_right_info and $one_rule_field.exp_write_acc < 2}
                                <script>change_flag['{$rules_id}_exp_write_acc_{$one_rule_field.id}'] = 1</script>
                                {/if}
                                {if $one_rule_field.type == 'fgroup'}
                                  <input type="checkbox" id="{$one_rule_field.id}_7" onclick="checkGroup(this)" class="fgroup-checkbox">

                                  <label for="{$one_rule_field.id}_7" class="label-for-fgroup-checkbox on">
                                      <img src="images/check_on_m.png"/>
                                  </label>
                                  <label for="{$one_rule_field.id}_7" class="label-for-fgroup-checkbox off">
                                      <img src="images/check_off_m.png"/>
                                  </label>
                                {/if}
                            {/if}
                        </td>
                    </tr>
                {/if}
            {/foreach}
            <tr>
                <td>
                    {if $config.protect_of_elements && $user.id == 1}
                        <a href=""
                           onclick="$('#protect_block').toggle();
                                    this.innerHTML = this.innerHTML == '{$lang.Protect}' ? '{$lang.Hide}' : '{$lang.Protect}';
                                    return false;">{$lang.Protect}</a>
                    {/if}
                </td>
                <td colspan="7">
                    <br/>
                    <div style="text-align:right;color:gray">
                        {$lang.Copy_rule_from_group}:
                        <select class="form-control form-control-250" onchange="document.location.href='edit_group.php?group={$group_id}&cat={$cat_id}&cat_item={$cat_item}&menu=rules&rules_id={$res_rule}&set_right='+this.value;">
                            <option></option>
                            {foreach from=$group_to_copy item=one_group}
                                <optgroup label="{$one_group.name}">
                                    {foreach from=$one_group.rules item=one_rule}
                                        <option value="{$one_rule.id}@@@{$one_rule.group_id}">{$one_rule.name}</option>
                                    {/foreach}
                                </optgroup>
                            {/foreach}
                        </select>
                    </div>
                </td>
            </tr>
            {if $config.protect_of_elements && $user.id == 1}
            <tr id="protect_block" style="display:none">
                <td colspan="8">
                    <table>
                        <tr>
                            <td align="right">{$lang.Protected}<span class='help_bt' h_id='Protect_of_element'></span>:</td>
                            <td>
                                <input type="checkbox" name="protected" {if $protected}checked{/if} onclick="$('[id^=pr_]').prop('disabled', !this.checked)">
                                <span class="access_param_wrapper">{$lang.View2}<span class='help_bt' h_id='protect_of_view'></span></span>
                                <span class="access_param_wrapper">{$lang.Edit3}<span class='help_bt' h_id='protect_of_edit'></span></span>
                            </td>
                        </tr>
                        <tr>
                            <td align="right"></td>
                            <td>
                                <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 15px; text-align: center;">
                                    <input type="checkbox" id="pr_view_all" {if !$protected}disabled{/if}
                                           onclick="$('[id^=pr_view]').prop('checked', this.checked); if (!this.checked) $('[id^=pr_edit]').prop('checked', 0);">
                                </div>
                                <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 0; text-align: center;">
                                    <input type="checkbox" id="pr_edit_all" {if !$protected}disabled{/if}
                                           onclick="$('[id^=pr_edit]').prop('checked', this.checked); if ( this.checked) $('[id^=pr_view]').prop('checked', 1);">
                                </div>
                            </td>
                        </tr>
                        {foreach from=$protect key=gid item=acc}
                            <tr>
                                <td align="right" style="padding-top: 11px;">{$acc.name}:</td>
                                <td style="display: flex; flex-wrap: nowrap;">
                                    <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 15px; text-align: center;">
                                        <input type="checkbox" name="protect_rights[{$gid}][view]" id="pr_view{$gid}" value="1"
                                               {if $acc.view}checked{/if} {if !$protected}disabled{/if}
                                               onclick="if (!this.checked) $('#pr_edit{$gid}').prop('checked', 0)">
                                    </div>
                                    <div style="float: left; margin:0 34px; width: 60px; padding: 8px 0 6px 0; text-align: center;">
                                        <input type="checkbox" name="protect_rights[{$gid}][edit]" id="pr_edit{$gid}" value="1"
                                               {if $acc.edit}checked{/if} {if !$protected}disabled{/if}
                                               onclick="if ( this.checked) $('#pr_view{$gid}').prop('checked', 1)">
                                    </div>
                                </td>
                            </tr>
                        {/foreach}
                        <tr><td></td></tr>
                        <tr>
                            <td align=right>{$lang.Comment}<span class='help_bt' h_id='protect_comment'></span>:</td>
                            <td><textarea class="form-control form-control-250" name="protect_comment" rows=5>{$protect_comment}</textarea></td>
                        </tr>
                    </table>
                </td>
            </tr>
            {/if}
        </table>

        <div id="div_child_{$rules_id}">
            <br/><br/>
            <center>
                <input type="hidden" value="{$selected_right_info}" name="selected_right_info"/>
                <input type="hidden" value="{$parent}" name="parent"/>
                <input type="hidden" value="{if !$set_rule}{$rules_id}{else}{$res_rule}{/if}" name="save_id"/>
                <input type="hidden" value="{$table_id}" name="table_id"/>
                <input type="hidden" value="{$expert_mode}" name="expert"/>
                <input type="hidden" value="{$csrf}" name="csrf"/>
                <input type="hidden" value="rules" name="save"/>
                <input class="btn btn-default btn-sm" type="submit" value="{$lang.Save}" style="margin-right:10px"
                       {if $no_save_mode}disabled title="{$lang.Element_no_edit_msg}"{/if}/>
                <input type="hidden" value="{$lang.Delete}" style="margin-right:10px"
                       onclick="$('#delete_{$rules_id}').val('1')"/>
                <input class="btn btn-default btn-sm" type="button" value="{$lang.Cancel}"
                       onclick="document.location.href='edit_group.php?group={$group_id}&cat={$cat_id}&cat_item={$cat_item}&menu={$menu}&rules_id={$rules_id}'"/>
            </center>
        </div>
    </form>
    <input type="hidden" value="0" name="delete" id="delete_{$rules_id}"/>
    <br>
    {/if}
    <a href="edit_group.php?group={if $to_back}{$to_back}{else}{$group_id}{/if}&cat={$cat_id}&cat_item=t{$table_id}&menu=rules">{$lang.return_to_rules}</a>
    <br/>
    <br/>
{/if}
