<%@ 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 class="well well-sm">

	<input type="text" class="input-sm" placeholder="搜索关键字" id="keyword"/>
	<select class="select" id="orderState">
		<option value="">状态</option>
		<option value="20">融资中</option>
		<option value="21">融资完成</option>
		<option value="30">诉讼中</option>
		<option value="40">汇款中</option>
		<option value="50">已回款</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 -->



<!-- page specific plugin scripts -->
<script type="text/javascript">

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() {
     
     	
     	
     	
     	
     	// 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}/ssrz/ssrzInvest/getInvests",
     			datatype : "json",
     			height : '99%',
     			colModel : [  {
     				name : 'createDate',
     				label : '投资时间',
     				width : 80,
     			},{
     				name : 'lawyerName',
     				label : '姓名',
     				width : 100,
     			}, {
     				name : 'lawyerMobile',
     				label : '手机号码',
     				width : 80,
     			},{
     				name : 'orderId',
     				label : '案件编号',
     				width : 100,
     			}, {
     				name : 'orderTitle',
     				label : '案件名称',
     				width : 80,
     			}, {
     				name : 'moneyPc',
     				label : '融资金额',
     				width : 80,
     			}, {
     				name : 'money',
     				label : '投资金额',
     				width : 80,
     			}, {
     				name : 'platform',
     				label : '支付方式',
     				width : 80,
     			}, {
     				name : 'moneyTzl',
     				label : '总投资金额',
     				width : 80,
     			}, {
     				name : 'orderStateName',
     				label : '案件状态',
     				width : 60,
     			},{
     				name : 'investIncome',
     				label : '投资收入',
     				width : 80,
     			},{
     				name : 'investRat',
     				label : '投资收益率',
     				width : 80,
     			},{
     				name : 'investMonths',
     				label : '回报周期',
     				width : 80,
     			}],
     			//scroll : 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records
     			sortname : "createDate",
     			sortorder : "desc",
     			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 = "<button data-toggle='modal' onclick='showdetail(\""+cellvalue+"\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>详细</button>";
     			 template += "<shiro:hasPermission name='${ROLE_KEY}:ssdbCompany:edit'>";
     			template += "&nbsp;<button data-toggle='modal' onclick='edit(\""+cellvalue+"\",\""+cell.name+"\",\""+cell.loginName+"\",\""+cell.tel+"\",\""+cell.contact+"\",\""+cell.orderState+"\",\""+cell.commision+"\",\""+cell.commisionLawyer+"\",\""+cell.companyType+"\",\""+cell.payChannel+"\")' class='btn btn-minier btn-info'><i class='ace-icon fa fa-pencil-square-o'></i>编辑</button>";
     			if(cell.orderState==1){
     				template += "&nbsp;<button data-toggle='modal' onclick='renzhen(\""+cellvalue+"\")' class='btn btn-minier btn-success'><i class='ace-icon fa fa-check-square-o'></i>审核</button>";
     			}
     			if(cell.orderState!=0){
     				template += "&nbsp;<button data-toggle='modal' onclick='tuishen(\""+cellvalue+"\")' class='btn btn-minier btn-danger'><i class='ace-icon fa fa-ban'></i>退审</button>";
     			}
     			template += "</shiro:hasPermission>";
     			return template;
     		}
     		
     		function defaultCommision(cellvalue, options, rowObject){
				return parseInt(cellvalue*100)+"%";
			}
     		
     		function defaultCommisionLawyer(cellvalue, options, rowObject){
     			return parseInt(cellvalue*100)+"%";
			}
     		
			$("#searchd").click(function(){
				var keyword =$("#keyword").val();
				var orderState =$("#orderState").val();
				myGrid.setGridParam({postData:{'keyword':keyword,'orderState':orderState},url : '${contextPath}/ssrz/ssrzInvest/getInvests',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();
     		});
     		
     	});
     });
     

function isNotBlank(obj){
	var result = true;
	if(obj == undefined || obj == null || obj == 'null' || obj.length < 1){
		result = false;
	}
	return result;
}

</script>