<%@ page import="com.fadu.app.util.SystemCache" %>
<%@ 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" />


<div style="background: rgba(1,1,2,0.05)">
    <br>
    筛选日期：<input type="text" class="input-sm" placeholder="开始日期"  id="startDate"/>
    <input type="text" class="input-sm" placeholder="结束日期"  id="endDate"/>

    关键字:<input id="keyword" placeholder="输入关键字" class="input-medium search-query" type="text" />
    &nbsp;支付方式：<select id="payType">
    <option selected value="">全部</option>
    <option value="1">微信</option>
    <option value="2">支付宝</option>
    <option value="3">钱包</option>
</select>
    &nbsp;支付状态：<select id="payState">
    <option selected value="">全部</option>
    <option value="1">已支付</option>
    <option value="2">待支付</option>
</select>
<%--    &nbsp;逾期情况：<select id="overdueState">
    <option selected value="">全部</option>
    <option value="1">已逾期</option>
    <option value="0">未逾期</option>
</select>--%>
    &nbsp;<button id="searchd" type="button" class="btn" >搜索</button>
    <br>
</div>

<div class="row" >
    <div class="col-xs-6" >
        <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 -->

<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 keyword = $("#keyword").val();
                var payType = $("#payType").val();
                var startDate = $("#startDate").val();
                var endDate = $("#endDate").val();
                var payState = $("#payState").val();
                var overdueState = $("#overdueState").val();
                myGrid.setGridParam({postData:{keyword:keyword,
                        startDate:startDate,
                        endDate:endDate,
                        payType:payType,
                        payState:payState,
                        overdueState:overdueState,
                        type:1,page:1},
                    url : '${contextPath}/ads/lawsuit/getAdsBiddOrder',page:1}).trigger('reloadGrid');
            });

            $('#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"
            });


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


            myGrid=	jQuery(grid_selector).jqGrid({
                subGrid : false,
                url : "${contextPath}/ads/lawsuit/getAdsBiddOrder",
                datatype : "json",
                mtype:'POST',//设置http方式为post以解决乱码问题
                colNames : ['adsBiddId','支付单号','支付时间','支付方式','钱包支付','现金支付',
                    '案件订单号',/*'律师费', '平台佣金',*/'支付状态',
                    /*'逾期状态',*/'律师','律师电话','当事人','当事人电话','逾期状态','过期时间','操作'],
                colModel : [{
                    name : 'adsBiddId',
                    index : 'adsBiddId',
                    width : 150,
                    search : false,
                    editable : false,
                    hidden : true
                    //sorttype : 'date'
                },{
                    name : 'tradeNo',
                    index : 'tradeNo',
                    width : 120,
                    search : false,
                    editable : false,
                },{
                    name : 'overdueTime',
                    index : 'overdueTime',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'payType',
                    index : 'payType',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'balancePrice',
                    index : 'balancePrice',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'priced',
                    index : 'priced',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'adsLawsuitId',
                    index : 'adsLawsuitId',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },/*{
                    name : 'cost',
                    index : 'cost',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'referralFee',
                    index : 'referralFee',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*/{
                    name : 'payState',
                    index : 'payState',
                    width : 80,
                    search : false,
                    editable : false,
                    // sorttype : 'date'
                },/*{
                    name : 'overdueState',
                    index : 'overdueState',
                    width : 80,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                },*/{
                    name : 'lawyerName',
                    index : 'lawyerName',
                    width : 90,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                },{
                    name : 'lawyerPhone',
                    index : 'lawyerPhone',
                    width : 90,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                },{
                    name : 'userName',
                    index : 'userName',
                    width : 90,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                },{
                    name : 'userPhone',
                    index : 'userPhone',
                    width : 90,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                }, {
                    name : 'overdueState',
                    index : 'overdueState',
                    width : 90,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                },{
                    name : 'overdueTime',
                    index : 'overdueTime',
                    width : 80,
                    search : false,
                    editable : false,
                    sorttype : 'date'
                },{
                    name : '',
                    index : '',
                    width : 120,
                    editable : false,
                    search : false,
                    sortable : false,
                    fixed:true,
                    formatter : optionFormatter
                }],
                sortname : "payState",
                sortorder : "asc",
                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) {
                console.log(cell);
                // var template = "<button data-toggle='modal'  onclick='showImg(\""+cell.adsBiddId+"\")' class='btn btn-minier btn-yellow'>更改律师费</button>";
                return "";
            }


        });
    });

</script>