<%@ 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" />

<div class="row">
	<div class="col-xs-12">
		<table id="grid-table">
				状态:
				<select id='status'>
				    <option selected value="" >全部</option>
				    <option value="-1" >未付保证金</option>
				    <option value="0" >已付保证金</option>
				    <option value="1" >待退保证金</option>
				    <option value="2" >已退保证金</option>
				</select>
				关键字:<input id="keyword" class="input-medium search-query" type="text" />
			交易时间开始日期<input type="text" class="input-sm datepick" placeholder="交易时间开始日期" id="startDate"/>
			交易时间结束日期<input type="text" class="input-sm datepick" placeholder="交易时间结束日期" id="endDate"/>
			&nbsp;
			<button id="searchd" type="button" class="btn" >搜索</button>&nbsp;
			<button type="button" class="btn btn-primary btn-sm" onclick='calcaa();' id="calc">
				计算筛选后的保证金总额
			</button>
			&nbsp;&nbsp;
			<button type="button" class="btn btn-info btn-sm" onclick='showDepositCount();' id="depositCount">
				统计保证金情况
			</button>
			<div id ="calc-result" class="bg-info" style="display:none">test</div>
		</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="mod-deposit" 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>
					已退保证金
				</div>
	      	</div>
	      	<div class="modal-body">
      			<form id="depositForm" class="form-horizontal">
      				<input type="hidden" name="id" id="mod-deposit-id"/>
			      	<div class="form-group">
			      		<label class="col-sm-2 control-label">备注:</label>
			      		<div class="col-sm-10 text-left">
			      			<textarea rows="5" id="mod-deposit-remark" class="form-control"></textarea>
			      		</div>
			      	</div>
      			</form>
	      	</div>
	      	<div class="modal-footer no-margin-top">
                <div class="text-center">
					<button id="mod-deposit-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="mod-bankInfo" 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>
					银行卡信息
				</div>
			</div>
			<div class="modal-body">
					<div class="form-group">
						<label class="col-sm-4 control-label">银行卡账号:</label>
						<p id="bankAccount"></p>
						<label class="col-sm-4 control-label">银行卡账户名:</label>
						<p id="bankAccountName"></p>
						<label class="col-sm-4 control-label">银行预留电话:</label>
						<p id="userBankPhone"></p>
						<label class="col-sm-4 control-label">银行名称:</label>
						<p id="bankName"></p>
						<label class="col-sm-4 control-label">银行简称:</label>
						<p id="bankShortName"></p>
					</div>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="mod-bankInfo-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="deposit-Info" 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>
					统计保证金退缴情况
				</div>
			</div>
			<div class="modal-body">
				<div>
					统计：<input type="text" class="input-sm datepick" placeholder="统计开始日期" id="depositStartDate"/>
					&nbsp;&nbsp;至&nbsp;&nbsp;&nbsp;<input type="text" class="input-sm datepick" placeholder="统计结束日期" id="depositEndDate"/>&nbsp;&nbsp;
					<button onclick="countDeposit()" type="button" class="btn btn-sm btn-primary">
						开始统计
					</button>
				</div>
				<br>
				<div>
					<table  border="1" id="dataTable"  style=" border-collapse:collapse;border-spacing:0; border:1px  solid  #FFFFFF;height: 220px;width: 560px">
						<tr  style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center;">
							<td> </td>
							<td   style="background: #e5efeb; text-align: center;color: black;width: 50px"></td>
							<td  style="background:#50aca2;color: #fff;border-bottom-width: 0;width: 140px;  text-align: center;">1000</td>
							<td style="background: #e5efeb; text-align: center;width: 140px;color: black">2000</td>
							<td style="background:#50aca2;color: #fff;border-bottom-width: 0;width: 140px;  text-align: center;">3000</td>
							<td   style="background: #e5efeb; text-align: center;color: black;width: 160px">共计</td>
						</tr>
						<tr >
							<td rowspan="2"  style="background:#50aca2;color: #fff;border-bottom-width: 0;width: 200px;  text-align: center; ">收到保证金</td>
							<td  style="background: #e5efeb; text-align: center;color: black;width: 100px;">数量</td>
							<td id="count_1000_a" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; "></td>
							<td id="count_2000_a" style="background: #e5efeb; text-align: center;;color: black"></td>
							<td id="count_3000_a"  style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; "></td>
							<td id="count_all_a"  style="background: #e5efeb; text-align: center;color: black;width: 160px"></td>
						</tr>
						<tr >
							<td  style="background: #e5efeb; text-align: center;color: black">金额</td>
							<td id="sum_1000_a" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; "></td>
							<td id="sum_2000_a" style="background: #e5efeb; text-align: center;color: black"></td>
							<td id="sum_3000_a" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center;"></td>
							<td id="sum_all_a"  style="background: #e5efeb; text-align: center;color: black;width: 160px"></td>
						</tr>
						<tr >
							<td rowspan="2"  style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; ">申请退保证金</td>
							<td  style="background: #e5efeb; text-align: center;color: black">数量</td>
							<td id="count_1000_b" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; "></td>
							<td id="count_2000_b" style="background: #e5efeb; text-align: center;;color: black"></td>
							<td id="count_3000_b" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; "></td>
							<td id="count_all_b"  style="background: #e5efeb; text-align: center;color: black;width: 160px"></td>
						</tr>
						<tr >
							<td  style="background: #e5efeb; text-align: center;color: black">金额</td>
							<td id="sum_1000_b" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center; "></td>
							<td id="sum_2000_b" style="background: #e5efeb; text-align: center;color: black"></td>
							<td id="sum_3000_b" style="background:#50aca2;color: #fff;border-bottom-width: 0;  text-align: center;"></td>
							<td id="sum_all_b"  style="background: #e5efeb; text-align: center;color: black;width: 160px"></td>
						</tr>
					</table>
				</div>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i>
						取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<!-- page specific plugin scripts -->
