{% extends 'base.html' %}
{% load mytags %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-lg-12">
            <div class="ibox float-e-margins">
                <div id="ibox-content" class="ibox-title">
                    <h5> 用户权限申请详细信息列表 </h5>
                    <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="#">未启用 1</a>
                            </li>
                            <li><a href="#">未启用 2</a>
                            </li>
                        </ul>
                        <a class="close-link">
                            <i class="fa fa-times"></i>
                        </a>
                    </div>
                </div>

                <div class="ibox-content">
                    <div class="panel-options">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="/jperm/apply_show/online/" class="text-center"><i class="fa fa-laptop"></i> 未审批 </a></li>
                            <li><a href="/jperm/apply_show/offline/" class="text-center"><i class="fa fa-bar-chart-o"></i> 已审批 </a></li>
                            <li 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="search_input" name="keyword" placeholder="Search">
                                        <input type="text" style="display: none">
                                        <div class="input-group-btn">
                                            <button id='search_btn' type="button" class="btn btn-sm btn-primary" onclick="apply_search()">
                                                Search
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </li>
                        </ul>
                    </div>
                    <br/>
                    <div class="tab-content">
                        <table class="table table-striped table-bordered table-hover ">
                            <thead>
                                <tr>
                                    <th class="text-center"> 申请人 </th>
                                    <th class="text-center"> 所属部门 </th>
                                    <th class="text-center"> 申请主机组 </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 post in contacts.object_list %}
                                <tr class="gradeX">
                                    <td class="text-center" id="username"> {{ post.applyer }} </td>
                                    <td class="text-center" id="dept"> {{ post.dept }} </td>
                                    <td class="text-center" id="ip"> {{ post.bisgroup|ast_to_list }}</td>
                                    <td class="text-center" id="remote_ip"> {{ post.asset|ast_to_list }} </td>
                                    <td class="text-center" id="start_time"> {{ post.date_add|date:"Y-m-d H:i:s"}} </td>
                                    <td class="text-center" id=""> {{ post.comment }} </td>
                                    <td class="text-center" data-editable='false'>
                                        <a value="/jperm/apply_info/?uuid={{ post.uuid }}" class="iframe btn btn-xs btn-primary">详情</a>
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                        <div class="row">
                            <div class="col-sm-6">
                            </div>
                            {% include 'paginator.html' %}
                        </div>
                    </div>    
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    $(".iframe").on('click', function(){
        var url= $(this).attr("value");
        $.layer({
            type: 2,
            title: '权限申请详情',
            maxmin: true,
            shift: 'top',
            border: [2, 0.3, '#1AB394'],
            shade: [0.5, '#000000'],
            shadeClose: true,
            area : ['800px' , '600px'],
            iframe: {src: url}
        });
    });
    function apply_search(){
        $.ajax({
            type: "GET",
            url: "/jperm/apply_search/?env=online",
            data: $("#search_form").serialize(),
            success: function (data) {
                $(".tab-content").html(data);
            }
        });
    }
    $("#search_input").keydown(function(e){
        if(e.keyCode==13){
            apply_search()
            }
    })
</script>

{% endblock %}