<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html>
	<head>
		<%@include file="/WEB-INF/navigation/JsAndCss.jsp" %>
		<script src="/js/html5.js"></script>
		<script type="text/javascript" charset="utf-8" src="/js/data.js"></script>
		<script type="text/javascript" charset="utf-8" src="/js/datajs.js"></script>
		<script type="text/javascript">
		function isNull(obj){
			if(obj.value!=null&&obj.value!=""&&obj.value!=undefined){
				return true;
			}else{
				return false;
			}
		}
		function checkNull(){
			var flag = true;
			if(!isNull($('#companyName')[0])){
				alert("公司名不能为空");
				flag=false;
			}else if(!isNull($('#shorterName')[0])){
				alert("公司简称不能为空");
				flag=false;
			}else if(!isNull($('#contactName')[0])){
				alert("公司联系人不能为空");
				flag=false;
			}else if(!isNull($('#contactPhoneNumber')[0])){
				alert("公司联系电话不能为空");
				flag=false;
			}else if(!isNull($('#contactAddress')[0])){
				alert("公司地址不能为空");
				flag=false;
			}
			if(flag){
		$('#new-project')[0].submit();
			}
		}
		function getCitys(){
			var id=$("#province").val();
			
			$.post("findCityByProvinceId.do",{"provinceId":id},function(data){
				var obj = document.form.city;
				obj.length=0;
				if(data != null){
					for(var i=0;i<data.length;i++){
						obj[i]=new Option(data[i].name, data[i].id);
					}
				}
			});
			
		}
		

		function ajaxFileUpload() {  
            $.ajaxFileUpload  
        (  
            {  
                url: '/imageUp.jsp',  
                secureuri: false,  
                fileElementId: 'businesslisenseUriFile',  
                dataType: 'json',  
                beforeSend: function() {  
                    $("#loading").show();  
                },  
                complete: function() {  
                    $("#loading").hide();  
                },  
                success: function(data, status) {  
                	//alert(data.url);
                    $('#businesslisenseUri').val(data.url);
                    $('#label1').html("\(已上传图片\)");
                },  
                error: function(data, status, e) {  
                    alert(e);  
                }  
            }  
        )  
            return false;  
        }  
		</script>
	</head>
	<body>
		<div class="container">
			<div class="navbar">
				<div class="navbar-inner">
					<%@include file="../navigation/menu.jsp" %>
				</div>
			</div>
			<div class="row">
				<%@include file="../navigation/navigation.jsp" %>
				<div class="span9">
					<h1>
						编辑合作公司
					</h1>
					
					<form id="new-project" class="form-horizontal"  name="form"  action="modifyCompany.do?companyId=${company.companyId }" method="post">
						<fieldset>
						<legend></legend>
						
							<div class="control-group">
								<label class="control-label" for="companyName">公司名称</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="companyName" name="companyName" value="${company.companyName}" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="shorterName">公司简称</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="shorterName" name="shorterName" value="${company.shorterName}" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="select01">国家</label>
								<div class="controls">
									<select id="select01" name="country">
									<option value="${company.country }">中国</option>
										
									</select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="province">省市</label>
								<div class="controls">
									<select id="province" class="zzjg_sel1"  name="province" onchange="getCitys()" >
										<option value="${province.id }">${province.name }</option>
										<c:forEach items="${provinces}" var="provinces">
											<option value="${provinces.id }">${provinces.name }</option>
										</c:forEach>
										
									</select>
									<select id="city" class="zzjg_sel1" name="city"  >
										<option value="${city.id }">${city.name }</option>
										<c:forEach items="${citys }" var="citys">
											<option value="${citys.id }">${citys.name }</option>
										</c:forEach>
									</select>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="contactName">联系人</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactName" name="contactName" value="${company.contactName}" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="contactPhoneNumber">联系电话</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactPhoneNumber" name="contactPhoneNumber" value="${company.contactPhoneNumber}" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="contactAddress">公司地址</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactAddress" name="contactAddress" value="${company.contactAddress}" />
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="contactEmail">邮箱</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactEmail" name="contactEmail" value="${company.contactEmail}" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="contactFox">传真</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="contactFox" name="contactFox" value="${company.contactFox}" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="website">官方网站</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="website" name="website" value="${company.website}" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="input01">法律顾问</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="lawAdviser" value="${company.lawAdviser}" />
								</div>
							</div><div class="control-group">
								<label class="control-label" for="input01">审计事务所</label>
								<div class="controls">
									<input type="text" class="input-xlarge" id="input01" name="auditFirm" value="${company.auditFirm}" />
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="businesslicenseUri">营业执照</label>
								<div class="controls">
											<input id="businesslisenseUriFile" type="file" name="businesslisenseUriFile" class="fimg1"/>
											<input id="businesslisenseUri" type="hidden" name="businesslisenseUri" value="${company.businesslisenseUri}"/>
											<button type="button" class="btn btn-primary" onclick="return ajaxFileUpload();">上传图片</button>
											<label id="label1"><c:if test="${company.businesslisenseUri!=null }">(已上传图片)</c:if></label>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="yes">是否为合作方</label>
								<div class="controls">
									<input type="checkbox" name="isPartner" id="yes" 
									<c:if test="${company.isPartner==1}">checked</c:if>  value="1"/>
								</div>
							</div>
							<div class="control-group">
								<label class="control-label" for="textarea">公司简介</label>
								<div class="controls">
									<textarea class="input-xlarge" id="textarea" rows="3" name="companyIntroduction">${company.companyIntroduction}</textarea>
								</div>
							</div>
							<div class="form-actions">
								<button type="button" class="btn btn-primary" onclick="checkNull();">保存</button> 
								<button class="btn" type="reset" onclick="history.back()">取消</button>
							</div>
						</fieldset>
					</form>
				</div>
			</div>
		</div>
	</body>
</html>
