{include file="./index_top.tpl"}
<script>
    let ajaxObj = new XMLHTTP("edit_status.php");
        ajaxObj.format = 0;
        ajaxObj.method = "POST";
    function switchOnObjectInformers(status_id) {
        $('#switch-on-btn_'+status_id).toggleClass('switch-on');
        $('#switch-on-btn_'+status_id).trigger('on.switch');
        ajaxObj.call('status_id='+status_id+'&sel=disable&enbl='+($('#switch-on-btn_'+status_id).hasClass('switch-on')?1:0)+'&csrf={$csrf}',()=>{});
    }
</script>
<div align=center>
    <br>{$lang.informers_of_table} "{$name_table}"<span class='help_bt' h_id='Informers'></span><br><br>
    {include file="./conf_nav.tpl"}
    <p style="font-size:14px;">
        {if $archive}<a style="font-size:14px;" href="edit_status.php?table={$table_id}">{/if}
            {$lang.active}
        {if $archive}</a>{/if}
        /
        {if !$archive}
            {if $has_archive}
                <a style="font-size:14px;" href="edit_status.php?table={$table_id}&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_status.php?table={$table_id}" method="post">
        <table class="sortableTable">
            {foreach from=$all_informers item=one_informer}
                {if $user.group_id==1 || $user.sub_admin_rights.tables.{$table_id}>=2 || $one_informer.owner_id==$user.group_id}
                {if $config.display_protected_elements || $one_informer.blocked != 2}
                    <tr {if $one_informer.table_id != $table_id}class="noDrug"{/if}>
                        <td>{if $one_informer.table_id == $table_id}<span class="draggableImg"></span>{/if}</td>
                        <td>
                            {if $user.group_id==1 || $user.sub_admin_rights.tables.{$one_informer.table_id}==2 || $one_informer.owner_id==$user.group_id}
                            {if !$one_informer.blocked}
                            {if !$archive}
                                <a class='href_post'
                                    href="edit_status.php?table={$one_informer.table_id}&status={$one_informer.id}&sel=archive&return={$table_id}"><img
                                            alt="{$lang.into_archive}" title="{$lang.send_in_archive}"
                                            src="images/b_archive.png" border=0></a>
                            {else}
                                <a class='href_post'
                                    href="edit_status.php?table={$one_informer.table_id}&status={$one_informer.id}&sel=restore&return={$table_id}"><img
                                            alt="{$lang.restore}" title="{$lang.restore_from_archive}"
                                            src="images/b_restore.png" border=0></a>
                            {/if}
                            {/if}
                            {/if}
                        </td>
                        <td>
                            {if $user.group_id==1 || ($user.sub_admin_rights.tables.{$one_informer.table_id}==2 && $user.sub_admin_rights.allow_del) || $one_informer.owner_id==$user.group_id}
                            {if !$one_informer.blocked}
                                <a class='href_post'
                                href="edit_status.php?table={$one_informer.table_id}&informer={$one_informer.id}&delete&return={$table_id}{if $back_url}&back_url={$base64_back_url}{/if}"
                                onClick="return href_post=jconfirm('{$lang.alert_delete_informer}', this);"><img
                                        alt="{$lang.delete}" title="{$lang.Delete_informer}" src="images/b_drop.png" border=0>
                                </a>
                            {/if}
                            {/if}
                        </td>
                        {if !$archive}
                            <td>
                            {if $one_informer.blocked != 2 && $one_informer.blocked != 3 && !$add_blocked && ($all_modules.pro_tariff || $one_informer.construct)}
                                <a class='href_post'
                                href="edit_status.php?table={$one_informer.table_id}&informer={$one_informer.id}&amp;copy&return={$table_id}{if $back_url}&back_url={$base64_current_url}{/if}"
                                onClick="if (copy_name=prompt('{$lang.Copy_as}','{$one_informer.name} {$lang['(copy)']}')) {ldelim}this.href=this.href+'&amp;copy='+copy_name; href_post=true;{rdelim} else href_post=false;"><img
                                alt="{$lang.copy}" title="{$lang.Copy_informer}" src="images/b_copy.png" border=0>
                                </a>
                            {/if}
                            </td>
                            <td>
                            {if !$one_informer.blocked}
                                <div style="left: 0; top: 2px; margin: 0 5px;"
                                    onclick="switchOnObjectInformers('{$one_informer.id}')"
                                    class="switch-btn {if !$one_informer.disabled}switch-on{/if}"
                                    id="switch-on-btn_{$one_informer.id}"><div></div></div>
                            {/if}
                            </td>
                            <td><input type=text size=1 {if $one_informer.table_id == $table_id}name=num[{$one_informer.id}]{else}disabled{/if} value={$one_informer.num} class="informer__informer-num"></td>
                        {/if}
                        <td>
                            {if ($user.group_id==1 || $user.sub_admin_rights.tables.{$one_informer.table_id}>=2 || $one_informer.owner_id==$user.group_id) && $one_informer.blocked != 2}
                                <a href="edit_status.php?table={$one_informer.table_id}&informer={$one_informer.id}{if $back_url}&back_url={$smarty.get.back_url}{/if}"
                                   class="cb_field_title__link" {if $one_informer.blocked || $one_informer.table_id != $table_id}style="color:#ccc"{/if}>
                                    <b>{$one_informer.full_name}</b>
                                </a>
                            {else}
                                <b style="color:ccc">{$one_informer.full_name}</b>
                            {/if}
                        </td>
                        <td style="padding-left: 30px;">
                            {if $one_informer.construct}<span style="color: grey; font-style: italic;">{$lang.construct}</span>{/if}
                        </td>
                        {if $one_informer.protected}<td><img src="images/lock.svg" style="width:13px" title="{$one_informer.protect_comment}"></td>{/if}
                    </tr>
                {/if}
                {/if}
                {foreachelse}
                <tr>
                    <td>{$lang.No_informers}</td>
                </tr>
            {/foreach}
        </table>
        <br>
        <input type="hidden" name="back_url" value="{if $back_url}{$back_url}{else}{/if}">
        <input type="hidden" name="csrf" value="{$csrf}">
        {if !$archive && !$add_blocked}<input class="btn btn-default btn-sm" type=button value="{$lang.Add_informer}"
               onClick="location.href='edit_status.php?table={$table_id}&informer=-1{if $back_url}&back_url={$smarty.get.back_url}{/if}';">{/if}
        <br><br><br>
        <a href="{if $back_url}{$back_url}{else}edit_tabrep.php?cat={$cat_id}{/if}">
            {$lang.return_to_tables}
        </a> | <a href="fields.php?table={$table_id}" target="_blank">{$lang.view_table}</a>
    </form>
</div>

<script src="themes/clientbase/js/cut_title_field.js"></script>
