<%@ 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>
	.hr-line-dashed {
	    background-color: #ffffff;
	    border-top: 1px dashed #e7eaec;
	    color: #ffffff;
	    height: 1px;
	    margin: 20px 0;
	}
</style>

<div class="well well-sm">
	<input type="text" class="input-sm" placeholder="开始时间" id="startDate"/>
	<input type="text" class="input-sm" placeholder="结束时间" id="endDate"/>
	&nbsp;关键字选项：<select id="keywordId">
	<option value="">请选择</option>
	<option value="1">订单号</option>
	<option value="2">交易号</option>
	<option value="3">查档地区</option>
	<option value="4">订单类型</option>
	<option value="5">发起律师姓名</option>
	<option value="6">接单律师姓名</option>
	<option value="7">发起律师手机号码</option>
	<option value="8">接单律师手机号码</option>
</select>
	<input type="text" class="input-sm" placeholder="搜索关键字" id="keyword"/>
	<input type="text" class="input-sm" placeholder="完成月份" id="finishMonth"/>
	<select class="select" id="orderState">
		<option value="" selected = "selected">状态</option>
		<option value="待接单">待接单</option>
		<option value="已取消">已取消</option>
		<option value="已确认">已确认</option>
		<option value="待查收">待查收</option>
		<option value="查档中">查档中</option>
		<option value="待配送">待配送</option>
		<option value="已完成">已完成</option>
		<option value="已过期">已过期</option>
	</select>
	<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>
</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-remark" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog">
		<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>
					<span id="modal-confirm-order-title">备注</span>
				</div>
	      	</div>
	      	<div class="modal-body" id="modal-confirm-order-body">
      			<form id="confirmOrderForm" class="form-horizontal">
      				<input type="hidden" name="orderId" id="modal-remark-orderId"/>
      				<!--
      				<input type="hidden" name="selectId" id="mod-confirm-selectId"/>
      				<input type="hidden" name="lawyerId" id="mod-confirm-lawyerId"/>
      				-->
			      	<div>
						<label for="remark-09">添加或修改备注</label>
						<textarea style="height:180px" placeholder="请输入备注信息" class="form-control limited autosize-transition" id="remark-09" maxlength="200"></textarea>
					</div>
      			</form>
	      	</div>
	      	<div class="modal-footer no-margin-top">
                <div class="text-center">
					<button id="modal-remark-confirm" 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>
	</div>
</div>

<div id="modal-confirm-order" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog">
		<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>
					<span id="modal-confirm-order-title1">确认订单</span>
				</div>
	      	</div>
	      	<div class="modal-body" id="modal-confirm-order-body1">
      			<form id="confirmOrderForm1" class="form-horizontal">
      				<input type="hidden" name="orderId" id="mod-confirm-orderId"/>
      				<input type="hidden" name="selectId" id="mod-confirm-selectId"/>
      				<input type="hidden" name="lawyerId" id="mod-confirm-lawyerId"/>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">地区律师:</label>
			      		<div class="col-sm-10 text-left">
			      			<select class="select form-control" id="mod-confirm-lawyerB" onchange="selectAreaChange(this)"></select>
			      		</div>
			      	</div>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">申请律师:</label>
			      		<div class="col-sm-10 text-left">
			      			<select class="select form-control" id="mod-confirm-lawyerBidd" onchange="selectBiddChange(this)"></select>
			      		</div>
			      	</div>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">姓名:</label>
			      		<label class="col-sm-4 control-label" id="mod-confirm-name"></label>
			      		<label class="col-sm-2 control-label">电话:</label>
			      		<label class="col-sm-4 control-label" id="mod-confirm-mobile"></label>
			      	</div>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">报价:</label>
			      		<label class="col-sm-4 control-label" id="mod-confirm-fee"></label>
			      		<label class="col-sm-2 control-label">状态:</label>
			      		<label class="col-sm-4 control-label" id="mod-confirm-state"></label>
			      	</div>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">优势:</label>
			      		<label class="col-sm-10 control-label" id="mod-confirm-odds"></label>
			      	</div>
      			</form>
	      	</div>
	      	<div class="modal-footer no-margin-top">
                <div class="text-center">
					<button id="modal-confirm-order-confirm" 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>
	</div>
