<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/common/taglibs.jspf"%>
<div class="modal-dialog" style="width: 860px;"><!-- BEGIN modal-dialog -->
     <div class="modal-content"><!-- BEGIN modal-content -->
         <div class="modal-header">
             <button type="button" class="close" data-dismiss="modal">&times;</button>
             <h4 class="modal-title">查看用户</h4>
         </div>
         	<div class="modal-body">
         		<div class="row form-group">
                        <!-- Tabs within a box -->
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="#revenue-chart" data-toggle="tab">用户信息</a></li>
                            <li><a href="#sales-chart" data-toggle="tab">公司信息</a></li>
                            <li><a href="#sales-charts" data-toggle="tab">证照信息</a></li>
                            <c:if test="${ user.userType eq '10' ||  user.userType eq '20'}">
                           	<c:if test="${user.accountType eq '主账号' || user.accountType eq '系统管理员'}">
                           		<li><a id="childAccountHrefId" href="#child_account_info_id" data-toggle="tab">子账号信息</a></li>
                           		</c:if>
                            </c:if>
                        </ul>
                        <div class="tab-content no-padding">
                        	<!-- 当前需要查看选中的用户信息id -->
                        	<input type="hidden" id="currSelectUserId" value="${user.userId}">
                            <!-- Morris chart - Sales -->
                            <div class="chart tab-pane active" id="revenue-chart" style="position: relative;">
                            	<div class="row form-group"></div>
                            	<div class="row form-group" style="height: 20px;">
	                                <div class="col-sm-3">
										<label class="span">用户名称</label>
									</div>
									<div class="col-sm-7">
				                    	<span>${user.userName}</span>
				                     </div>
			                     </div>
			                     <div class="row form-group"  style="height: 20px;">
				                     <div class="col-sm-3">
										<label class="span">登录名称</label>
									</div>
									<div class="col-sm-7">
	                       				<span>${user.loginName}</span>
	                     			</div>
                     			</div>
                     			<div class="row form-group"  style="height: 20px;">
	                     			<div class="col-sm-3">
										<label class="span">证件类型</label>
									</div>
									<div class="col-sm-7">
                            			<c:forEach items="${certTypeMap}" var="map">
											<c:if test="${map.key eq user.certType}">
												<span>${map.value}</span>
											</c:if>
										</c:forEach>
	                     			</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
                     				<div class="col-sm-3">
										<label class="span">证件号码</label>
									</div>
									<div class="col-sm-7">
                       					<span>${user.certNo }</span>
                     				</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">用户类型</label>
									</div>
									<div class="col-sm-7">
		                            	<c:forEach items="${userTypeMap}" var="typeMap">
											<c:if test="${typeMap.key eq user.userType}">
												<span>${typeMap.value}</span>
											</c:if>
										</c:forEach>
			                     	</div>
								</div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">用户角色</label>
									</div>
									<div class="col-sm-7">
										<c:forEach items="${roleList}" var="roleList">
								    		<c:if test="${roleList.roleId eq role.roleId}">
								    			<span>${roleList.roleName}</span>
											</c:if>
										</c:forEach>
			                     	</div>
								</div>

								<div class="row form-group" style="height: 20px;">
				                     <div class="col-sm-3">
										<label class="span">主账号</label>
									</div>
									<div class="col-sm-7">
	                       				<span>${parentSysUser.loginName}</span>
	                       				<input type="hidden" id="hiddenParentId" name="parentId" value="${parentSysUser.userId}"/>
	                     			</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
                     				<div class="col-sm-3">
										<label class="span">电话</label>
									</div>
									<div class="col-sm-7">
                    					<span>${user.mobile }</span>
                   					</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
                     				<div class="col-sm-3">
										<label class="span">邮箱</label>
									</div>
									<div class="col-sm-7">
                       					<span>${user.email }</span>
                     				</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
                     				<div class="col-sm-3">
										<label class="span">性别</label>
									</div>
									<div class="col-sm-7">
		                            	<c:forEach items="${sexMap}" var="sexMap">
											<c:if test="${sexMap.key eq user.sex}">
												<span>${sexMap.value}</span>
											</c:if>
										</c:forEach>
			                     	</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
                     				<div class="col-sm-3">
										<label class="span">生日</label>
									</div>
									<div class="col-sm-7">
                       					<span>${user.birthday }</span>
                     				</div>
                     			</div>
                     			<div class="row form-group" style="height: 20px;">
                     				<div class="col-sm-3">
										<label class="span">职位</label>
									</div>
									<div class="col-sm-7">
                       					<span>${user.userPosition }</span>
                     				</div>
                     			</div>

                            </div>
                            <div class="chart tab-pane" id="sales-chart" style="position: relative;">
								<div class="row form-group"></div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">公司名称</label>
									</div>
									<div class="col-sm-7">
			                       		<span>${user.companyName }</span>
			                     	</div>
								</div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">公司电话</label>
									</div>
									<div class="col-sm-7">
			                       		<span>${user.companyPhome }</span>
			                     	</div>
								</div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">公司网址</label>
									</div>
									<div class="col-sm-7">
			                       		<span>${user.website }</span>
			                     	</div>
								</div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">公司地址</label>
									</div>
									<div class="col-sm-7">
			                       		<span>${user.address}</span>
			                     	</div>
								</div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">所属企业ID</label>
									</div>
									<div class="col-sm-7">
			                       		<span>${user.companyId }</span>
			                     	</div>
								</div>
								<div class="row form-group" style="height: 20px;">
									<div class="col-sm-3">
										<label class="span">所属企业</label>
									</div>
									<div class="col-sm-7">
			                       		<span>${connectedCompanyName}</span>
			                     	</div>
								</div>
                            </div>
                            <div class="chart tab-pane" id="sales-charts" style="position: relative;">
                            	<div class="row form-group"></div>
                            	<div class="row form-group" style="height: 20px;">
                            		<div class="col-sm-2"><label class="span">营业执照</label></div>
                            		<div class="col-sm-10">
										<div class="controls">
											<input type="hidden" name="icon" id="businessLicenses_icon" value="<c:if test="${not empty user.businessLicense}">${user.businessLicense }</c:if>">
											<div id="businessLicense_view">
												<c:if test="${not empty user.businessLicense}">
													<img style="margin-left: 0px;margin-top: 10px;" width='600px' height='400px' src="attach/image.do?attachmentId=${user.businessLicense }">
												</c:if>
											</div>
										</div>
			            			</div>
                            	</div>
                            	<div class="row form-group" style="height: 20px;">
                            		<div class="col-sm-2"><label class="span">组织机构代码证</label></div>
                            		<div class="col-sm-10">
										<div class="controls">
											<input type="hidden" name="icon" id="orgCodes_icon" value="<c:if test="${not empty user.orgCode}">${user.orgCode}</c:if>">
											<div id="orgCode_view">
												<c:if test="${not empty user.orgCode}">
												<img style="margin-left: 0px;margin-top: 10px;" width='600px' height='400px' src="attach/image.do?attachmentId=${user.orgCode}">
												</c:if>
											</div>
										</div>
			            			</div>
                            	</div>
                            </div>
                            <c:if test="${ user.userType eq '10' ||  user.userType eq '20'}">
                            	<c:if test="${user.accountType eq '主账号' || user.accountType eq '系统管理员'}">
                            		<div class="chart tab-pane" id="child_account_info_id" style="position: relative;">
		                          		<div class="">
			                             	<table class="table table-bordered table-striped" id="childAccountTableId" style="width:100%;">
								            	<thead>
								                	<tr>
								                		<th class="col-sm-1"><input id="allChildAccountIds" name="all" type="checkbox">全选</th>
								                    	<th>姓名</th>
								                    	<th>性别</th>
								                        <th>生日</th>
								                        <th>职位</th>
								                        <th>邮箱</th>
								                        <th>手机</th>
								                        <th>证件类型</th>
								                        <th>证件号码</th>
								                       	<!-- <th>操作</th> -->
								                    </tr>
								                </thead>
								                <tbody>
								                </tbody>
							             	</table>
					             	    </div>
						    		</div>
                            	</c:if>
                            </c:if>
                     </div>
                 </div>
             </div>
            <div class="modal-footer clearfix">
                <button type="button" class="btn btn-danger" data-dismiss="modal"><i class="fa fa-times"></i>取消</button>
            </div>
     </div><!-- END modal-content -->
