{include file="./index_top.tpl"}
{include file="./acc_top.tpl"}
<script>
    function set_pid(obj) {
        if ($(obj).val() != '0') $('#set_parent').val("1"); else $('#set_parent').val("0");
    }
</script>
<br>
<table class="" border=0 cellpadding=3>
    {foreach from=$all_groups item=one_group}
        <tr>
            <td>
                {if $one_group.id!=1 && $one_group.id!=777 && ($user.sub_admin_rights.access_subadmin || $user.group_id==1) && $user.group_id!=$one_group.id}
                    <a  href="edit_group.php?group={$one_group.id}&delete=1"
                        onClick="{if $one_group.cnt_users}jalert('{$lang.delete_group_empty_confirm}');return false;"{else}return href_post=jconfirm('{$lang.delete_group_confirm}', this)" class="href_post"{/if}>
                        <img alt="{$lang.Delete}" title="{$lang.Delete_group}" src="images/b_drop.png" border=0>
                    </a>
                {/if}
            </td>
            <td>{if (($user.sub_admin_rights.access_subadmin && $user.group_id!=$one_group.id) || $user.group_id==1)}
                    <a href="edit_group.php?group={$one_group.id}&edit=1"><img alt="{$lang.edit}" title="{$lang.Edit}"
                        src="images/b_edit.png" border=0>
                    </a>
                {/if}
            </td>
            <td>{if ($user.sub_admin_rights.access_subadmin || $user.group_id==1)}
                    <a class="href_post" href="edit_group.php?group={$one_group.id}&group_copy=1"
                        onClick="if (copy_name=prompt('{$lang.Copy_as}','{$one_group.name|escape:'html'} {$lang['(copy)']}')) { this.href=this.href+'&cname='+copy_name; href_post=true; } else { href_post=false; }">
                        <img alt="{$lang.copy}" title="{$lang.Copy_group}" src="images/b_copy.png" border=0>
                    </a>
                {/if}
            </td>
            <td>{$one_group.tab}
                <a href="edit_group.php?group={$one_group.id}{if $cat_id}&cat={$cat_id}{/if}{if $cat_item}&cat_item={$cat_item}{/if}">
                    {if ($one_group.cnt_users > 0)}
                        <b>{$one_group.name} ({$one_group.cnt_users})</b>
                    {else}
                        <b style="color: gray">{$one_group.name}</b>
                    {/if}
                </a>
            </td>
            <td style="font-style: italic;color:gray;">
                {if $one_group.id==1}
                    {$lang.administrator}
                    <span class='help_bt'
                          style="cursor:pointer;width:0px;height:14px;display:inline-block;vertical-align:baseline;background:none;margin:0;"
                          h_id='Admin'>(?)</span>
                {elseif $one_group.sub_admin==1}
                    {$lang.sub_admin}
                    <span class='help_bt'
                          style="cursor:pointer;width:0px;height:14px;display:inline-block;vertical-align:baseline;background:none;margin:0;"
                          h_id='Sub_admin'>(?)</span>
                {elseif $one_group.id==777}
                    {$lang.clients}
                    <span class='help_bt'
                          style="cursor:pointer;width:0px;height:14px;display:inline-block;vertical-align:baseline;background:none;margin:0;"
                          h_id='Clients'>(?)</span>
                {/if}
            </td>
        </tr>
        {foreachelse}
        <tr>
            <td>{$lang.No_groups}</td>
        </tr>
    {/foreach}
</table>
<br>
{if ($user.sub_admin_rights.access_subadmin || $user.group_id==1)}
    <form action="" method="post" id="adding_form">
        <table border=0 cellpadding=3 id="adding" style="display:none">
            <tr>
                <td align=right>{$lang.Group_name}:</td>
                <td><input class="form-control form-control-160" name="group_name" id="add_name" size=30/></td>
            </tr>
            <tr>
                <td align=right>{$lang.Subordinate_to_group}:</td>
                <td><select class="form-control form-control-160" style="min-width:100px" name="pid" onchange="set_pid(this)">
                        <option value="0">{$lang.no}</option>
                        {$in_group_select}
                    </select></td>
            </tr>
        </table>
        <br/>
        <input type="hidden" name="add_group" value="1"/>
        <input type="hidden" name="set_parent" id="set_parent" value="0"/>
        <input type="hidden" name="csrf" value="{$csrf}"/>
        <input class="btn btn-default" type="button" name="new" value="{$lang.Add_group}"
               onclick="if ($('#adding').css('display')=='none') $('#adding').css('display',''); else if ($('#add_name').val()=='') jalert('{$lang.alert_group_name}'); else { $('*').css('cursor','wait'); $('#adding_form').submit(); }">
    </form>
    <br>
{/if}
<br>
