<%@ include file="validate.jsp" %>
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>
    <%@ page import="cn.sendsms.jdsmsserver.*"%>
    <%@ page import="cn.sendsms.otherModem.nbiot.*"%>
    <%@ page import="cn.sendsms.otherModem.common.*"%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Ιθ±ΈΧΆ²α</title>
<link href="css.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
 function goback(){
	 window.location.href="/nbiotInfoPage?action=refreshNbIoT";
 }
 function cancellDevice(){
	 var ids = document.getElementById("gatewayid").value;
	 var serialnum = document.getElementById('serialnum').value;
	 window.location.href="/nbiotInfoPage?action=cancellNbIoTDevice&ids="+ids+"&serialnum="+serialnum;
 }
 function check1(){
	
	 var serialnum = document.getElementById('serialnum').value;
	 var regcode = document.getElementById('regcode').value;
	 if(serialnum=='')
		 {
		 alert('<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_failed_to_get_imei1")%>');
		 	return false;
		 }
	
	 if(regcode==''){
		 alert('<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_input_reg_code")%>');
		 return false;
	 }
	
	 if(regcode.length!=23 && regcode.length!=28){
		 alert('<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_failure_info5")%>');
		 return false;
	 }
	return true;
	 
 }
</script>
<style type="text/css">
	input{
		height:22px;
		line-height: 15px;
	}
	.wbtn1,.wbtn2,.wbtn3,.wbtn4{margin-top:15px;width:80px !important;}
	.wbtn1,.wbtn2{
		padding:5px 10px;
		line-height: 15px;
		color:#fff;
		background:#5db3b6;
		border:1px solid #fff;
		border-radius: 5px;
		margin-right:10px;
		width:100px;
		height:auto;
	}
	.wbtn2{
		background: #ff4d4d;
	}

	.wbtn3{
		padding:5px 10px;
		line-height: 15px;
		border:1px solid #9cc0c1;
		background: #fff;
		color:#5db3b6;
		border-radius: 5px;
		margin-right:10px;
		width:100px;
		height:auto;
	}
</style>
</head>
<body>
<div id="top"><span><img src="img/tu1.jpg"></span><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg")%></div>
<div id="center">
<%
	String serialnum = (String)request.getAttribute("serialnum");
    if(Utils.isEmptyStr(serialnum)){
	    serialnum ="";
    }
    String port_id = (String)request.getAttribute("gatewayid");
    String regcode = (String)request.getAttribute("regcode");
    if(Utils.isEmptyStr(regcode)){
    	regcode ="";
    }
    String userId = (String)request.getAttribute("userId");
    if(Utils.isEmptyStr(userId)){
    	userId ="";
    }
    String company = (String)request.getAttribute("company");
    if(Utils.isEmptyStr(company)){
    	company ="";
    }
    String telephone = (String)request.getAttribute("telephone");
    if(Utils.isEmptyStr(telephone)){
    	telephone = "";
    }
    String deviceType = "";
    try{
    	deviceType = NbIoTDeviceInfoGetter.getInstance().findDeviceByPortID((String)request.getAttribute("gatewayid")).getDeviceType();
    	}
        catch(Exception e){
        }
    
%>
<form action="/nbiotInfoPage" name="form1" method="post" onsubmit="return check1();">
<input type="hidden" name="action" value="regNbIoTDevice">
<input type="hidden" name="gatewayid"  id="gatewayid" value="<%=request.getAttribute("gatewayid")%>">

<table>
<% 
if(request.getAttribute("error")!=null)
	{%>
	<tr><td colspan="2" style="color:#ff0000"><%=request.getAttribute("error") %></td></tr>
<%}else if(request.getAttribute("info")!=null) {%>
	<tr><td colspan="2" style="color:#00ff00"><%=request.getAttribute("info") %></td></tr>
<%} %>
<% 
if(!Utils.isEmptyStr(deviceType)&&deviceType.equals(Const.VITUAL_NBIOT_DEVICE))
	{%>
	<tr>
    <td><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_id")%></td>
    <td><input type="text" name="serialnum"  id="serialnum"  size="40"  value="<%=serialnum %>"></td>
    </tr>
	<%}else{ %>
		<tr>
    <td><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_id")%></td>
    <td><input type="text" readonly name="serialnum"  id="serialnum"  size="40"  value="<%=serialnum %>"></td>
    </tr>
	<% }%>
<tr>
<td><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_code")%> </td>
<td><input type="text" name="regcode" id="regcode" maxlength="28" size="40" value="<%=regcode%>"></td>
</tr>
<% 
if(!Utils.isEmptyStr(deviceType)&&deviceType.equals(Const.VITUAL_NBIOT_DEVICE))
	{%>
<tr>
<td><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_company")%></td>
<td><input type="text" name="company"  id="company"  size="25" value="<%=company%>"></td>
</tr>
<tr>
<td><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_user")%></td>
<td><input type="text" name="userId"  id="userId"  size="25" value="<%=userId%>"></td>
</tr>
<tr>
<td><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_telephone")%></td>
<td><input type="text" name="telephone"  id="telephone"  size="25" value="<%=telephone%>"></td>
</tr>
<%} %>
<tr>
	<td></td>
	<td>
		<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_info1")%>
		<div></div>
		<a target="_top" href="http://www.sendsms.com.cn/">www.sendsms.com.cn</a> <%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_info2")%>
	</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" class="wbtn1" value=<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_submit")%>>
<input type="reset" class="wbtn3" value=<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_reset")%>>
<input type="button" class="wbtn3" value=<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_reg_back")%> onclick="goback()">
<% 
if(!Utils.isEmptyStr(deviceType)&&deviceType.equals(Const.VITUAL_NBIOT_DEVICE))
	{%>
<input type="button" class="wbtn2" value=<%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.device_cancell")%> onclick="cancellDevice()">
<%} %>
</td>
</tr>

</table>
</form>
</div>
<%if(request.getAttribute("message")!=null) {%>
<script type="text/javascript">
alert('<%=request.getAttribute("message")%>');
</script>
<% }%>
</body>
</html>