</div>

<div id="modal-orderDetail" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog" style="min-width: 650px;">
		<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="max-height: 500px;overflow-y: scroll;">
	      		<div class="row">
      				<label class="col-sm-12 control-label">付款信息</label>
      			</div>
      			<br/>
	      		<div class="row">
      				<label class="col-sm-2 control-label">付款时间:</label>
      				<label class="" id="mo-payedDate"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">付款类型:</label>
      				<label class="" id="mo-costName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">付款方式:</label>
      				<label class="" id="mo-platform"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">付款单号:</label>
      				<label class="" id="mo-tradeNo"></label>
      			</div>
      			
      			<div class="hr-line-dashed"></div>
	      		<div class="row">
      				<label class="col-sm-12 control-label">基本信息</label>
      			</div>
      			<br/>
	      		<div class="row">
      				<label class="col-sm-2 control-label">创建时间:</label>
      				<label class="" id="mo-createDate"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查档类型:</label>
      				<label class="" id="mo-orderType"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查档地区:</label>
      				<label class="" id="mo-areaFullName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查档价格:</label>
      				<label class="" id="mo-price"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">过期时间:</label>
      				<label class="" id="mo-expiresDate"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">现有资料:</label>
      				<label class="col-sm-10 control-label" id="mo-cdReqInfo"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查档要求:</label>
      				<label class="col-sm-10 control-label" id="mo-textOther"></label>
      			</div>
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">发单律师信息</label>
      			</div>
      			<br/>
      			<div class="row">
      				<label class="col-sm-2 control-label">律师姓名:</label>
      				<label class="" id="mo-lawyerAName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">律师电话:</label>
      				<label class="" id="mo-phoneLawA"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">律师地址:</label>
      				<label class="" id="mo-addressLawA"></label>
      			</div>
      			
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">接单律师信息</label>
      			</div>
      			<br/>
      			<div class="row">
      				<label class="col-sm-2 control-label">律师姓名:</label>
      				<label class="" id="mo-lawyerBName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">律师电话:</label>
      				<label class="" id="mo-phoneLawB"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">律师地址:</label>
      				<label class="" id="mo-addressLawB"></label>
      			</div>
      			
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">收货人信息</label>
      			</div>
      			<br/>
      			<div class="row">
      				<label class="col-sm-2 control-label">收件人:</label>
      				<label class="" id="mo-rpName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">收件人电话:</label>
      				<label class="" id="mo-rpTel"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">收件人地址:</label>
      				<label class="" id="mo-rpAddress"></label>
      			</div>
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">配送信息</label>
      			</div>
      			<br/>
      			<div class="row">
      				<label class="col-sm-2 control-label">物流公司:</label>
      				<label class="" id="mo-lgName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">物流单号:</label>
      				<label class="" id="mo-lgNum"></label>
      			</div>
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查档结果:</label>
      				<label class="" id="mo-cdFiles"></label>
      			</div>
      			
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">评价信息</label>
      			</div>
      			<br/>
      			<div class="row">
      				<label class="col-sm-2 control-label">服务质量:</label>
      				<label class="" id="mo-value1"></label>
      				
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">出函速度:</label>
      				<label class="" id="mo-value2"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">评论内容:</label>
      				<label class="" id="mo-CommentContent"></label>
      			</div>
      			<br/>
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">其它信息</label>
      			</div>
      			<br/>
      			<div class="row">
      				<label class="col-sm-3 control-label">是否需要保证金:</label>
      				<label class="" id="mo-bzj"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-3 control-label">重新发单的原因:</label>
      				<label class="" id="mo-resendReason"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-3 control-label">后台的备注信息:</label>
      				<label class="" id="mo-remark"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查询对象:</label>
      				<label class="" id="mo-textName"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查询号码:</label>
      				<label class="" id="mo-textNumber"></label>
      			</div>
      			<div class="row">
      				<label class="col-sm-2 control-label">查询地址:</label>
      				<label class="" id="mo-textAddress"></label>
      			</div>
      			<br/>
      			<div class="hr-line-dashed"></div>
      			<div class="row">
      				<label class="col-sm-12 control-label">竞标记录</label>
      			</div>
      			<br/>
      			<div id="mo-biddrecord">
      				
      			</div>
      			<br/>
	      	</div>
		</div>
	</div>