<script type="text/javascript">
	var myGrid = null;
	
	var scripts = [ null, "${contextPath}/static/assets/js/jqGrid/jquery.jqGrid.js",
		"${contextPath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js",
		"${contextPath}/static/assets/js/date-time/bootstrap-datepicker.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 status = $("#status").val();
			var startDate = $("#startDate").val();
			var endDate = $("#endDate").val();
		    	  myGrid.setGridParam({data:'json',
					  url : '${contextPath}/fs/report/getDeposit?keyword='+ keyword+
							  '&status='+status +'&stratDate='+startDate +'&endDate='+endDate }).trigger('reloadGrid');
			});

		    myGrid=	jQuery(grid_selector).jqGrid({
				subGrid : false,
				url : "${contextPath}/fs/report/getDeposit",
				datatype : "json",
    			height : '100%',
    			width : 'auto',
				colNames : ['支付单号', '支付方式', '姓名', '交易时间', '律师申请退款时间',
					'客服确认退款时间','电话', '身份证', '费用名','保证金', '状态', '备注',
					'是否显示银行卡信息','律师Id', '操作'],
				colModel : [{	name : 'tradeNo',
					index : 'tradeNo',
					width : 150,
					editable : false,
					//sorttype : 'date'
				},{	name : 'platform',
					index : 'platform',
					width : 50,
					editable : false,
					//sorttype : 'date'
				},{	name : 'lawyer_realName',
					index : 'lawyer_realName',
					width : 100,
					editable : false,
					//sorttype : 'date'
				},{ name : 'createDate', //支付时间
				  index : 'createDate',
				  width : 120,
				  editable : false,
					sorttype : 'date'
            	},{	name : 'applyDate', //律师申请退款时间
					index : 'applyDate',
					width : 120,
					editable : false,
					sorttype : 'date'
				},{  name : 'quitDate', //客服确认退款时间
				     index : 'quitDate',
				     width : 120,
				     editable : false,
				     //sorttype : 'date'
            	},{	name : 'lawyer_mobile',
					index : 'lawyer_mobile',
					width : 100,
					search : false,	
					editable : false,
					readonly : true,
					//sorttype : 'date'
				},{	name : 'lawyer_idCard',
					index : 'lawyer_idCard',
					width : 120,
					search : false,	
					editable : false,
                },{	name : 'costName',
                    index : 'costName',
                    width : 100,
                    editable : false
				},{	name : 'money',
					index : 'money',
					width : 80,
					editable : false
				},{
					name : 'lawyer_depositStatus',
					index : 'lawyer_depositStatus',
					width : 100,
					formatter:defaultStateFormat,
					editable : false
				},{
					name : 'remark',
					index : 'remark',
					width : 120,
					editable : false
				},{
					name : 'isReverse',
					index : 'isReverse',
					width : 200,
					editable : false,
					hidden : true
				},{
					name : 'lawyer_id',
					index : 'lawyer_id',
					width : 200,
					editable : false,
					hidden : true
				},{	name : 'id',
	 				index : '',
	 				label : '操作',
	 				width : 150,
	 				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 : "createDate",
				sortorder : "desc",
				viewrecords : true,
				rowNum : 100,
				rowList : [ 100, 500, 1000 ],
				pager : pager_selector,
				altRows : true,
				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'
				},
				*/
			});
	
			//默认值格式化: state 状态
			function defaultStateFormat(cellvalue, options, rowObject){
				switch(cellvalue){
					case -1:
						return "未付保证金";
						break;
					case 0:
						return "已付保证金";
						break;
					case 1:
						return "待退保证金";
						break;
					case 2:
						return "已退保证金";
						break;
					default:
						return cellvalue;
				}
			}
	
	 		function optionFormatter(cellvalue, options, cell) {
	 			var template = "";
	 			if(cell.lawyer_depositStatus == 1){
	 				template += "<button data-toggle='modal' onclick='depositModShow(\""+cell.id+"\")' class='btn btn-minier btn-info'>已退</button>";
	 			}
	 			if(cell.isReverse == 0){
	 				template +=  "&nbsp;|&nbsp;<button data-toggle='modal' onclick='showBankInfo(\""+cell.lawyer_id+"\")' 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'
				});
			};
			$('#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"
			});

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

			jQuery(grid_selector).jqGrid('navButtonAdd', pager_selector,{
				caption : "",
				title : "导出Excel",
				buttonicon : "ace-icon fa fa-file-excel-o green",
				onClickButton : function () {
					var keys = [], ii = 0, rows = "";
					var ids = $(grid_selector).getDataIDs(); // Get All IDs
					var row = $(grid_selector).getRowData(ids[0]); // Get First row to get the labels
					var label = $(grid_selector).jqGrid('getGridParam','colNames');
					for(var k in label){
						rows = rows + label[k] + "\t"; // output each Column as tab delimited
					}
					for (var k in row) {
						keys[ii++] = k; // capture col names
					}
					rows = rows + "\n"; // Output header with end of line
					var tIds = {"tradeNo":true,"platform":false,"lawyer_realName":false,"createDate":true,"applyDate":true,"quitDate":true,"lawyer_mobile":true,
						"lawyer_idCard":true,"costName":false,"money":true,"lawyer_depositStatus":false,"remark":false};
					for (var i = 0; i < ids.length; i++) {
						row = $(grid_selector).getRowData(ids[i]); // get each row
						for (var j = 0; j < keys.length; j++){
							if(tIds[keys[j]]){
								rows = rows + '="' + row[keys[j]] + '"\t'; // output each Row as tab delimited
							}else{
								rows = rows + row[keys[j]] + '\t'; // output each Row as tab delimited
							}
						}
						rows = rows + "\n"; // output each row with end of line
					}
					rows = rows + "\n"; // end of line at the end
					var form = "<form name='csvexportform' action='${contextPath}/fs/report/getExcel?fileName=deposit' method='post'>";
					form = form + "<input type='hidden' name='csvBuffer' value='" + encodeURIComponent(rows) + "'>";
					form = form + "</form><script>document.csvexportform.submit();</sc" + "ript>";
					OpenWindow = window.open('', '');
					OpenWindow.document.write(form);
					OpenWindow.document.close();
				}
			});
	
			// var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');
	
			$(document).one('ajaxloadstart.page', function(e) {
				$(grid_selector).jqGrid('GridUnload');
				$('.ui-jqdialog').remove();
			});
			
			$('#mod-deposit-confirm').click(function(event) {
				retiredDeposit();
			});
		});

	});

	function depositModShow(id){
		$('#mod-deposit-id').val(id);
		$('#mod-deposit').modal("toggle");
	}
	function showBankInfo(lawyerId){
		$("#bankAccount").html("");
		$("#bankAccountName").html("");
		$("#bankName").html("");
		$("#userBankPhone").html("");
		$("#bankShortName").html("");
		$.ajax({
			dataType : "json",
			url : "${contextPath}/fs/report/getBankInfo",
			type : "post",
			data : {
				'lawyerId' : lawyerId
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				$("#bankAccount").html(ret.bankAccount);
				$("#bankAccountName").html(ret.bankAccountName);
				$("#bankName").html(ret.bankName);
				$("#userBankPhone").html(ret.userBankPhone);
				$("#bankShortName").html(ret.bankShortName);
				$('#mod-bankInfo').modal("toggle");
			}
		});

	}
	function calcaa(){
		//订单数：100 | 总保费：100000元 | 客单价：100元 | 退保保费：1000元 |  总积分：10000 | 总标的：100000000
		var dds = $("#grid-table").getCol('platform',false,'count');
		var money = $("#grid-table").getCol('money',false,'sum');

		$("#calc-result").html("订单数："+dds+" | 保证金总额："+(money).toFixed(2) +"元" );

		if( $("#calc-result").css("display")==='none' ){
			$("#calc-result").show();
		}else{
			$("#calc-result").hide();
		}
	}

	function showDepositCount() {
		$("#depositStartDate").val("");
		$("#depositEndDate").val("");
		$("#count_1000_a").html("");
		$("#count_2000_a").html("");
		$("#count_3000_a").html("");
		$("#sum_1000_a").html("");
		$("#sum_2000_a").html("");
		$("#sum_3000_a").html("");
		$("#count_all_a").html("");
		$("#sum_all_a").html("");
		$("#count_1000_b").html("");
		$("#count_2000_b").html("");
		$("#count_3000_b").html("");
		$("#sum_1000_b").html("");
		$("#sum_2000_b").html("");
		$("#sum_3000_b").html("");
		$("#count_all_b").html("");
		$("#sum_all_b").html("");
		$('#deposit-Info').modal("toggle");
	}
	function countDeposit() {
		var  depositStartDate = $("#depositStartDate").val();
		var  depositEndDate = $("#depositEndDate").val();
		$.ajax({
			dataType : "json",
			url : "${contextPath}/fs/report/countDeposit",
			type : "post",
			data : {
				'depositStartDate' : depositStartDate,
				'depositEndDate' :depositEndDate
			},complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				$("#count_1000_a").html(ret.count_1000_a);
				$("#count_2000_a").html(ret.count_2000_a);
				$("#count_3000_a").html(ret.count_3000_a);
				$("#sum_1000_a").html(parseInt(ret.sum_1000_a));
				$("#sum_2000_a").html(parseInt(ret.sum_2000_a));
				$("#sum_3000_a").html(parseInt(ret.sum_3000_a));
				$("#count_all_a").html(parseInt(ret.count_1000_a)+ parseInt(ret.count_2000_a)+parseInt(ret.count_3000_a));
				$("#sum_all_a").html(parseInt(ret.sum_1000_a)+ parseInt(ret.sum_2000_a)+parseInt(ret.sum_3000_a));
				$("#count_1000_b").html(ret.count_1000_b);
				$("#count_2000_b").html(ret.count_2000_b);
				$("#count_3000_b").html(ret.count_3000_b);
				$("#sum_1000_b").html(parseInt(ret.sum_1000_b));
				$("#sum_2000_b").html(parseInt(ret.sum_2000_b));
				$("#sum_3000_b").html(parseInt(ret.sum_3000_b));
				$("#count_all_b").html(parseInt(ret.count_1000_b)+ parseInt(ret.count_2000_b)+parseInt(ret.count_3000_b));
				$("#sum_all_b").html(parseInt(ret.sum_1000_b)+ parseInt(ret.sum_2000_b)+parseInt(ret.sum_3000_b));
			}
		})
	}
	
	function retiredDeposit(){
		var id = $('#mod-deposit-id').val();
		var remark = $('#mod-deposit-remark').val();
		$.ajax({
			dataType : "json",
			url : "${contextPath}/fs/report/depositRetired",
			type : "post",
			data : {
				'id' : id,
				'remark' : remark
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					alert('保存成功');
					$('#mod-deposit').modal("toggle");
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});


	}

</script>