<%@ 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/ui.jqgrid.css"/>

<style>
    .hr-line-dashed {
        background-color: #ffffff;
        border-top: 1px dashed #e7eaec;
        color: #ffffff;
        height: 1px;
        margin: 20px 0;
    }
</style>
<%--新增公司窗口--%>
<div id="mod-add" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog">
        <form id="AddForm">
            <div class="modal-content">
                <div class="modal-header no-padding">
                    <div class="table-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                            <span class="white">&times;</span>
                        </button>
                        新增公司
                    </div>
                </div>
                <div class="modal-body" style="overflow-y: scroll;">
                    <div id="mod-add-tip" class="red clearfix"></div>
                    <div class="form-group">
                        <label for="mod-add-name">公司全称</label>
                        <input type="text" id="mod-add-name" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-loginName">公司简称（登录名）</label>
                        <input type="text" id="mod-add-loginName" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-clearing-institution-name">结算机构名称</label>
                        <input type="text" id="mod-add-clearing-institution-name" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-loginName">公司类型</label>
                        <select class="form-control" id="mod-add-companyType">
                            <option value="1">保险公司</option>
                            <option value="0">担保公司</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-password">密码</label>
                        <input type="password" id="mod-add-password" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-password2">确认密码</label>
                        <input type="password" id="mod-add-password2" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-contact">跟单对接人姓名</label>
                        <input type="text" id="mod-add-contact" class="form-control"/>
                    </div>
                    <div class="form-group">
                        <label for="mod-add-tel">跟单对接人手机</label>
                        <input type="text" id="mod-add-tel" class="form-control"/>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-commision">平台返佣</label>
                        <div class="input-group">
                            <input type="text" id="mod-add-commision" class="form-control" value="0"/>
                            <span class="input-group-addon">%</span>
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-commisionLawyer">律师返佣</label>
                        <div class="input-group">
                            <input type="text" id="mod-add-commisionLawyer" class="form-control" value="0"/>
                            <span class="input-group-addon">%</span>
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-sort">合作排序(0表示不是战略合作)</label>
                        <input type="text" id="mod-add-sort" class="form-control" value="1"/>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-text0">战略合作公司宣传语1(不能有|符号)</label>
                        <input type="text" id="mod-add-text0" class="form-control"/>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-text1">战略合作公司宣传语2(不能有|符号)</label>
                        <input type="text" id="mod-add-text1" class="form-control"/>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-text2">战略合作公司宣传语3(不能有|符号)</label>
                        <input type="text" id="mod-add-text2" class="form-control"/>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-commisionLawyer" class="no-padding-left col-sm-2 control-label">线下支付</label>
                        <div class="col-sm-10 text-left input-group">
                            <input type="radio" name="mod-add-pay_offLine" value="1" checked="checked"/>是
                            <input type="radio" name="mod-add-pay_offLine" value="0"/>否
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-commisionLawyer" class="no-padding-left col-sm-2 control-label">微信</label>
                        <div class="col-sm-10 text-left input-group">
                            <input type="radio" name="mod-add-pay_weixin" value="1"/>是
                            <input type="radio" name="mod-add-pay_weixin" value="0" checked="checked"/>否
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-commisionLawyer" class="no-padding-left col-sm-2 control-label">支付宝</label>
                        <div class="col-sm-10 text-left input-group">
                            <input type="radio" name="mod-add-pay_alipay" value="1"/>是
                            <input type="radio" name="mod-add-pay_alipay" value="0" checked="checked"/>否
                        </div>
                    </div>
                    <div class="form-group" style="display: none">
                        <label for="mod-add-advance-div" class="no-padding-left col-sm-3 control-label">是否多问垫付保费</label>
                        <div class="col-sm-9 text-left input-group">
                            <input type="radio" name="mod-add-advance" value="1"/>是
                            <input type="radio" name="mod-add-advance" value="0" checked="checked"/>否
                        </div>
                    </div>
                    <div class="form-group" id="mod-add-containTax-div" style="display: none">
                        <label class="no-padding-left col-sm-2 control-label">是否含税</label>
                        <div class="col-sm-10 text-left">
                            <select class="select" id="mod-add-containTax">
                                <option value="0">否</option>
                                <option value="1">是</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="modal-footer no-margin-top">
                    <div class="text-center">
                        <button id="mod-add-submit" type="button" class="btn btn-sm btn-primary">
                            <i class="ace-icon fa fa-floppy-o bigger-160"></i>
                            保存
                        </button>
                        <button class="btn btn-sm" data-dismiss="modal">
                            <i class="ace-icon fa fa-share bigger-160"></i>
                            取消
                        </button>
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal-dialog -->
</div>

