{% extends 'base.html' %}
{% load common_tags %}
{% block content %}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5> 查看用户组 </h5>
                    <div class="ibox-tools">
                        <a class="collapise-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="">
                        <a href="{% url 'users:usergroup-add' %}" class="btn btn-sm btn-primary "> 添加用户组 </a>
                        <a id="del_btn" class="btn btn-sm btn-danger "> 删除所选 </a>
                        <form id="search_form" method="get" action="{% url 'users:user-list' %}" class="pull-right mail-search">
                            <div class="input-group">
                                <input type="text" class="form-control input-sm" name="keyword" placeholder="名称" value="{{ keyword }}">
                                <div class="input-group-btn">
                                    <button id='search_btn' type="submit" class="btn btn-sm btn-primary">
                                        搜索
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <table class="table table-striped table-bordered table-hover " id="editable" >
                        <thead>
                            <tr>
                                <th class="text-center">
                                    <input type="checkbox" id="check_all" onclick="checkAll('check_all', 'checked')">
                                </th>
                                <th class="text-center"><a href="{% url 'users:usergroup-list' %}?sort=name">名称</a></th>
                                <th class="text-center">用户数量</th>
                                <th class="text-center">资产数量</th>
                                <th class="text-center">描述</th>
                                <th class="text-center"></th>
                            </tr>
                        </thead>
                        <tbody>
                        {% for usergroup in usergroup_list %}
                            <tr class="gradeX">
                                <td class="text-center">
                                    <input type="checkbox" name="checked" value="{{ usergroup.id }}">
                                </td>
                                <td class="text-center">
                                    <a href="{% url 'users:usergroup-detail' pk=usergroup.id %}">
                                        {{ usergroup.name }}
                                    </a>
                                </td>
                                <td class="text-center">{{ usergroup.user_set.all|length }}</td>
                                <td class="text-center">数量</td>
                                <th class="text-center">{{ usergroup.comment|truncatewords:8 }}</th>
                                <td class="text-center">
                                    <a href="{% url 'users:usergroup-edit' pk=usergroup.id %}?id={{ user.id }}" class="btn btn-xs btn-info">编辑</a>
                                    <a href="{% url 'users:usergroup-delete' pk=usergroup.id %}?id={{ user.id }}" class="btn btn-xs btn-danger del">删除</a>
                                </td>
                            </tr>
                        {% endfor %}
                        </tbody>
                    </table>
                    {% include '_pagination.html' %}
                </div>
            </div>
        </div>
    </div>
</div>

{% endblock %}
