#@layout()
#define script()
<script>

    function doChangeStatus(id, status) {
        ajaxGet("#(CPATH)/admin/page/doCommentStatusChange?id=" + id + "&status=" + status)
    }

    function doDelComment(id) {
        if (confirm("确定要删除这条评论吗？删除后不可恢复")) {
            ajaxGet("#(CPATH)/admin/page/doCommentDel?id=" + id)
        }
    }


    $("#batchDel").click(function () {
        var ids = getSelectedIds();
        if (ids == "") {
            alert('您未选择任何内容');
            return
        }

        if (confirm("确定要删除选中的评论吗？删除后不可恢复")) {
            ajaxGet("#(CPATH)/admin/page/doCommentDelByIds?ids=" + ids)
        }
    })


    $("#batchAudit").click(function () {
        var ids = getSelectedIds();
        if (ids == "") {
            alert('您未选择任何内容');
            return
        }
        ajaxGet("#(CPATH)/admin/page/doCommentAuditByIds?ids=" + ids)
    })

</script>
#end

#define css()
<style>
    strong p {
        display: inline;
    }
</style>
#end

#define content()
<div class="content-wrapper">

    <section class="content-header">
        <h1>
            评论管理
            <small>Comment Management</small>
        </h1>
    </section>

    <section class="content-header text-tap">
        <a href="#(CPATH)/admin/page/comment">全部 (#(totalCount ??))</a> |
        <a href="?status=normal">已发布 (#(normalCount ??))</a> |
        <a href="?status=unaudited">待审核 (#(unauditedCount ?? 0))</a> |
        <a href="?status=trash" style="color: #a00">垃圾箱 (#(trashCount ?? 0))</a>
    </section>

    <section class="content">

        <div class="row">
            <div class="col-xs-12">
                <div class="box box-primary">
                    <div class="box-header with-border">

                        <form class="form-horizontal actionPanel" action="#(CPATH)/admin/page/comment" method="get">
                            <input type="hidden" name="status" value="#para('status')">
                            <div class="row">
                                <div class="form-group col-lg-4">
                                    <label class="col-sm-3 control-label">关键字</label>
                                    <div class="col-sm-9">
                                        <input type="text" class="form-control" name="keyword" value="#para('keyword')">
                                    </div>
                                </div>
                                <div class="form-group col-lg-8">
                                    <div class="col-sm-12">
                                        <button type="submit" class="btn btn-primary ">搜索</button>
                                        <button type="reset" class="btn btn-default">重置</button>
                                        <a class="btn"> 更多<i class="fa fa-fw fa-angle-down"></i> </a>
                                    </div>
                                </div>
                            </div>
                            <!-- /.box-body -->
                        </form>

                        <div class="row actionPanel">
                            <div class="col-xs-12">
                                <button type="button" id="batchAudit" class="btn btn-primary checkAction"> 批量审核</button>
                                <button type="button" id="batchDel" class="btn btn-default checkAction"> 批量删除</button>
                            </div>
                        </div>

                    </div>
                    <!-- /.box-header -->
                    <div class="box-body ">

                        <table class="table table-striped">
                            <tbody>
                            <tr>
                                <th style="width: 10px">
                                    <input name="dataItem" onchange="checkAll(this)" type="checkbox"/>
                                </th>
                                <th style="width: 100px">作者</th>
                                <th style="width: 40%">内容</th>
                                <th>回复至</th>
                                <th style="width: 50px"><i class="fa fa-commenting"></i></th>
                                <th style="width: 90px">发布时间</th>
                            </tr>

                            #for(comment : page.list??)
                            <tr class="jp-actiontr">
                                <td>
                                    <input class="dataItem" type="checkbox" value="#(comment.id)"/>
                                </td>
                                <td>
                                    <a href="#(comment.user.detailUrl ??)">
                                        #(comment.user.nickname ??)
                                    </a>
                                </td>
                                <td>
                                    #(comment.text ??)
                                    <strong>
                                        #if(comment.isUnaudited()) (待审核) #end
                                    </strong>
                                    <div class="jp-actionblock">
                                        <div class="jp-actionitem">
                                            <a href="#(CPATH)/admin/page/commentEdit/#(comment.id)">编辑</a> |
                                            <a href="#(CPATH)/admin/page/commentReply/#(comment.id)">回复</a> |
                                            #if(comment.isNormal())
                                            <a href="javascript:;"
                                               onclick="doChangeStatus('#(comment.id)','unaudited')">待审核</a> |
                                            #else
                                            <a href="javascript:;"
                                               onclick="doChangeStatus('#(comment.id)','normal')">审核</a> |
                                            #end
                                            <a href="javascript:;" onclick="doChangeStatus('#(comment.id)','trash')"
                                               class="red-action">垃圾箱</a> |
                                            <a href="javascript:;" onclick="doDelComment('#(comment.id)')"
                                               class="red-action">永久删除</a>
                                        </div>
                                    </div>
                                </td>
                                <td>
                                    <a href="#(comment.page.url ??)" target="_blank">
                                        #(comment.page.title ??)
                                    </a>
                                </td>
                                <td>#(comment.comment_count ??)</td>
                                <td>#date(comment.created)</td>
                            </tr>
                            #end

                            </tbody>
                        </table>
                    </div>
                    <!-- /.box-body -->
                    <div class="box-footer">
                        <div class="row">
                            <div class="col-sm-12">
                                #@_paginate()
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box -->
            </div>
        </div>

    </section>


</div>
#end