</div>

<%@include file="/WEB-INF/page/back/auth.jsp" %>

<!-- page specific plugin scripts -->
<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", "${contextPath}/static/assets/js/lazyload/jquery.lazyload.js", null ];
	$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
    	// 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);
    			}
    		});
    		
    		$(document).keydown(function(event) {
				var key = window.event ? event.keyCode : event.which;
				if (key == 13) {
					$("#searchd").click();
				}
			});

		/*搜索框  主要对Jquery grid进行刷新 带参数刷新    */
			$("#searchd").click(function(){
				var keyword =encodeURI(encodeURI($("#keyword").val()));
				var keywordId = $("#keywordId").val();
				if(keyword && !keywordId){
					alert("请选择关键字查询选项");
					return;
				}
				var startDate =$("#startDate").val();
				var endDate =$("#endDate").val();
				var orderState =$("#orderState").val();
				var finishMonth = $("#finishMonth").val();
		    	myGrid.setGridParam({mtype:'POST',data:'json',url : '${contextPath}/cd/cdOrder/getOrders?keyword='+keyword+'&orderState='+orderState+'&startDate='+startDate+'&endDate='+endDate+'&finishMonth='+finishMonth+'&keywordId='+keywordId}).trigger('reloadGrid');
			});
			
    	    myGrid=	jQuery(grid_selector).jqGrid({
    			subGrid : false,
    			url : "${contextPath}/cd/cdOrder/getOrders",
    			datatype : "json",
    			mtype:'POST',//设置http方式为post以解决乱码问题
    			height : 450,
    			colModel : [{	
    				name : 'orderId',
    				index : 'orderId',
    				width : 120,
    				label : '订单号',
    				editable : false,
    				//sorttype : 'date'
    			},{
    				name : 'tradeNo',
    				index : 'tradeNo',
    				width : 120,
    				label : '支付单号',
    				editable : false,
    				//sorttype : 'date'
    			},{	name : 'createDate',
    				index : 'createDate',
    				width : 120,
    				label : '创建时间',
    				search : false,	
    				editable : false,
    				readonly : true,
    				//sorttype : 'date'
    			},{	name : 'payedDate',//付款时间
    				index : 'payedDate',
    				width : 120,
    				label : '付款时间',
    				search : false,	
    				editable : false,
    				readonly : true,
    				//sorttype : 'date'
    			},{	name : 'areaFullName',
    				index : 'areaFullName',
    				label : '查档地区',
    				width : 120,
    				search : false,	
    				editable : false,
    			},{	name : 'aName',
    				index : 'aName',
    				label : '发单律师',
    				width : 100,
    				editable : false
    			},{	name : 'aPhone',
    				index : 'aPhone',
    				label : '发单律师电话',
    				width : 120,
     				sortable : false,
    				editable : false
    			},{
    				name : 'bName',
    				index : 'bName',
    				label : '接单律师',
    				width : 100,
    				editable : false,
    			},{	name : 'bPhone',
    				index : 'bPhone',
    				label : '接单律师电话',
    				width : 120,
     				sortable : false,
    				editable : false
    			},{
    				name : 'orderType',
    				index : 'orderType',
    				label : '订单类型',
    				width : 100,
    				editable : false,
    				formatter:defaultOrderTypeFormat
    			},{
    				name : 'orderState',
    				index : 'orderState',
    				label : '订单状态',
    				width : 100,
    				formatter:defaultOrderStateFormat,
    				editable : true
    			}, {
    				name : 'price',
    				index : 'price',
    				label : '查档价格',
    				width : 100,
    				editable : false
    				
    			}, {
    				name : 'expiresDate',
    				index : 'expiresDate',
    				label : '过期时间',
    				width : 100,
    				editable : false
    				
    			}, {
    				name : 'finishDate',
    				index : 'finishDate',
    				label : '完成时间',
    				width : 100,
    				editable : false
    				
    			}, {
    				name : 'bzj',
    				index : 'bzj',
    				label : '保证金',
    				width : 100,
    				editable : false
    				
    			},{	name : 'areaCode',
     				index : '',
     				label : '操作',
     				width : 200,
     				editable : false,
     				search : false,
     				sortable : false,
       				fixed:true,
     				formatter : optionFormatter
    			}],
    			//scroll : 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records
    			sortname : "t.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);
    			}
    			//caption : "用户管理列表",
    			//autowidth : true,
    			/**
    			grouping : true, 
    			groupingView : { 
    				 groupField : ['name'],
    				 groupDataSorted : true,
    				 plusicon : 'fa fa-chevron-down bigger-110',
    				 minusicon : 'fa fa-chevron-up bigger-110'
    			},
    			*/
    		});
    		
    		//默认值格式化: OrderType 状态
			function defaultOrderTypeFormat(cellvalue, options, rowObject){
				switch(cellvalue){
					case 1:
						return "工商基本信息";
						break;
					case 2:
						return "工商内档信息";
						break;
					case 3:
						return "户籍信息";
						break;
					case 4:
						return "婚姻信息";
						break;
					case 5:
						return "房产信息";
						break;
					case 6:
						return "车辆信息";
						break;
					default:
						return cellvalue;
				}
			}

    		//默认值格式化: OrderState 状态
			function defaultOrderStateFormat(cellvalue, options, rowObject){
				switch(cellvalue){
					case 0:
						return "待接单";
						break;
					case 1:
						return "已取消";
						break;
					case 2:
						return "已确认";
						break;
					case 3:
						return "待查收";
						break;
					case 4:
						return "查档中";
						break;
					case 5:
						return "待配送";
						break;
					case 6:
						return "已完成";
						break;
                    case 7:
                        return "已过期";
                        break;
					default:
						return cellvalue;
				}
			}

     		function optionFormatter(cellvalue, options, cell) {
     			//添加备注按钮
     			var template = "<button data-toggle='modal' onclick='remark(\""+cell.orderId+"\")' class='btn btn-minier btn-default'>备注</button>&nbsp;|&nbsp;";

     			template += "<button data-toggle='modal' onclick='showdetail(\""+cell.orderId+"\")' class='btn btn-minier btn-grey'>详细</button>";
     			/* if(cell.orderState == 0){
     				if(checkUserDeps([dep_YFB,dep_SCB])){
         				template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='showConfirmOrder(\""+cell.orderId+"\",\""+cell.areaCode+"\",\""+cell.orderType+"\",\""+cell.lawyerAId+"\",\""+cell.lawyerBId+"\",\""+cell.orderState+"\")' class='btn btn-minier btn-info'>确认订单</button>";
     				}
     			}
     			if(cell.orderState == 1){
     				if(checkUserDeps([dep_YFB,dep_SCB])){
         				template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='showConfirmOrder(\""+cell.orderId+"\",\""+cell.areaCode+"\",\""+cell.orderType+"\",\""+cell.lawyerAId+"\",\""+cell.lawyerBId+"\",\""+cell.orderState+"\")' class='btn btn-minier btn-info'>重发订单</button>";
     				}
     			} */
     			if(cell.orderState != "已完成" && cell.orderState != "已取消"){
     				var b = true;
     					b = checkUserDeps([dep_YFB,dep_CWB]);
     					template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='disp_confirm(\""+cell.orderId+"\")' class='btn btn-minier btn-primary'>取消订单</button>";

     			}
     			return template;
     		}
     		
    		$(window).triggerHandler('resize.jqGrid');// trigger window resize to make the grid get the correct size
    		
    		// enable search/filter toolbar
    		// jQuery(grid_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
    		// jQuery(grid_selector).filterToolbar({});
    		// switch element when editing inline
    		function aceSwitch(cellvalue, options, cell) {
    			setTimeout(function() {
    				$(cell).find('input[type=checkbox]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
    			}, 0);
    		}
    		
    		// navButtons
    		jQuery(grid_selector).jqGrid('navGrid', pager_selector,  { // navbar options
    			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 : true,
    			refreshicon : 'ace-icon fa fa-refresh blue',
    			view : false,
    			viewicon : 'ace-icon fa fa-search-plus grey'
    		}, {
    			// edit record form
    			// closeAfterEdit: true,
    			// width: 700,
    			recreateForm : true,
    			beforeShowForm : function(e) {
    				var form = $(e[0]);
    				form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
    				style_edit_form(form);
    			},
				errorTextFormat: function (response) {
					var result = eval('('+response.responseText+')');
				    return result.message;
				}
    		})
    		
    		function style_edit_form(form) {
    			// form.find('input[name=statusCn]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
    			// don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
    			// .addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');

    			// update buttons classes
    			var buttons = form.next().find('.EditButton .fm-button');
    			buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();// ui-icon, s-icon
    			buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
    			buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

    			buttons = form.next().find('.navButton a');
    			buttons.find('.ui-icon').hide();
    			buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
    			buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
    		}



    

    		function beforeEditCallback(e) {
    			var form = $(e[0]);
    			form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
    			style_edit_form(form);
    		}

    		// it causes some flicker when reloading or navigating grid
    		// it may be possible to have some custom formatter to do this as the grid is being created to prevent this
    		// or go back to default browser checkbox styles for the grid
    		function styleCheckbox(table) {
    			/**
    			 * $(table).find('input:checkbox').addClass('ace') .wrap('<label />') .after('<span class="lbl align-top" />') $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
    			 * .find('input.cbox[type=checkbox]').addClass('ace') .wrap('<label />').after('<span class="lbl align-top" />');
    			 */
    		}

    		// unlike navButtons icons, action icons in rows seem to be hard-coded
    		// you can change them like this in here if you want
    		function updateActionIcons(table) {
    			/**
    			 * var replacement = { 'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue', 'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red', 'ui-icon-disk' : 'ace-icon fa fa-check green', 'ui-icon-cancel' :
    			 * 'ace-icon fa fa-times red' }; $(table).find('.ui-pg-div span.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]); })
    			 */
    		}

    		// 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();
    		});
    		
    		$('#modal-confirm-order-confirm').click(function(event) {
    			confirmOrder();
			});
    		
    		//提交备注
    		$('#modal-remark-confirm').click(function(event) {
    			confirmRemark();
			});
    		
    		$('#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"
    	    });
    		$('#finishMonth').datepicker({
    	        language: 'zh-CN',
    	        pickTime: false,
    	        todayBtn: true,
    	        autoclose: true,
    	        minView: '2',
    	        forceParse: false,
    	        format:"yyyy-mm"
    	    });    		
    	});
    });
	
	//添加备注
	remark = function(orderId,remark) {
		$("#modal-remark-orderId").val(orderId);
		//$("#remark-09").val((remark != undefined && remark!=null && remark != 'null')?remark:"");
		//从服务器拉取最新的备注信息
		$.ajax({
			url : "${contextPath}/cd/cdOrder/getRemark",
			type : 'post',
			data : {
				orderId : orderId,
			},
			dataType : 'json',
			success : function(data) {
				if(data != null && data.success){
					$("#remark-09").val(data.message);
					$("#modal-remark").modal("toggle");
					return;
				}
				alert(data.message);
			}
		});
	};

	//提交备注
	confirmRemark = function(event) {
		//console.info("confirm remark");
		$.ajax({
			url : "${contextPath}/cd/cdOrder/remark",
			type : 'post',
			data : {
				orderId : $("#modal-remark-orderId").val(),
				remark : $("#remark-09").val()
			},
			dataType : 'json',
			success : function(data) {
				if(data != null && data.success){
					$("#modal-remark").modal("toggle");
					return;
				}
				alert("保存失败");
			}
		});
	};

	var lawyersArea = {};
	var lawyersBidd = {};

	function cancelOrder(orderId) {
		$.ajax({
			dataType : "json",
			url : "${contextPath}/cd/cdOrder/cancelOrder",
			type : "post",
			data : {
				'orderId' : orderId
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if (ret.success) {
					alert('保存成功');
					myGrid.trigger("reloadGrid");
				} else {
					alert(ret.message);
				}
			}
		});
	}

	function confirmOrder() {
		if ($("#mod-confirm-lawyerB")[0].options.length > 0) {
			var id = $('#mod-confirm-lawyerId').val();
			
			var selectId = $('#mod-confirm-selectId').val();
			var lawyerId = null;
			
			$.ajax({
				dataType : "json",
				url : "${contextPath}/cd/cdOrder/confirmCdOrder",
				type : "post",
				data : {
					'orderId' : $('#mod-confirm-orderId').val(),
					'bidd' : id
				},
				complete : function(ret) {
					var ret = eval("(" + ret.responseText + ")");
					if (ret.success) {
						$("#modal-confirm-order").modal("toggle");
						alert('保存成功');
						myGrid.trigger("reloadGrid");
					} else {
						alert(ret.message);
					}
				}
			});
		} else {
			alert('没有接单律师');
		}
	}

	function confirmOrderClear() {
		var ids = [ 'mod-confirm-name', 'mod-confirm-mobile',
				'mod-confirm-fee', 'mod-confirm-state', 'mod-confirm-odds' ];
		for ( var i in ids) {
			$('#' + ids[i]).html('');
		}
		$('#mod-confirm-lawyerId').val('');
		$('#mod-confirm-selectId').val('');
	}

	function selectAreaChange(obj) {
		confirmOrderClear();
		var id = obj.value;
		if (id.length > 0) {
			$('#mod-confirm-lawyerId').val(id);
			$('#mod-confirm-selectId').val('1');
			var o = lawyersArea[id];
			$('#mod-confirm-name').html(o.name);
			$('#mod-confirm-mobile').html(o.phone);
		}
	}

	function selectBiddChange(obj) {
		confirmOrderClear();
		var id = obj.value;
		if (id.length > 0) {
			$('#mod-confirm-lawyerId').val(id);
			$('#mod-confirm-selectId').val('2');
			var o = lawyersBidd[id];
			$('#mod-confirm-name').html(o.lawyer_name);
			$('#mod-confirm-mobile').html(o.mobile);
			$('#mod-confirm-fee').html(o.fee);
			$('#mod-confirm-state').html(o.state);
			$('#mod-confirm-odds').html(o.odds);
		}
	}

	function showdetail(id) {
		var array = [ 'mo-textName', 'mo-textAddress', 'mo-textNumber' ];
		var key = '';
		for ( var i in array) {
			key = array[i];
			$('#' + key + '-div').hide();

			$('#' + key + '-line').hide();
		}
		$
				.ajax({
					dataType : "json",
					url : "${contextPath}/cd/cdOrder/getOrderDetail",
					type : "post",
					data : {
						'orderId' : id
					},
					complete : function(ret) {
						var res = eval("(" + ret.responseText + ")");
						if (res.success) {
							var keys = {
								"mo-createDate" : "createDate",
								"mo-orderType" : "orderType",
								"mo-areaFullName" : "areaFullName",
								"mo-price" : "price",
								"mo-expiresDate" : "expiresDate",
								"mo-cdReqInfo" : "cdReqInfo",
								"mo-textOther" : "textOther",
								"mo-rpName" : "rpName",
								"mo-rpTel" : "rpTel",
								"mo-rpAddress" : "rpAddress",
								"mo-CommentContent" : "CommentContent",
								"mo-value1" : "value1",
								"mo-value2" : "value2",
								"mo-lgName" : "lgName",
								"mo-lgNum" : "lgNum",
								"mo-lawyerAName" : "lawyerAName",
								"mo-phoneLawA" : "phoneLawA",
								"mo-addressLawA" : "addressLawA",
								"mo-lawyerBName" : "lawyerBName",
								"mo-phoneLawB" : "phoneLawB",
								"mo-addressLawB" : "addressLawB",
								"mo-bzj" : "bzj",
								"mo-resendReason" : "resendReason",
								"mo-remark" : "remark",
								"mo-textName" : "textName",
								"mo-textAddress" : "textAddress",
								"mo-textNumber" : "textNumber",
								"mo-payedDate" : "payedDate",
				      			"mo-tradeNo" : "tradeNo",
				      			"mo-platform" : "platform",
				      			"mo-costName" : "costName",
							};
							for ( var key in keys) {
								$("#" + key).html(res[keys[key]]);
							}
							
							var divObj = $('#mo-cdFiles');
							var html = '';
							var url = '${oss_bucket_ssdb_url}';
							var thum = '${oss_bucket_ssdb_url_img}';
							var size = '${oss_bucket_ssdb_url_img_size}';
							for(var m in res.attachRs){
								oa = res.attachRs[m];
								html +='<a href="' + oa.path + '" target="_blank">';
								html += '<img class="lazy" src="${contextPath}/static/img/loading.gif" data-original="' + oa.pathSL + size + '" height="100" width="100">';
								html +='</a>&nbsp;';
							}
							
							divObj.html(html);
							
							var divObj2 = $('#mo-biddrecord');
							var html2="";
							for(var i in res.biddBean){
								var lawyer = res.biddBean[i];
								html2 += '<div class="row">';
								html2 += '	<label class="col-sm-2 control-label">竞标状态:</label>';
								html2 += '	<label class="">'+lawyer.state+'</label>';
								html2 += '</div>';
								html2 += '<div class="row">';
								html2 += '	<label class="col-sm-2 control-label">竞标律师:</label>';
								html2 += '	<label class="">'+lawyer.lawyerName+'</label>';
								html2 += '</div>';
								html2 += '<div class="row">';
								html2 += '	<label class="col-sm-2 control-label">联系电话:</label>';
								html2 += '	<label class="">'+lawyer.mobile+'</label>';
								html2 += '</div>';
								html2 += '<div class="row">';
								html2 += '	<label class="col-sm-2 control-label">完成时间:</label>';
								html2 += '	<label class="">'+lawyer.takeTime+'</label>';
								html2 += '</div>';
								html2 += '<div class="row">';
								html2 += '	<label class="col-sm-2 control-label">竞标优势:</label>';
								html2 += '	<label class="col-sm-10 control-label">'+lawyer.odds+'</label>';
								html2 += '</div>';
							}
							divObj2.html(html2);
							
							$("#modal-orderDetail").modal("toggle");
							setTimeout(function() {
								$("img.lazy").lazyload({
									threshold : 200
								});
							}, 200);
						} else {
							alert(res.message);
						}
					}
				});
	}
	
	function disp_confirm(orderId) {
	  var r = confirm("确定取消订单？")
	  if (r==true) {
		  cancelOrder(orderId);
	  }
	}

	function showConfirmOrder(orderId, areaCode, orderType, lawyerAId,
			lawyerBId, orderState) {
		$('#mod-confirm-orderId').val(orderId);
		$('#mod-confirm-lawyerB').empty();
		$('#mod-confirm-lawyerBidd').empty();
		confirmOrderClear();
		lawyersArea = {};
		lawyersBidd = {};
		$.ajax({
			dataType : "json",
			url : "${contextPath}/cd/cdOrder/getLawyersByAreaCode",
			type : "post",
			data : {
				'areaCode' : areaCode,
				'orderType' : orderType,
				'lawyerAId' : lawyerAId,
				'lawyerBId' : lawyerBId,
				'orderId' : orderId
			},
			complete : function(ret) {
				var res = eval("(" + ret.responseText + ")");
				if (res.success) {
					var select = $('#mod-confirm-lawyerB');
					var lawyer = null;
					select.append("<option value=''></option>");
					for ( var i in res.lawyers) {
						lawyer = res.lawyers[i];
						select.append("<option value='" + lawyer.id + "'>"
								+ lawyer.name + "</option>");
						lawyersArea[lawyer.id] = lawyer;
					}
					select = $('#mod-confirm-lawyerBidd');
					select.append("<option value=''></option>");
					for ( var i in res.lawyerBidds) {
						lawyer = res.lawyerBidds[i];
						select.append("<option value='" + lawyer.id + "'>"
								+ lawyer.lawyer_name + "</option>");
						lawyersBidd[lawyer.id] = lawyer;
					}
					var title = '确认订单';
					if ('1' == orderState) {
						title = '重发订单';
					}
					$('#modal-confirm-order-title').html(title);
					$("#modal-confirm-order").modal("toggle");
				} else {
					alert(res.message);
				}
			}
		});
	}
</script>