<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="p" uri="http://www.test.com/jsp/permission" %>
<!doctype html>
<html>
<head>
	<%@ include file="../../common/head.jsp"%>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<link href="../res/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <script src="../res/js/plugins/bootstrap-table/bootstrap-table.js"></script>
    <script src="../res/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="../res/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script>
    	
    	function test(value,row,index){
//     		return '<a href="#">' + row['id'] + '</a>';
    		return '<a href="#">编辑 </a>|<a href="#">删除</a>';
    	}
    	
    	function format_action(value,row,index){
    		var returnhtml = '<a href="javascript:show('+row.id+','+row.break_id+');">查看 </a>';
    		if(row.roleCodeN==2){   
	    		if(row.apply_state != 1){
	    			returnhtml += '<a href="javascript:editApply('+row.id+','+row.break_id+');">办理</a>';
	    		}
    		}
    		return returnhtml;
     	}
    	
    	
    	function format_state(value,row,index){
    		if(row.apply_state == 1){
    			return '审批通过';
    		}else{
    			return '审批中';
    		}
    		
     	}
    	//editApply
    	function init_pwd(){
    		var data = getSelectedRow("tab_user");
    		if(null == data){
    			return;
    		}
    		
    		$.confirm("确定初始化密码吗？ ", function(){
    			$.post('initPwd.cs?id=' + data.id, 
    					function(result){
    						window.location.reload();
    						}
    			);
    		});
    	}

        function format_type(value,row,index){
    	    if(value == 0){
    	        return '平台管理员';
			}else if(value==1){
                return '机场管理员';
            }else if(value==2){
                return '航空公司管理员';
            }
        }
        $(function(){
    		$('#btnSearch').click(function () { 
    			$('#tab_user').bootstrapTable('refresh');
  	        });  
  	        
  	        $('#clearHref').click(function () { 
  	        	$('#myform')[0].reset();
 	       	}); 
    	});
    	// 分配角色
    	function setRole(){
    		var data = getSelectedRow("tab_user");
    		if(null == data){
    			return;
    		}
    		$.openDlg({
    			url:'transfer.cs?action=setRole&id=' + data.id,
    			title:'分配角色',
    			width:'100%',
    			height:'100%',
    		});
    	}
    	
    	// 查看申请表
    	function show(id,break_id){
    		$.openDlg({
    			url:'transfer.cs?action=applyView&id=' + id+"&break_id="+break_id,
    			title:'查看详情',
    			width:'95%',
    			height:'95%',
    		});
    	}	
    	
    	
    	// 办理申请终止办理
    	function editApply(id,break_id){
    		$.openDlg({
    			url:'transfer.cs?action=editApply&id=' + id+"&break_id="+break_id,
    			title:'办理',
    			width:'95%',
    			height:'95%',
    		});
    	}	
    	
    	
    	function queryParams(params){
			var page = params.offset / params.limit + 1;
			var dataObj = new Object(); 
			//alert($("#search").val());
			dataObj.name=$("#name").val();
			dataObj.orderNo=$("#orderNo").val();
			return  { page:page, 
					  pageSize:params.limit, 
					  search:JSON.stringify(dataObj), 
					  sort:params.sort,
					  order:params.order,
		};  
	} 
    	
    </script>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInUp">
    	<div class="row row-lg">
  			<div class="col-sm-12">
				<div class="ibox-content m-b-sm border-bottom">
					<div class="">
						<h4>查询条件</h4>
					</div>
					<form class="form-inline" id="myform">
						<div class="form-group">
						<label>&nbsp;客户名称：</label><input id="name" name="name" class="form-control" type="text" value="">
						<label>&nbsp;订单编号：</label><input id="orderNo" name="orderNo" class="form-control" type="text" value="">
						
						</div>
						
						&nbsp;&nbsp;
						<label><a href="#" id="btnSearch" class="btn btn-primary"><i class="icon-search"></i> 搜索</a></label>&nbsp;&nbsp;
						<label><a href="#" id="clearHref" class="btn btn-primary"><i class="icon-search"></i> 清除搜索条件</a></label>
					</form>
				</div>

                  <table id="tab_user"  
                  	   data-toggle="table"
				       data-url="applyList2.cs"
				       data-method="get"
				       data-click-to-select="true"
				       data-pagination="true"
				       data-data-type="json"
				       data-show-refresh="true"
				       data-show-columns="true"
				       data-show-toggle="true"
				       data-search-on-enter-key="true"
				       data-toolbar="#def_toolbar"  
				       data-side-pagination="server"
				       data-query-params="queryParams"
				       data-mobile-responsive="true"
						>
                      <thead>
                          <tr>
                              <th data-checkbox="true"	data-click-to-select="true"></th>
                              <th data-field="break_id" data-visible="false">id</th>
                              <th data-field="order_no">订单编号</th>                           
                              <th data-field="apply_reason">申请原因</th>                              
                              <th data-field="apply_time"  data-formatter="format_time">申请时间</th>
                              <th data-field="apply_state" data-formatter="format_state">申请状态</th>                           
                                
                              <th data-field="name">订单状态</th>
                              <th data-formatter="format_action">操作</th>
                          </tr>
                      </thead>
                  </table>	              		
             		</div>	              	
             </div>				 
    </div>
</body>
</html>
