<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
	<style type="text/css">
	 .cmdmessage_main{padding-top:10px;}
	</style>
	</head>
	<body>
		<!--命令
		<div class="cmdbox" id="cmdContentWin">-->
			<div class="top"></div>
			<div class="center">
				<h3 id="movecmdWin">
					<a href="javascript:;" title="关闭" class="message_close" id="closePopuWin"></a>
					<span id="cmdName">省电模式 </span>
				</h3>
				<ul>
		        	<li id="cmdMsg_li" style="text-align:center;display:none;margin-top:10px;">
		        		<span id="cmdMsg" style="color:red;"></span>
		        	</li>
		        </ul>
					<div class="cmdmessage_main" id="cmdmessage_main">
						<div id="cpcontent">
							<span>定位模式:</span>
							<select id="sdms_dwms">
								<option value="1">
									GPS+基站定位
								</option>
								<option value="0">
									基站定位
								</option>
								<option value="2">
									基站+Wifi定位
								</option>
								<option value="3">
									GPS+基站+Wifi定位
								</option>
							</select>
							<br>
							<span>上传时间(HHMM):</span>
								<input id="sdms_time" name="cp" value="">
							<br>
							<span>唤醒间隔(小时):</span>
							<select name="pl_cs" id="sdms_hxpl">
								<option value="1">1</option>
								<option value="2">2</option>
								<option value="3">3</option>
								<option value="4">4</option>
								<option value="6">6</option>
								<option value="8">8</option>
								<option value="12">12</option>
								<option value="24">24</option>
							</select>
							<br>
							<div
								style="border: 1px solid #ddd; padding: 0px 10px; margin: 0px -10px; padding-bottom: 15px">
								<div style="overflow: hidden">
									<span>星期模式</span>
									<div style="float: right">
										<input id="sdms_all" name="sdms_all" type="checkbox">
										<span>全选</span>
									</div>
								</div>
								<div>
									<table width="100%"
										style="border: 1px solid #ddd; text-align: center">
										<thead>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													星期
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													上报使能
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													包括GPS信息
												</td>
											</tr>
										</thead>
										<tbody>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													日
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
											</tr>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													一
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
											</tr>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													二
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
											</tr>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													三
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>

											</tr>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													四
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>

											</tr>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													五
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>

											</tr>
											<tr>
												<td style="border: 1px solid #ddd; padding: 4px">
													六
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>
												<td style="border: 1px solid #ddd; padding: 4px">
													<input name="sdms_node" type="checkbox">
												</td>

											</tr>
										</tbody>
									</table>
								</div>
							</div>
						</div>
						<input type="button" value="发送" onclick="sendCmd_sdms();"
							style="width: 80px; height: 30px; margin-left: 90px; margin-top: 20px;">
						<!-- <a href='javascript:;' onclick='sendCmd();'>发送</a>|<a href='javascript:;' id='cancelCmd'>取消</a> -->
					</div>
			</div>
			<div class="bot"></div>
			<input type="hidden" id="SDMS_vhcCode" value="<%=request.getParameter("name")%>">
			<input type="hidden" id="SDMS_gprsCode" value="<%=request.getParameter("gprsCode")%>">
			<input type="hidden" id="SDMS_mask" value="<%=request.getParameter("mask")%>">
			<input type="hidden" id="SDMS_mtid" value="<%=request.getParameter("mtid")%>">
			<input type="hidden" id="SDMS_cmdid" value="<%=request.getParameter("cmdid")%>">
			<!--命令 end-->
		<script>
		$("[name='sdms_all']:checkbox").click(function(){
			$("[name='sdms_node']:checkbox").attr('checked',this.checked);
		});
		$("[name='sdms_node']:checkbox").click(function(){
			if($("input[name='sdms_node']:checked").length > 0){
				$("#sdms_all").attr('checked',"checked");
			}else{
				$("#sdms_all").attr('checked',false);
			}
		});

		function sendCmd_sdms(){
			$("#cmdMsg").html("");
	    	$("#cmdMsg_li").hide();
			var dwms = $("#sdms_dwms").val();
			var time = $("#sdms_time").val();
			var hxpl = $("#sdms_hxpl").val();
			var vid = $("#SDMS_gprsCode").val();
			if(time.length!=4){
				$("#cmdMsg").html("上传时间格式错误");
		    	  $("#cmdMsg_li").show();
		    	  return;
			}
			if(time.length!=4){
				var r = /^\+?[1-9][0-9]*$/;　　//正整数 
			      if(!r.test(time)){
			    	  $("#cmdMsg").html("上传时间格式错误");
			    	  $("#cmdMsg_li").show();
			    	  return;
				  }
			}
			var byts = "";
			$('input[name="sdms_node"]:checkbox').each(function(){
				if(this.checked){
					byts +=1;
				}else{
					byts +=0;
				}
			});
			var params = "vid="+$("#SDMS_gprsCode").val()+"&mtid="+$("#SDMS_mtid").val()+"&cmdid="+$("#SDMS_mask").val()+"&cp="+dwms+"&cp="+time+"&cp="+hxpl+"&cp="+byts+"&cp=";
			console.info(params);
			  $.ajax({
			        type: "POST",
			        dataType: "json",
			        url: "json/cmdAction_send.action",
			        data: params,
			        success: function(json){
			        console.info(json);
						  if (json.flag){
							  $("#closePopuWin").click();
						  }
			   		}
			   });

		}
				$(function(){

					//alert("----"+decodeURI($("#SDMS_vhcCode").val()));
					
				})
			</script>
	</body>
</html>
