<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>企业信息管理</title>
<meta
	content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
	name='viewport'>
<link href="<c:url value='/scripts/lib/layui/layui.css'/>" rel="stylesheet" type="text/css" />
<!-- bootstrap 3.0.2 -->
<link href="<c:url value='/styles/lib/bootstrap.min.css'/>"
	rel="stylesheet" type="text/css" />
<!-- font Awesome -->
<link href="<c:url value='/styles/lib/font-awesome.min.css'/>"
	rel="stylesheet" type="text/css" />
<!-- Ionicons -->
<link href="<c:url value='/styles/lib/ionicons.min.css' />"
	rel="stylesheet" type="text/css" />
<!-- DATA TABLES -->
<link href="<c:url value='/styles/lib/datatables/dataTables.bootstrap.css' />"
	rel="stylesheet" type="text/css" />
<!-- Theme style -->
<link href="<c:url value='/styles/AdminLTE.css'/>" rel="stylesheet" type="text/css" />
<link href="<c:url value='/scripts/zTree/css/zTreeStyle/zTreeStyle.css'/>" rel="stylesheet"  type="text/css" />
<link href="<c:url value='/styles/virtualArch/virtualArchForm.css'/>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<c:url value='/plugin/layer/layer.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/lib/layui/layui.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/lib/jquery-1.8.2.min.js'/>"></script>
<script type="text/javascript" src="<c:url value='/scripts/lib/template-native.js'/>"></script>
</head>
<body>
<div style="display:none;">
	非admin编辑level=2 级别下面display
    <input id="page_agent_id" value="${agentAndRange.agent_id}"/>
	<input id="vir_id" value="${agentAndRange.id}"/>
	<div>level: ${agentAndRange.level}</div>
	<div>isAdminAndProjectAdmin: ${isAdminAndProjectAdmin}</div>
	<div>isAdminAndProjectAdmin: ${agentAndRange}</div>
	<c:set var="editableRoom" scope="page" value="${empty model.id || isAdminAndProjectAdmin || (agentAndRange.level == 1 && not empty param.rangeId)}"/>
	<div>editableRoom: ${editableRoom}</div>
	<c:set var="readonlyRoom" scope="page" value="${editableRoom ? '' : 'readonly'}"/>
	<div>readonlyRoom: ${readonlyRoom}</div>
	<c:set var="disabledBuild" scope="page" value="${editableRoom ? '' : 'disabled'}"/>
	<div>disabledBuild: ${disabledBuild}</div>

	<c:set var="editableKeyInfo" scope="page" value="${!(!isAdminAndProjectAdmin && agentAndRange.level == 1 && empty param.rangeId)}"/>
	<div>editableKeyInfo: ${editableKeyInfo}</div>
	<c:set var="readonlyKeyInfo" scope="page" value="${editableKeyInfo ? '' : 'readonly'}"/>
	<div>readonlyKeyInfo: ${readonlyKeyInfo}</div>
