{% extends 'base.html' %}
{% load common_tags %}
{% load users_tags %}
{% load static %}

{% block custom_head_css_js %}
    <link href="{% static "css/plugins/select2/select2.min.css" %}" rel="stylesheet">
    <script src="{% static "js/plugins/select2/select2.full.min.js" %}"></script>
{% endblock %}
{% 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-content">#}
                    <div class="panel-options">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="" class="text-center"><i class="fa fa-laptop"></i> 用户信息 </a>
                            </li>
                            <li><a href="" class="text-center"><i class="fa fa-bar-chart-o"></i> 用户资产</a></li>
                            <li><a href="" class="text-center"><i class="fa fa-bar-chart-o"></i> 登录记录 </a></li>
                            <div class="" style="float: right">
                                <form id="search_form" method="get" action="" class="pull-right mail-search">
                                    <div class="input-group">
                                        <input type="text" class="form-control input-sm" id="keyword" name="keyword"
                                               value="{{ keyword }}" placeholder="Search">
                                        <div class="input-group-btn">
                                            <button id='search_btn' type="submit" class="btn btn-sm btn-primary">
                                                搜索
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </ul>
                    </div>
                    <div class="tab-content">
                        <div class="col-sm-7" style="padding-left: 0px;">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title">
                                    <span class="label"><b>{{ user.name }}</b></span>
                                    <div class="ibox-tools">
                                        <a class="collapse-link">
                                            <i class="fa fa-chevron-up"></i>
                                        </a>
                                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                                            <i class="fa fa-wrench"></i>
                                        </a>
                                        <ul class="dropdown-menu dropdown-user">
                                            <li><a href="#"></a>
                                            </li>
                                            <li><a href="#"></a>
                                            </li>
                                        </ul>
                                        <a class="close-link">
                                            <i class="fa fa-times"></i>
                                        </a>
                                    </div>
                                </div>
                                <div class="ibox-content">
                                    <table class="table">
                                        <tbody>
                                        <tr>
                                            <td colspan="2">
                                                <img src="{{ user | user_avatar_url }}" class="img-circle" width="64"
                                                     height="64">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td width="20%">姓名:</td>
                                            <td><b>{{ user.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>用户名:</td>
                                            <td><b>{{ user.username }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>邮件:</td>
                                            <td><b>{{ user.email }}</b></td>
                                        </tr>
                                        {% if user.phone %}
                                            <tr>
                                                <td>手机:</td>
                                                <td><b>{{ user.phone }}</b></td>
                                            </tr>
                                        {% endif %}
                                        {% if user.wechat %}
                                            <tr>
                                                <td>微信:</td>
                                                <td><b>{{ user.wechat }}</b></td>
                                            </tr>
                                        {% endif %}
                                        <tr>
                                            <td>角色:</td>
                                            <td><b>{{ user.role.name }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>有效期:</td>
                                            <td><b>{{ user.date_expired|date:"Y-m-j H:i:s" }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>创建者:</td>
                                            <td><b>{{ user.created_by }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>创建日期:</td>
                                            <td><b>{{ user.date_joined|date:"Y-m-j H:i:s" }}</b></td>
                                        </tr>
                                        <tr>
                                            <td>最后登录:</td>
                                            <td><b>{{ user.last_login|date:"Y-m-j H:i:s" }}</b></td>
                                        </tr>
                                        <tr>
                                            <td class="no-borders">描述:</td>
                                            <td class="no-borders"><b>{{ user.comment }}</b></td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-5" style="padding-left: 0px;">
                            <div class="ibox float-e-margins">
                                <div class="ibox-title " style="background: #1ab394">
                                    <span style="color: white">快速修改</span>
                                    <div class="ibox-tools">
                                    </div>
                                </div>
                                <div class="ibox-content primary-panel">
                                    <table class="table">
                                        <tbody>
                                        <tr>
                                            <td width="50%">Active:</td>
                                            <td><span style="float: right">
                                                <div class="switch">
                                                    <div class="onoffswitch">
                                                        <input type="checkbox" checked class="onoffswitch-checkbox"
                                                               id="example1">
                                                        <label class="onoffswitch-label" for="example1">
                                                            <span class="onoffswitch-inner"></span>
                                                            <span class="onoffswitch-switch"></span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </span></td>
                                        </tr>
                                        <tr>
                                            <td>二次验证:</td>
                                            <td><span style="float: right">
                                                <div class="switch">
                                                    <div class="onoffswitch">
                                                        <input type="checkbox" class="onoffswitch-checkbox"
                                                               id="example2">
                                                        <label class="onoffswitch-label" for="example2">
                                                            <span class="onoffswitch-inner"></span>
                                                            <span class="onoffswitch-switch"></span>
                                                        </label>
                                                    </div>
                                                </div>
                                            </span></td>
                                        </tr>
                                        <tr>
                                            <td>重置密码:</td>
                                            <td>
                                                <span style="float: right">
                                                    <button type="button" class="btn btn-primary btn-xs" style="width: 54px">重置</button>
                                                </span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="no-borders">重置密钥:</td>
                                            <td class="no-borders">
                                                <span style="float: right">
                                                    <button type="button" class="btn btn-primary btn-xs" style="width: 54px;">重置</button>
                                                </span>
                                            </td>
                                        </tr>
                                        </tbody>
                                    </table>
                                </div>
                            </div>

                            <div class="ibox float-e-margins">
                                <div class="ibox-title bg-primary" style="background: #1ab394">
                                    <span style="color: white">用户组</span>
                                    <div class="ibox-tools">
                                    </div>
                                </div>
                                <div class="ibox-content primary-panel">
                                    <table class="table">
                                        <tbody>
                                        <form>
                                            <tr>
                                                <td colspan="2" class="no-borders">
                                                    <select data-placeholder="选择用户组" class="select2" style="width: 100%" multiple="" tabindex="4">
                                                        {% for group in groups %}
                                                        <option value="{{ group.id }}">{{ group.name }}</option>
                                                        {% endfor %}
                                                    </select>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td colspan="2" class="no-borders">
                                                    <button type="button" class="btn btn-primary btn-small">添加到用户组</button>
                                                </td>
                                            </tr>
                                        </form>

                                        {% for group in user.groups.all %}
                                        <tr>
                                            <td ><b>{{ group.name }}</b></td>
                                            <td>
                                                <button class="btn btn-danger btn-sm" type="button" style="float: right;"><i class="fa fa-minus"></i></button>
                                            </td>
                                        </tr>
                                        {% endfor %}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

{% endblock %}
{% block custom_foot_js %}
    <script>
        $(document).ready(function () {
            $('.select2').select2();
        })
    </script>
{% endblock %}