<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<2029>")) {	//没有权限
		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 6.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<SCRIPT language="JavaScript">

//当日期为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>
<title>组续费清单查询</title>
</head>

<body background="bkg.bmp">

<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="querygpaddtime_result.php">
  <table border="1" width="528" height="180" bordercolor="#008080" cellspacing="0" cellpadding="0">
    <tr>
      <td align="center" width="100">
      组名
      </td>
      <td align="left" width="250">&nbsp;&nbsp;
        <select size="1" name="gpid" > 
        <option value="">所有组</option>
<?php
        $db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
		mysql_select_db(get_cfg_var("SIPDB"),$db);
        $rs = mysql_query("select gpid,gpname from groups order by gpname",$db);		//读取组列表
        while ($row = mysql_fetch_array($rs)) {
           echo("<option value=".chr(34).strval($row["gpid"]).chr(34).">".$row["gpname"]."</option>");
        }
		mysql_free_result($rs);
		mysql_close($db);
?>
       </select>
      </td>
    </tr>
   
    <tr>
      <td width="128" align="center" height="34">查询起始时间</td>
      <td width="400" 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="400" 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="528" 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>