</div>
	<input type="hidden" value="${ctx}" id="contextPath">
	<input type="hidden" value="${dealFlag}" id="dealFlag">
	<input type="hidden" value="${resultDesc}" id="resultDesc">
	<input type="hidden" id="buildId_" value="${model.buildId}">
	<input type="hidden" id="floorAndRoomList" value="${floorAndRoomList}">
	<input type="hidden" id="addFloorRoomMode" value="floor">
	<input type="hidden" id="level_" value="${agentAndRange.level}">
	<c:forEach items="${organizationList}" var="obj">
		<input type="hidden" value="${obj.address}" id="organization_${obj.id}">
	</c:forEach>
	
	<section class="content">
		<div class="row">
			<div class="box-header" style="width:92%;padding-left:20px;">
				<h3 class="box-title">企业信息管理&nbsp;&nbsp; <strong font-color="red">${errormsg}</strong></h3>
			</div>
			<form action="${ctx}/admin/virtualArch/virtualArchForm" method="post" id="conditionform">
				<input type="hidden" name="actType" value="save">
				<input type="hidden" name="virtualId" id="virtualId" value="${model.id}">
				<div class="col-md-12">
				<c:if test="${fn:length(organizationList) > 1}">
				    <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label">所属项目：</label>
				        <div class="col-sm-12">
				            <select class="form-control" name="organizationId" id="organizationId">
					            <option value="">请选择项目</option>
								<c:forEach items="${organizationList}" var="obj">
									<c:choose>
										<c:when test="${obj.id==model.organizationId}">
											<option value="${obj.id }" selected="selected">${obj.name }</option>
										</c:when>
										<c:otherwise>
											<option value="${obj.id }">${obj.name }</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
							</select>
				        </div>
				    </div>
				 </c:if>
				 <c:if test="${fn:length(organizationList) == 1}">
					<c:forEach items="${organizationList}" var="obj">
						<input type="hidden" id="organizationId" name="organizationId"  value="${obj.id }"/>
					</c:forEach>
				</c:if>
				<c:if test="${fn:length(buildList) == 1}">
					<div class="form-group clearfloat">
						<label class="col-sm-3 control-label">所属楼宇：</label>
						<div class="col-sm-12">
							<select class="form-control" name="buildId" id="buildId" ${disabledBuild} >
								<!-- <option value="">请选择楼宇</option> -->
							</select>
						</div>
					</div>
				</c:if>
				<c:if test="${fn:length(buildList) > 1}">
					<div class="form-group clearfloat">
						<label class="col-sm-3 control-label">所属楼宇：</label>
						<div class="col-sm-9">
							<select class="form-control" name="buildId" id="buildId" ${disabledBuild} >
								<option value="">请选择楼宇</option>
							</select>
						</div>
					</div>
				</c:if>
				<c:if test="${editableRoom}">
				<div class="form-group clearfloat">
					<div class="col-sm-9">
						<label class="col-sm-3 control-label"><div class="btn-red add-floor-room">添加楼层房间号</div></label>
					</div>
				</div>
				</c:if>
				<div class="form-group clearfloat" style="display: none">
				        <label class="col-sm-3 control-label"></span>楼层：</label>
				        <div class="col-sm-12">
				            <input type="text" name="floorNames" id="floorNames" class="form-control" placeholder="请输入楼层" value="${model.floorNames }" >
				            <input type="hidden" name="floorIds" id="floorIds" class="form-control"  value="${model.floorIds }">
				        </div>
				    </div>
				    <div class="form-group clearfloat"  style="display: none">
				        <label class="col-sm-3 control-label"></span>房间号：</label>
				        <div class="col-sm-12">
				            <input type="text" name="roomNames" id="roomNames" class="form-control" placeholder="请输入房间号" value="${model.roomNames }" >
							<input type="hidden" name="roomIds" id="roomIds" class="form-control"  value="${model.roomIds }">
				        </div>
				    </div>
				    <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label"></span>楼层房间号：</label>
				        <div class="col-sm-12">
				            <input type="text" name="floorAndNames" id="floorAndNames" class="form-control" placeholder="请输入楼层房间号" value="${model.floorAndNames }" ${readonlyRoom}>
				        </div>
				    </div>
				    <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label"><span style="color: red">*</span>企业名称：</label>
				        <div class="col-sm-12">
				            <input type="text" name="virtualName" id="virtualName" class="form-control" placeholder="请输入企业名称" value="${model.name }" ${readonlyKeyInfo}>
				        </div>
				    </div>
				    <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label"><span style="color: red">*</span>企业地址：</label>
				        <div class="col-sm-12">
				            <input type="text" name="address" id="address" class="form-control" placeholder="请输入企业地址" value="${model.address}"  ${readonlyKeyInfo}>
				        </div>
					</div>
					<div class="form-group clearfloat">
						<label class="col-sm-3 control-label"><span style="color: red">*</span>签约时间：</label>
						<div class="col-sm-12">
							<input type="text" name="signingTime" id="signingTime" autocomplete="off"  class="form-control" value="${model.signingTime}" ${readonlyKeyInfo}>
						</div>
					</div>
					<div class="form-group clearfloat">
						<label class="col-sm-3 control-label"><span style="color: red">*</span>合同到期时间：</label>
						<div class="col-sm-12">
							<input type="text" name="contExpireTime" id="contExpireTime" autocomplete="off"  class="form-control" value="${model.contExpireTime}" ${readonlyKeyInfo}>
						</div>
					</div>


					<c:choose>
						<c:when test="${isAdminAndProjectAdmin || agentAndRange.level == 2}">

					<div class="form-group clearfloat">
							<c:choose>
								<c:when test="${isAdminAndProjectAdmin}">
						<label class="col-sm-3 control-label"><span style="color: red">*</span>级别：</label>
						<div class="col-sm-12" style="display: flex;line-height: 40px;">
							<span style="width: 30px;">普通</span>
                            <input type="radio" style="width: 20px;" name="level" id="agency1" class="form-control level-select" value="1">
							<span style="width: 30px;margin-left: 30px;">代理</span>
                            <input type="radio" style="width: 20px;" name="level" id="agency2" class="form-control level-select" value="2">
						</div>
								</c:when>
								<c:otherwise>
						<input type="hidden" name="level" value="2">
								</c:otherwise>
							</c:choose>
						<div id="agencySelectDiv" style="display: none;">

