<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.sql.*,gbase.db.*" %>
<%@ include file="../checkLogin.jsp" %>
<SCRIPT language="JavaScript" src="../js/util.js"></SCRIPT>
<link rel="stylesheet" href="../js/calendar.css" type="text/css">
<SCRIPT Language="JavaScript" src="../js/simpleCalendar.js"></SCRIPT>
<LINK href="../css/css.css" rel=stylesheet>
<%
DBOperation theDBOperation = new DBOperation();

String id = request.getParameter("id") == null ? "" :request.getParameter("id");
String action = request.getParameter("action") == null ? "" :request.getParameter("action");
String task_name="";
String web_collection_id="";
String circle_flag="";
String timer_time="";
String timer_week="";
String timer_day="";
String create_date="";
if(action.equals("update") || action.equals("view"))
{
String sql = "select * from web_timer_task  where id="+id+"";
ResultSet rs =theDBOperation.getResultSet(sql);
if(rs.next())
{
task_name=rs.getString("task_name")==null?"":rs.getString("task_name");
web_collection_id=rs.getString("web_collection_id")==null?"":rs.getString("web_collection_id");
circle_flag=rs.getString("circle_flag")==null?"":rs.getString("circle_flag");
timer_time=rs.getString("timer_time")==null?"":rs.getString("timer_time");
timer_week=rs.getString("timer_week")==null?"":rs.getString("timer_week");
timer_day=rs.getString("timer_day")==null?"":rs.getString("timer_day");
create_date=rs.getString("create_date")==null?"":rs.getString("create_date");
}
}
%>
<html>
<head>
<title>
定时管理
</title>
</head>
<body leftmargin="0" topmargin="0">

<!--导航-->
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
       <tr>
		<td width="100%" height="20"  bgcolor="#eeeeee" class="p2">您当前所在的位置>>定时管理</td>
	   </tr>
       <tr>
          <td width="100%" height="2"> <img border="0" src="../images/spacer.gif" width="1" height="3"></td>
       </tr>
    </table>
<!--标题-->
  <div align="center">
   <table border="0" width="100%" cellspacing="0" cellpadding="0" height="34">
	<tr>
		<td width="159" background="../images/back_board2.gif" nowrap valign="bottom"><span class="title01">&nbsp;<span class="style1">新增/修改定时管理</span></span></td>
		<td valign="bottom" align="right" width="642"></td>
	</tr>
	<tr>
		<td bgcolor="#2C9CC4" colspan="2"><img border="0" src="../images/bline_3.gif" width="1" height="2"></td>
	</tr>
