<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<1004>")) {	//没有权限
		ob_clean();
		header("Location: ../accesserror.html");
		exit;
	}
?>

<html>

<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>操作历史记录查询</title>
<SCRIPT language="JavaScript">
function settype()
{
     var n=document.Form1.operation2.selectedIndex;
     document.Form1.operation1.value=document.Form1.operation2.options(n).text;
}

//当日期为0开头是去掉0，如05格式化为5
function formatdate(obj)
{
     if (obj.value!="")
        {
         var a=parseInt(obj.value);
         obj.value=a.toString();
        }
}

//检查日期输入是否有效
function evaldate(tmpyear,tmpmonth,tmpday)
{
     var canuse=0;
     if (tmpyear!=""&&tmpmonth!=""&&tmpday!="")
	    {
	     if (tmpyear.search(/\d{4}/)!=0)
	         canuse=2;
	     else
	        {
	         var tmpstr=parseInt(tmpmonth);
	         if (tmpmonth==tmpstr&&tmpstr<13&&tmpstr>0)
	            {
	             tmpstr=parseInt(tmpday);
	             if (tmpday==tmpstr&&tmpstr<32&&tmpstr>0)
	                 canuse=1;
	             else
	                 canuse=2
	            }
	         else
	             canuse=2;
	        }	         
	    }
	else
	   {
	    if (tmpyear==""&&tmpmonth==""&&tmpday=="")
	        canuse=0;
	    else
	        canuse=3;
	   }
	return canuse
}

//如果输入有效则提交，无效则提示错误
function evaluation()
{
    var year1=document.Form1.year1.value;
    var	month1=document.Form1.month1.value;
	var	day1=document.Form1.day1.value;
	var canuse1=evaldate(year1,month1,day1);
	var	year2=document.Form1.year2.value;
	var	month2=document.Form1.month2.value;
	var	day2=document.Form1.day2.value;
	var canuse2=evaldate(year2,month2,day2);
	if ((canuse1==0&&canuse2==0)||(canuse1==1&&canuse2==0)||(canuse1==0&&canuse2==1))
	   {
	    if (canuse1==1)
	       {
	        date1=new Date(year1,month1-1,day1);
	        tmpdate=new Date();
	        if (tmpdate>date1)
	           {
	            formatdate(document.Form1.month1);
	            formatdate(document.Form1.day1);
	            document.Form1.submit();
	           }
	        else
	            alert("起始日期应小于当前时间")
	       }
	    else
	       {
	        formatdate(document.Form1.month2);
	        formatdate(document.Form1.day2);
	        document.Form1.submit();
	       }
	   }
	else
	   {
	    if (canuse1==1&&canuse2==1)
	       {
	        date1=new Date(year1,month1-1,day1);
	        date2=new Date(year2,month2-1,day2);
	        if (date1<=date2)
	           {
	            formatdate(document.Form1.month1);
	            formatdate(document.Form1.day1);
	            formatdate(document.Form1.month2);
	            formatdate(document.Form1.day2);
	            document.Form1.submit();
	           }
	        else
	            alert("起始日期应小于截止日期");
	       }
	    else
	       {
	        switch (canuse1)
	              {
	               case 2: alert("起始日期输入有错");
	               break;
	               case 3: alert("请输入完整的起始日期或全部为空");
	              }
	        switch (canuse2)
	              {
	               case 2: alert("截止日期输入有错");
	               break;
	               case 3: alert("请输入完整的截止日期或全部为空");
	              }
	       }
	   }
}
</SCRIPT>
</head>

<body background="../bkg.bmp" onload="settype();">

<p align="center"><font size="5"><b>操作历史记录查询</b></font></p>
<hr color="#999966">
<p>　</p>
<div align="center">
  <center>
  <form name="Form1" method="GET" action="listaction.php">
  <table border="1" width="703" height="180" bordercolor="#008080" cellspacing="0" cellpadding="0">
    <tr>
      <td width="128" align="center" height="33">操作员ID</td>
      <td width="575" align="left" height="33">&nbsp&nbsp    
      <?php
		$db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD")); 
		mysql_select_db(get_cfg_var("SIPDB"),$db);
        echo("<select name=operator size=1>");
        echo("<option selected value=''>全部操作员</option>");
        $rs = mysql_query("select operator from operators",$db);
		while ($row = mysql_fetch_array($rs)) {
              echo("<option value=".$row["operator"].">".$row["operator"]."</option>");
        }
		mysql_free_result($rs);
        echo("</select>");
       ?>
       </td>
    </tr>
    <tr>
      <td width="128" align="center" height="33">操作类型</td>
      <td width="575" align="left" height="33">&nbsp&nbsp    
      <input type="text" name="operation1" size=20>（ 
      <?php
           echo("<select name='operation2' size=1 onclick='settype();'>");
           echo("<option selected value='全部操作'>全部操作</option>");
	       $rs = mysql_query("select actionname from actions",$db);
		   while ($row = mysql_fetch_array($rs)) {
              echo("<option value=".$row["actionname"].">".$row["actionname"]."</option>");
           }
		   mysql_free_result($rs);
           echo("</select>");
		   mysql_close($db);
       ?>
        ）
         <p align="left"><font size="2">直接输入或从下拉菜单中选择。支持模糊查询。</font></p>
       </td>
    </tr>
    
    <tr>
      <td width="128" align="center" height="34">查询起始时间</td>
      <td width="575" align="left" height="34">
          &nbsp &nbsp<input name="year1" size="4" maxlength="4">年<input name="month1" size="2" maxlength="2">月<input name="day1" size="2" maxlength="2">日<p align="left"><font size="2">为空则查询起始时间为2004年1月1日0时</font></p>  
      </td>
    </tr>
    <tr>
      <td width="128" align="center" height="34">查询截止时间</td>
      <td width="575" align="left" height="34">
          &nbsp &nbsp<input name="year2" size="4" maxlength="4">年<input name="month2" size="2" maxlength="2">月<input name="day2" size="2" maxlength="2">日<p align="left"><font size="2">为空则截止时间为当前时间</font></p>  
      </td>
    </tr>
    <tr>
      <td colspan="2" width="703" align="center" height="36"><input type="button" value="提交" name="B1" onclick="evaluation();"><input type="reset" value="全部重写" name="B2"></td>
    </tr>
  </table>
  </form>
  </center>
</div>

<p>　</p>
<hr>
<p align="center">SIP宽带上网计费管理系统</p>
<p align="center">作者：<b>深圳市飞沃软件有限公司</b></p>

</body>

</html>