<%--							<c:if test="${fn:length(organizationList) > 1}">--%>
							    <div class="form-group clearfloat">
							        <label class="col-sm-3 control-label">代理企业：</label>
							        <div class="col-sm-12">
							            <select class="form-control" name="agent_id" id="agencySelect">
								            <option value="">请选择企业</option>
			 								<c:forEach items="${organizationList}" var="obj">
												<c:choose>
													<c:when test="${obj.id==agentAndRange.agent_id}">
														<option value="${obj.id }" selected="selected">${obj.name }</option>
													</c:when>
													<c:otherwise>
														<option value="${obj.id }">${obj.name }</option>
													</c:otherwise>
												</c:choose>
											</c:forEach>
										</select>
							        </div>
							    </div>
<%--							 </c:if>--%>

						</div>

						<div id="agencyNewDiv"  style="display: none;">
							<div class="form-group clearfloat">
								<label class="col-sm-3 control-label"></span>代理区域:</label>
								<div class="col-sm-12">
									<div id="area-names">${agentAndRange.range_name }</div>
									<input type="hidden" name="range_id" id="range_id" value="${agentAndRange.range_id }" >
							    </div>
                                <c:if test="${isAdminAndProjectAdmin}">
                                    <div class="col-sm-9">
                                        <label class="col-sm-3 control-label"><div class="btn-red add-range">添加</div></label>
                                    </div>
                                </c:if>
							</div>

							<div class="form-group clearfloat">
								<label class="col-sm-3 control-label"></span>关联企业:</label>
								<div class="col-sm-12">
									<div id="relation-name">${agentAndRange.relation_name }</div>
									<input type="hidden" name="relation_id" id="relation_id"  value="${agentAndRange.relation_id }" >
							    </div>	

							    <div class="col-sm-9">
										<label class="col-sm-3 control-label"><div class="btn-red add-relation">添加</div></label>
								</div>
					        </div>


				        </div>
					</div>
						</c:when>
						<c:otherwise>
							<div class="form-group clearfloat">
								<label class="col-sm-3 control-label">代理企业：</label>
								<div class="col-sm-12">
								<c:choose>
									<c:when test="${empty model.id && not empty param.virId}">
									<div>${param.virName }</div>
									<input type="hidden" name="agent_id" value="${param.virId }">
									</c:when>
									<c:otherwise>
									<div>${agentAndRange.agent_name }</div>
									<input type="hidden" name="agent_id" value="${agentAndRange.agent_id }">
									</c:otherwise>
								</c:choose>
									<input type="hidden" name="level" value="1">
									<input type="hidden" name="room_rangeId" id="room_rangeId" value="${param.rangeId }">
								</div>
							</div>
						</c:otherwise>
					</c:choose>
				    <!-- <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label">企业编码：</label>
				        <div class="col-sm-12">
				            <input type="text" name="codeNumber" id="codeNumber" class="form-control" placeholder="请输入企业编码" value="${model.codeNumber}" >
				        </div>
				    </div> -->
				    <%-- <div class="form-group">
				        <label class="col-sm-3 control-label"><span style="color: red">*</span>客户编号：</label>
				        <div class="col-sm-12">
				        	<c:choose>
				        		<c:when test="${empty model.id }">
				        			 <input type="text" name="customerNumber" id="customerNumber" class="form-control" placeholder="自动生成" readonly="readonly" >
				        		</c:when>
				        		<c:otherwise>
				        			 <input type="text" name="customerNumber" id="customerNumber" class="form-control" placeholder="请输入客户编号" value="${model.customerNumber}" >
				        		</c:otherwise>
				        	</c:choose>
				        </div>
				    </div> --%>
				    <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label">联系人：</label>
				        <div class="col-sm-12">
				            <input type="text" name="contacts" id="contacts" class="form-control" placeholder="请输入联系人" value="${model.contacts}" >
				        </div>
				    </div>
				    <div class="form-group clearfloat">
				        <label class="col-sm-3 control-label"><span style="color: red">*</span>联系电话：</label>
				        <div class="col-sm-12">
				            <input type="text" name="phone" id="phone" class="form-control" placeholder="请输入联系电话" value="${model.phone }" >
				        </div>
					</div>
					<div class="form-group clearfloat">
						<label class="col-sm-3 control-label"><span style="color: red">*</span>邮箱：</label>
						<div class="col-sm-12">
							<input type="text" name="email" id="email" class="form-control" placeholder="请输入邮箱" value="${model.email }" >
						</div>
					</div>
					<div class="form-group clearfloat">
						<label class="col-sm-3 control-label">企业饭卡ID：</label>
						<div class="col-sm-12">
							<input type="text" name="meal_card" id="meal_card" class="form-control" placeholder="请输入企业饭卡" value="${model.meal_card }" >
						</div>
					</div>
				   <%--  <div class="form-group">
				        <label class="col-sm-3 control-label">企业规模：</label>
				        <div class="col-sm-12">
				            <input type="text" name="employees" id="employees"  class="form-control" placeholder="请输入数字" value="${model.employees}">
				        </div>
				    </div>
				    <div class="form-group">
				        <label class="col-sm-3 control-label">客户类型：</label>
				        <div class="col-sm-12">
				            <select class="form-control" name="customerType">
				            	<c:forEach items="${vipGroup }" var="obj">
									<c:choose>
										<c:when test="${obj.itemcode==model.customerType }">
										<option value="${obj.itemcode }" selected="selected">${obj.itemname }</option>
										</c:when>
										<c:otherwise>
										<option value="${obj.itemcode }">${obj.itemname }</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
				            </select>
				        </div>
				    </div>
				    <div class="form-group">
				        <label class="col-sm-3 control-label"><span style="color: red">*</span>审核状态：</label>
				        <div class="col-sm-12">
				            <select class="form-control" name="status" id="viewStatus">
				            	<c:forEach items="${reviewStatusGroup }" var="obj">
									<c:choose>
										<c:when test="${obj.itemcode==model.status }">
										<option value="${obj.itemcode }" selected="selected">${obj.itemname }</option>
										</c:when>
										<c:otherwise>
										<option value="${obj.itemcode }">${obj.itemname }</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
				            </select>
				        </div>
				    </div>
				    <div class="form-group">
				        <label class="col-sm-3 control-label"><span style="color: red">*</span>审批说明：</label>
				        <div class="col-sm-12">
				            <textarea name="reviewRemark" id="reviewRemark" rows="3" cols="84" >${model.reviewRemark }</textarea>
				        </div>
				    </div>
				</div> --%>
				<div align="absmiddle" class="anniu" style="text-align: center;">
					<a class="btn btn-primary" href="javascript:void();" id='btn-save'>保存</a> 
					<a class="btn btn-back" href="javascript:window.close();">关闭</a>
				</div>
			</form>
		</div>
	</section>
	<script type="text/javascript" src="<c:url value='/scripts/admin/virtualArch/virtualArchForm.js'/>"></script>
</body>
</html>