</div><!-- END modal-dialog -->
<script type="text/javascript">
$(function() {
   /**
    *点击子账号信息触发事件查询当前主账号下的所有子账号
    */
    var childAccountsTable = null;
	if (childAccountsTable) {
		var data=[];//存放json类型的查询条件，可以放多个
       	data.push({ "name": "userId", "value": $("#currSelectUserId").val()});
       	//Ajax重新load控件数据
       	drawTable(childAccountsTable,data);
	} else {
		/*
	     *通过主账号id加载它所有的子账号
	     */
	     childAccountsTable = $('#childAccountTableId').platformDataTable({
			"sAjaxSource" : 'system/user/loadChildAccountsList.do?'+ new Date().getTime(),
			"iDisplayStart" : 0,
			"iDisplayLength" : 10,//每页显示6条记录
			"fnServerParams": function (aoData ) {
				aoData.push({ "name":"userId","value": $("#currSelectUserId").val()});
			},
			"bSort":false,//关闭排序
			"bAutoWidth":true, //列的宽度会根据table的宽度自适应 
			"aoColumns" : [ //列
			    {"sClass" : "center","mDataProp" : "","bSearchable" : false,
				"fnRender" : function(obj) {
					return '<input name="userIds" value="' + obj.aData.userId + '" type="checkbox" >';
					}
				},
				{"sClass" : "center", "mDataProp" : "userName"},
				//性别
				{"sClass" : "center", "mDataProp" : "sex", "fnRender" : function (data) {
					if (data.aData.sex == '10') {
						return '男';
					} else if (data.aData.sex == '20') {
						return '女';
					} else {
						return '其他';
					}
				}},
				//生日
				{"sClass" : "center", "mDataProp" : "birthday"},
				//职位
				{"sClass" : "center", "mDataProp" : "userPosition"},
				//邮箱
				{"sClass" : "center", "mDataProp" : "email"},
				//手机
				{"sClass" : "center", "mDataProp" : "mobile"},
				//证件类型
				{"sClass" : "center", "mDataProp" : "certType", "fnRender" : function (data) {
					if (data.aData.certType == '10') {
						return '身份证';
					} 
				}},
				//证件号码
				{"sClass" : "center", "mDataProp" : "certNo"}]
		});
	}
});
</script>