<div class="well well-sm">
    <select class="select" id="companyState">
        <option value="">状态</option>
        <option value="0">未提交</option>
        <option value="1">申请中</option>
        <option value="3">认证成功</option>
        <option value="2">认证失败</option>
    </select>
    <input type="text" class="input-sm" placeholder="搜索关键字" id="keyword"/>
    <button type="button" class="btn btn-purple btn-sm" id="searchd">
        <span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
        查找
    </button>
    <shiro:hasPermission name='${ROLE_KEY}:ssdbCompany:add'>
        <button type="button" class="btn btn-danger btn-sm"  onclick='add()'>
            <span class="ace-icon fa fa-edit icon-on-right bigger-110"></span>
            新增公司
        </button>
    </shiro:hasPermission>

</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="modal-table" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog" style="min-width: 920px;">
        <div class="modal-content">
            <div class="modal-header no-padding">
                <div class="table-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        <span class="white">&times;</span>
                    </button>
                    公司详情
                </div>
            </div>
            <div class="modal-body" id="modal-table-body">

            </div>
        </div>
    </div>
</div>





<!-- 阿里云OSS -->
<script type="text/javascript" src="${contextPath}/static/js/contract/promise-6.1.0.js"></script>
<script type="text/javascript" src="http://gosspublic.alicdn.com/aliyun-oss-sdk-4.3.0.min.js"></script>
<script type="text/javascript" src="${contextPath}/static/js/contract/ace.fileinput.js"></script>
<script type="text/javascript" src="${contextPath}/static/js/contract/uuid.js"></script>
<script type="text/javascript" src="${contextPath}/static/js/contract/picupload.js?v=2"></script>
<script type="text/javascript" src="${contextPath}/static/assets/js/lazyload/jquery.lazyload.js"></script>
<!-- page specific plugin scripts -->
<script type="text/javascript">
    var bucket = '${oss_bucket_b}';
    var contextPath = '${contextPath}';
    var logoUrl = '${oss_bucket_b_url}';
    var logoThum = '${oss_bucket_b_url_img}';
    var myGrid = null;
    var url_b = '${duowenapp_b}';
    var scripts = [null, "${contextPath}/static/assets/js/jqGrid/jquery.jqGrid.js", "${contextPath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js",
        "${contextPath}/static/js/contract/promise-6.1.0.js",
        "http://gosspublic.alicdn.com/aliyun-oss-sdk-4.3.0.min.js",
        "${contextPath}/static/js/contract/ace.fileinput.js",
        "${contextPath}/static/js/contract/uuid.js",
        "${contextPath}/static/js/contract/picupload.js",
        "${contextPath}/static/assets/js/lazyload/jquery.lazyload.js",
        "${contextPath}/static/js/network.js",
        null];

    var hiddenModalBody = '';
    $(function () {
        hiddenModalBody += '<div class="row">'
            + '<label class="col-sm-2 control-label">公司LOGO:</label>'
            + '<div class="col-sm-2 text-right" id="company-Logo"></div>'
            + '<label class="col-sm-2 control-label">公司宣传图:</label>'
            + '<div class="col-sm-2 text-right" id="company-Pic"></div>'
            + '<label class="col-sm-2 control-label">公司营业执照:</label>'
            + '<div class="col-sm-2 text-right" id="company-Cert"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label">保函样式:</label>'
            + '<div class="col-sm-2 text-right" id="company-Example1"></div>'
            + '<label class="col-sm-2 control-label">保单样式:</label>'
            + '<div class="col-sm-2 text-right" id="company-Example2"></div>'
            + '<label class="col-sm-2 control-label">合同/投保单:</label>'
            + '<div class="col-sm-2 text-right" id="company-Example3"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label">诉讼前申请文件:</label>'
            + '<div class="col-sm-2 text-right" id="company-SuitBefore"></div>'
            + '<label class="col-sm-2 control-label">诉讼中申请文件:</label>'
            + '<div class="col-sm-2 text-right" id="company-SuitAfter"></div>'
            + '<label class="col-sm-2 control-label">客服电话:</label>'
            + '<div class="col-sm-2 text-right" id="company-Tel"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label">公司简介:</label>'
            + '<div class="col-sm-10 text-right" id="company-Info"></div>'
            + '</div>'
            + '<div class="hr-line-dashed"></div>';
        hiddenModalBody += '<div class="row">'
            + '<div class="col-sm-12 text-left"><h5>服务承诺</h5></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label">审核承诺:</label>'
            + '<div class="col-sm-2 text-right" id="company-CheckTime"></div>'
            + '<label class="col-sm-2 control-label">确认收款承诺:</label>'
            + '<div class="col-sm-2 text-right" id="company-ConfirmTime"></div>'
            + '<label class="col-sm-2 control-label">出函承诺:</label>'
            + '<div class="col-sm-2 text-right" id="company-SendTime"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-3 control-label">发票(保单)配送方式:</label>'
            + '<div class="col-sm-3 text-right" id="company-Deliver2"></div>'
            + '<label class="col-sm-6 control-label"></label>'
            + '</div>'
            + '<div class="hr-line-dashed"></div>';
        hiddenModalBody += '<div class="row">'
            + '<div class="col-sm-12 text-left"><h5>保费比例</h5></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label no-padding-right">房产:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s101"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">银行账户类:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s102"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">土地使用权:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s103"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label no-padding-right">非上市公司股权:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s104"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">应收债权:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s105"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">车辆:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s201"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label no-padding-right">船舶:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s202"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">不易腐朽损坏货物:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s203"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">机器设备:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s204"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label no-padding-right">商标专利:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s205"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">上市公司股票:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s301"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">非固定收益基金账户:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s302"></div>'
            + '</div>'
            + '<div class="row">'
            + '<label class="col-sm-2 control-label no-padding-right">易腐朽损坏货物:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-s303"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">诉讼前折扣:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-suitBefore"></div>'
            + '<label class="col-sm-2 control-label no-padding-right">诉讼中折扣:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-suitAfter"></div>'
            + '</div>'
            + '<div class="row" id="modalBodyLastDiv">'
            + '<label class="col-sm-2 control-label no-padding-right">最低保费:</label>'
            + '<div class="col-sm-2 text-right no-padding-left" id="company-minFee"></div>'
            + '<label class="col-sm-8 control-label"></label>'
            + '</div>';
    });

    function showdetail(companyId,name) {
        var url = "home#page/ssdbCompanyDetails?companyId="+companyId+"&name="+name;
        window.open(url, "_blank");
    }


    $('#mod-sb-addButton').click(function (event) {
        $("#mod-service-sb").modal("toggle");
    });

    $('#mod-ps-addButton').click(function (event) {
        $("#mod-service-ps").modal("toggle");
    });


    function add() {
        $("#AddForm")[0].reset();
        $("#mod-add-tip").html('');
        $("#mod-add").modal("toggle");
    }


    function isNotNaturalNumber(obj) {
        var reg = /^[0-9]+$/;
        return !reg.test(obj);
    }

    function isNotNumber(obj) {
        var reg = /^(\-|\+)?\d+(\.\d+)?$/;
        return !reg.test(obj);
    }

    var scripts = [null, "${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 () {

        $("#mod-add-submit").on("click", function (e) {
            var p1 = $("#mod-add-password").val();
            var p2 = $("#mod-add-password2").val();
            if ($("#mod-add-name").val() == "") {
                alert("请输入公司全称！");
                return;
            }
            if ($("#mod-add-loginName").val() == "") {
                alert("请输入公司简称（登录名）！");
                return;
            }
            if ($("#mod-add-clearing-institution-name").val() == "") {
                alert("请输入结算机构名称！");
                return;
            }
            if (p1 == "" || p2 == "" || p1 != p2) {
                alert("请输入密码，并且密码一致！");
                return;
            }
            var texts = ['', '', ''];
            for (var i = 0; i < 3; i++) {
                texts[i] = $('#mod-add-text' + i).val();
            }
            var payChannel = "" + $("input[name='mod-add-pay_offLine']:checked").val() + $("input[name='mod-add-pay_weixin']:checked").val() + $("input[name='mod-add-pay_alipay']:checked").val();
            var sort = $('#mod-add-sort').val();
            if (isNotNaturalNumber(sort)) {
                alert('合作排序只能为自然数');
                return;
            }
            $.ajax({
                dataType: "json",
                url: "${contextPath}/sys/newSsdbCompany/add",
                type: "post",
                data: {
                    name: $("#mod-add-name").val(),
                    loginName: $("#mod-add-loginName").val(),
                    password: $("#mod-add-password").val(),
                    tel: $("#mod-add-tel").val(),
                    contact: $("#mod-add-contact").val(),
                    commision: $("#mod-add-commision").val() / 100,
                    commisionLawyer: $("#mod-add-commisionLawyer").val() / 100,
                    companyType: $("#mod-add-companyType").val(),
                    payChannel: payChannel,
                    containTax: $("#mod-add-containTax").val(),
                    advance: $("input[name='mod-add-advance']:checked").val(),
                    clearingInstitutionName: $("#mod-add-clearing-institution-name").val(),
                    sort: sort,
                    textInfo: texts.join('|')
                },
                complete: function (ret) {
                    if (ret.success) {
                        $("#mod-add").modal("toggle");
                        myGrid.trigger("reloadGrid");
                    } else {
                        alert(ret.message);
                    }
                }
            });

        });



        // inline scripts related to this page
        jQuery(function ($) {
            var grid_selector = "#grid-table";
            var pager_selector = "#grid-pager";

            // resize to fit page size
            $(window).on('resize.jqGrid', function () {
                $(grid_selector).jqGrid('setGridWidth', $(".page-content").width());
            })
            // resize on sidebar collapse/expand
            var parent_column = $(grid_selector).closest('[class*="col-"]');
            $(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
                if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
                    // setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                    setTimeout(function () {
                        $(grid_selector).jqGrid('setGridWidth', parent_column.width());
                    }, 0);
                }
            });

            myGrid = jQuery(grid_selector).jqGrid({
                subGrid: false,
                url: "${contextPath}/sys/newSsdbCompany/getCompany",
                datatype: "json",
                height: '99%',
                colModel: [
                    {
                        name: 'loginName',
                        label: '登录名',
                        width: 100,
                    },{
                    name: 'name',
                    label: '公司全称',
                    width: 200,
                },{
                        name: 'contact',
                        label: '对接人',
                        width: 100,
                    },
                    {
                    name: 'tel',
                    label: '对接人电话',
                    width: 80,
                }, {
                    name: 'checkHours',
                    label: '审核时效',
                    width: 80,
                     formatter: checkHours,
                }, {
                    name: 'sendHours',
                    label: '出函时效',
                    width: 80,
                    formatter: sendHours,
                }, {
                    name: 'companyState',
                    label: '状态',
                    width: 80,
                    formatter: defaultState,
                }, {
                        name: 'id',
                        index: '',
                        label: '操作',
                        width: 100,
                        editable: false,
                        search: false,
                        sortable: false,
                        formatter: optionFormatter
                    }],
                //scroll : 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records
                sortname: "name",
                sortorder: "asc",
                viewrecords: true,
                rowNum: 10,
                rowList: [10, 20, 30],
                pager: pager_selector,
                altRows: true,
                //toppager : true,
                //multiselect : true,
                //multikey : "ctrlKey",
                //multiboxonly : true,
                loadComplete: function () {
                    var table = this;
                    setTimeout(function () {
                        //styleCheckbox(table);
                        //updateActionIcons(table);
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                },
                //editurl : "${contextPath}/sys/ssdbCompany/saveCompany",
                //caption : "用户管理列表",
                //autowidth : true,

            });

            function optionFormatter(cellvalue, options, cell) {
                var template = "";
                template += "<shiro:hasPermission name='${ROLE_KEY}:ssdbCompany:edit'>";
                template += "&nbsp;<button data-toggle='modal'  onclick='showdetail(\""+cell.companyId+"\",\"" + cell.name + "\")' class='btn btn-minier btn-info'><i class='ace-icon fa fa-pencil-square-o'></i>查看详情</button>";
                template += "</shiro:hasPermission>";
                return template;
            }
            function checkHours(cellvalue, options, rowObject) {
               var checkDays =  rowObject.checkDays;
               var checkHours =  rowObject.checkHours;
               if(checkDays == 0){
                   return checkHours + "个工作时";
               }else{
                   return checkDays + "个工作日";
               }
            }
            function sendHours (cellvalue, options, rowObject) {
                var sendDays =  rowObject.sendDays;
                var sendHours =  rowObject.sendHours;
                if(sendDays == 0){
                    return sendHours + "个工作时";
                }else{
                    return sendDays + "个工作日";
                }
            }
            function defaultState(cellvalue, options, rowObject) {
                switch (cellvalue) {
                    case 0:
                        return "未认证";
                    case 1:
                        return "<font color='red'>" + "申请中" + "</font>";
                        break;
                    case 2:
                        return "认证失败";
                        break;
                    case 3:
                        return "认证成功";
                        break;
                    default:
                        return "错误";
                        break;
                }
            }

            function defaultCommision(cellvalue, options, rowObject) {
                return parseInt(cellvalue * 100) + "%";
            }

            function defaultCommisionLawyer(cellvalue, options, rowObject) {
                return parseInt(cellvalue * 100) + "%";
            }

            $("#searchd").click(function () {
                var keyword = encodeURI(encodeURI($("#keyword").val()));
                var companyState = $("#companyState").val();
                myGrid.setGridParam({
                    postData: {'keyword': keyword, 'companyState': companyState},
                    url: '${contextPath}/sys/newSsdbCompany/getCompany',
                    page: 1
                }).trigger('reloadGrid');
            });

            $(window).triggerHandler('resize.jqGrid');// trigger window resize to make the grid get the correct size

            jQuery(grid_selector).jqGrid('navGrid', pager_selector, {
                edit: false,
                editicon: 'ace-icon fa fa-pencil blue',
                add: false,
                addicon: 'ace-icon fa fa-plus-circle purple',
                del: false,
                delicon: 'ace-icon fa fa-trash-o red',
                search: false,
                searchicon: 'ace-icon fa fa-search orange',
                refresh: false,
                refreshicon: 'ace-icon fa fa-refresh blue',
                view: false,
            });

            // replace icons with FontAwesome icons like above
            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'
                });
            }

            // var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

            $(document).one('ajaxloadstart.page', function (e) {
                $(grid_selector).jqGrid('GridUnload');
                $('.ui-jqdialog').remove();
            });

            $("#mod-cr-addButton").on("click", function (e) {
                document.getElementById('mod-add1-form').reset();
                $('#mod-add1').modal('toggle');
            });

            $("#mod-ncr-addButton").on("click", function (e) {
                document.getElementById('mod-add2-form').reset();
                $('#mod-add2').modal('toggle');
            });

            $("#mod-add1-submit").on("click", function (e) {
                submitRateInterval();
            });

            $("#mod-add2-submit").on("click", function (e) {
                addSpecialRateInterval();
            });

            $("#modal-customRate-submit").on("click", function (e) {
                submitCustomRate();
            });

            $('#mod-cr-pcSel').change(function () {
                var v = $(this).children('option:selected').val();
                $('#mod-cr-pcInputHid').val(v);
            });
        });
    });






</script>