</table>
</div><br>
<form name="form1" method="post" action="web_timer_task_save.jsp">
<input name="action" type="hidden" value="<%=action%>">
<input name="id" type="hidden" value="<%=id%>">
<div align="center">
<table width="85%" class="p1" border="0" cellSpacing="1" cellPadding="3" align="center" bgColor="#cccccc">
        
	<tr>
		<td align="right"  bgColor=#e9f0f4 width=150">定时名称：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
	            <input name="task_name" type="text" size="50" maxlength="25" value="<%=task_name%>">&nbsp;
                </td>
	</tr>
	<tr>
		<td align="right"  bgColor=#e9f0f4 width=150">定时项目：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
	            <%
	               DBOperation theSelectDBOperation = new DBOperation();
	               String select_sql = "select * from web_collection where state='设置完成' and web_account='"+web_account+"'";
                       ResultSet select_rs =theSelectDBOperation.getResultSet(select_sql);
	             %>
	             <select name="web_collection_id">
                        <option value="">--请选择--</option>
                        <%while(select_rs.next()){%>
	                <option value="<%=select_rs.getString("id")%>"><%=select_rs.getString("itemname")%></option>
	                <%}%>
	             </select>
                     <script>form1.web_collection_id.value='<%=web_collection_id%>';</script>
                </td>
	</tr>
	<tr>
		<td align="right"  bgColor=#e9f0f4>定时启动时间：</td>
		<td onmouseover='vbscript:me.bgcolor="#F5F5F5"'	onmouseout='vbscript:me.bgcolor="#FFFFFF"' bgColor=#ffffff>&nbsp;
		     <select name="circle_flag" onchange="javascript:ShowTimingType(this.options[this.selectedIndex].value)">
                        <option value="">--请选择--</option>
                        <option value="1">每天</option>
                        <option value="2">每周</option>
                        <option value="3">每月</option>
                     </select>&nbsp;
                     <script>form1.circle_flag.value='<%=circle_flag%>';</script>
                     <select name="timer_week" style="DISPLAY: none">
                        <option value="">--请选择--</option>
                        <option value="1">星期日</option>
                        <option value="2">星期一</option>
                        <option value="3">星期二</option>
                        <option value="4">星期三</option>
                        <option value="5">星期四</option>
                        <option value="6">星期五</option>
                        <option value="7">星期六</option>
                     </select>&nbsp;
                     <script>form1.timer_week.value='<%=timer_week%>';</script>
                     <select name="timer_day" style="DISPLAY: none">
                        <option value="">--请选择--</option>
                        <option value="1">1</option>
                        <option value="2">2</option>
                        <option value="3">3</option>
                        <option value="4">4</option>
                        <option value="5">5</option>
                        <option value="6">6</option>
                        <option value="7">7</option>
                        <option value="8">8</option>
                        <option value="9">9</option>
                        <option value="10">10</option>
                        <option value="11">11</option>
                        <option value="12">12</option>
                        <option value="13">13</option>
                        <option value="14">14</option>
                        <option value="15">15</option>
                        <option value="16">16</option>
                        <option value="17">17</option>
                        <option value="18">18</option>
                        <option value="19">19</option>
                        <option value="20">20</option>
                        <option value="21">21</option>
                        <option value="22">22</option>
                        <option value="23">23</option>
                        <option value="24">24</option>
                        <option value="25">25</option>
                        <option value="26">26</option>
                        <option value="27">27</option>
                        <option value="28">28</option>
                        <option value="29">29</option>
                        <option value="30">30</option>
                        <option value="31">31</option>
                     </select>&nbsp;
                     <script>form1.timer_day.value='<%=timer_day%>';</script>
                     <select name="timer_time">
                        <option value="">--请选择--</option>
                        <option value="0">0点</option> 
                        <option value="1">1点</option>
                        <option value="2">2点</option>
                        <option value="3">3点</option>
                        <option value="4">4点</option>
                        <option value="5">5点</option>
                        <option value="6">6点</option>
                        <option value="7">7点</option>
                        <option value="8">8点</option>
                        <option value="9">9点</option>
                        <option value="10">10点</option>
                        <option value="11">11点</option>
                        <option value="12">12点</option>
                        <option value="13">13点</option>
                        <option value="14">14点</option>
                        <option value="15">15点</option>
                        <option value="16">16点</option>
                        <option value="17">17点</option>
                        <option value="18">18点</option>
                        <option value="19">19点</option>
                        <option value="20">20点</option>
                        <option value="21">21点</option>
                        <option value="22">22点</option>
                        <option value="23">23点</option> 
                     </select>&nbsp;
                     <script>form1.timer_time.value='<%=timer_time%>';</script>
		</td>
	</tr>
	
</table>

<table border="0" cellpadding="3" class="p1" width="90%" bordercolor="#D7D7D7" style="border-collapse: collapse" cellspacing="0">
	<tr>
		<td width="30%" align="right">　</td>
		<td width="70%" height="0">
		        <%if(!action.equals("view")){%>
			<img border="0" src="../images/btn/confirm.gif"  onclick = "check_validate(document.form1)" style="cursor:hand">
			<A href="javascript:document.form1.reset();"><IMG src="../images/btn/reset.gif" border=0></A>
			<%}%>
			<A href="javascript:history.back();"><IMG src="../images/btn/back.gif"  border=0></A>
		</td>
	</tr>
</table>
</div>
</form>
</body>
<Script Language="javaScript">
    function  check_validate(theForm) {
        if (isSpace(theForm.task_name.value)) {
            alert("定时名称不能为空！");
            theForm.task_name.focus();
            return false;
        }
        if (isSpace(theForm.web_collection_id.value)) {
            alert("请选择定时项目！");
            theForm.web_collection_id.focus();
            return false;
        }
        if (isSpace(theForm.circle_flag.value)) {
            alert("请选择定时周期！");
            theForm.circle_flag.focus();
            return false;
        }
        if(theForm.circle_flag.value=='2')
        {
          if (isSpace(theForm.timer_week.value)) {
            alert("请选择定时星期几");
            theForm.timer_week.focus();
            return false;
          }
        }
        if(theForm.circle_flag.value=='3')
        {
          if (isSpace(theForm.timer_day.value)) {
            alert("请选择哪天定时执行");
            theForm.timer_day.focus();
            return false;
          }
        }
        if (isSpace(theForm.timer_time.value)) {
            alert("请选择定时时间");
            theForm.timer_time.focus();
            return false;
          }
        theForm.submit();
    }
    function ShowTimingType(num){ 
                switch(num){
                case "1":     
                        document.form1.timer_week.style.display='none';
                        document.form1.timer_day.style.display='none';
                        break;
                case "2":     
                        document.form1.timer_week.style.display='';
                        document.form1.timer_day.style.display='none';
                        break;
                case "3":
                        document.form1.timer_week.style.display='none';
                        document.form1.timer_day.style.display='';
                        break;
                default:
                        //alert("错误参数调用！");
                        break;
                }
        }
   ShowTimingType('<%=circle_flag%>')
</Script>
</html>
