<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>

<link rel="stylesheet" href="${contextPath}/static/assets/css/jquery-ui.css" />
<link rel="stylesheet" href="${contextPath}/static/assets/css/datepicker.css" />
<link rel="stylesheet" href="${contextPath}/static/assets/css/ui.jqgrid.css" />


<style>
    #MyDiv{
        display: none;
        position: absolute;
        top: 0px;
        left: 300px;
        z-index: 666;
    }
</style>

<div style="background: rgba(1,1,2,0.05)">
    <br>
    订单号:<input id="orderId" placeholder="输入订单号搜索" class="input-medium search-query" type="text"/>
    &nbsp;&nbsp;
    手机号:<input id="phone" placeholder="输入手机号搜索" class="input-medium search-query" type="text"/>
    &nbsp;&nbsp;
    筛选日期：<input type="text" class="input-sm" placeholder="开始日期"  id="startDate"/>
    <input type="text" class="input-sm" placeholder="结束日期"  id="endDate"/>
    &nbsp;<button id="searchd" type="button" class="btn" >搜索</button>
    <br>
    <br>
</div>

<div class="row">
    <div class="col-xs-12">
        <table id="grid-table"></table>
        <div id="grid-pager"></div>
        <script type="text/javascript">
            var $path_base = "${contextPath}/static";//in Ace demo this will be used for editurl parameter
        </script>
        <!-- PAGE CONTENT ENDS -->
    </div><!-- /.col -->
</div><!-- /.row -->

<div  id="MyDiv" class="modal-dialog white_content">
    <div class="modal-content">
        <div class="modal-header no-padding">
            <div class="table-header">
                <button onclick="CloseDiv()" type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <span  class="white">&times;</span>
                </button>
                查看图片
            </div>
        </div>
        <br>
        <br>
        <div id="pic">

        </div>

    </div><!-- /.modal-dialog -->
</div>





<script type="text/javascript" >

    var myGrid = null;
    var scripts = [ null,  "${contextPath}/static/assets/js/date-time/bootstrap-datepicker.js", "${contextPath}/static/assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js", "${contextPath}/static/assets/js/jqGrid/jquery.jqGrid.js", "${contextPath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js", null ]

    $('.page-content-area').ace_ajax('loadScripts', scripts, function() {
        jQuery(function ($) {

            var grid_selector = "#grid-table";
            var pager_selector = "#grid-pager";

            /*搜索框  主要对Jquery grid进行刷新 带参数刷新    */
            $("#searchd").click(function(){
                var orderId = $("#orderId").val();
                var phone = $("#phone").val();
                var startDate = $("#startDate").val();
                var endDate = $("#endDate").val();
                myGrid.setGridParam({postData:{page:1,type:1,orderId:orderId,phone:phone,startDate:startDate,endDate:endDate},
                    url : '${contextPath}/ads/vip/getAdsPersonalLegalAdviser'}).trigger('reloadGrid');
            });


            $(document).keydown(function (event) {
                var key = window.event ? event.keyCode : event.which;
                if (key == 13) {
                    $("#searchd").click();
                }
            });

            $('#startDate').datepicker({
                language: 'zh-CN',
                pickTime: false,
                todayBtn: true,
                autoclose: true,
                minView: '2',
                forceParse: false,
                format:"yyyy-mm-dd"
            });$('#endDate').datepicker({
                language: 'zh-CN',
                pickTime: false,
                todayBtn: true,
                autoclose: true,
                minView: '2',
                forceParse: false,
                format:"yyyy-mm-dd"
            });


            myGrid=	jQuery(grid_selector).jqGrid({
                subGrid : false,
                url : "${contextPath}/ads/vip/getAdsPersonalLegalAdviser",
                datatype : "json",
                postData : {type:1},
                mtype:'POST',//设置http方式为post以解决乱码问题
                colNames : ['订单号','支付方式','支付单号','用户姓名','用户手机', '服务律师','律师手机','购买金额','付款时间','操作'],
                colModel : [{
                    name : 'orderId',
                    index : 'orderId',
                    width : 200,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'paymentMethod',
                    index : 'paymentMethod',
                    width : 70,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'paymentSlipNumber',
                    index : 'paymentSlipNumber',
                    width : 70,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'userName',
                    index : 'userName',
                    width : 130,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'mobile',
                    index : 'mobile',
                    width : 70,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'realName',
                    index : 'realName',
                    width : 130,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'phone',
                    index : 'phone',
                    width : 150,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'price',
                    index : 'price',
                    width : 50,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'payDate',
                    index : 'payDate',
                    width : 120,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{	name : 'type',
                    index : 'type',
                    width : 150,
                    editable : false,
                    search : false,
                    sortable : false,
                    fixed:true,
                    formatter : optionFormatter
                }],
                sortname : "createDate",
                sortorder : "desc",
                viewrecords : true,
                rowNum : 10,
                rowList : [ 10, 20, 30 ],
                pager : pager_selector,
                altRows : true,
                height:"auto",//自动根据每页条数弹性调整表格高度
                loadComplete : function() {
                    var table = this;
                    setTimeout(function(){
                        /*styleCheckbox(table);
                        updateActionIcons(table);*/
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                }
            });

            function updatePagerIcons(table) {
                var replacement = {
                    'ui-icon-seek-first' : 'ace-icon fa fa-angle-double-left bigger-140',
                    'ui-icon-seek-prev' : 'ace-icon fa fa-angle-left bigger-140',
                    'ui-icon-seek-next' : 'ace-icon fa fa-angle-right bigger-140',
                    'ui-icon-seek-end' : 'ace-icon fa fa-angle-double-right bigger-140'
                };
                $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function() {
                    var icon = $(this);
                    var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

                    if ($class in replacement)
                        icon.attr('class', 'ui-icon ' + replacement[$class]);
                })
            }

            function enableTooltips(table) {
                $('.navtable .ui-pg-button').tooltip({
                    container : 'body'
                });
                $(table).find('.ui-pg-div').tooltip({
                    container : 'body'
                });
            };

            function optionFormatter(cellvalue, options, cell) {
                var template = "<button data-toggle='modal' onclick='showPic(\""+cell.id+"\")' class='btn btn-minier btn-default'>详细</button>";
                template +="<button data-toggle='modal' onclick='showPic(\""+cell.id+"\")' class='btn btn-minier btn-default'>退款</button>";
                template += "<button data-toggle='modal' onclick='showPic(\""+cell.id+"\")' class='btn btn-minier btn-default'>取消</button>";
                return template;
            };

        });
    });
    function showPic(id) {

    }

    function CloseDiv() {
        $("#MyDiv").hide();
    }

</script>

