<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<2028>")) {	//没有权限
		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">
<STYLE>
td.TD1 { text-align:center; width:150 }
td.TD2 { text-align:left; width:300 }
td.TD3 { text-align:center; width:450 }
</STYLE>
<SCRIPT LANGUAGE="javascript">
function setup()
{
    var gpid=document.form1.gpid.value;
    if (gpid!="none")
    {
        if (document.form1.gp_name.options.length>0) {
	        var i=0;
    	    for (i=0;i<document.form1.gp_name.options.length;i++)
       		{
           		  if (document.form1.gp_name.options(i).value==gpid)
             	  {
                		document.form1.gp_name.options(i).selected=true;
			        	document.form1.gpname.value=document.form1.gp_name.options(i).text;
	                   break;
    	         }
                
       		}
        }
	    setmoney2();
    }
}
function InputGP()
{
    cancelBubble=true;
    var n=document.form1.gp_name.selectedIndex;
    if (n>=0) {
	    document.form1.gpname.value=document.form1.gp_name.options(n).text;
	}
}
function setmoney2()
{   
    var money1=parseFloat(document.all.money1.innerText);
    var money2=Math.round(money1*parseInt(document.form1.discount.value,"10")/10)/10;
    document.all.money21.innerText=money2.toString();
    document.form1.money2.value=money2.toString(); 
}
function checkdata()
{
    var str=document.form1.discount.value;
    var tmpstr=parseInt(str,"10");
    if (tmpstr!=str||tmpstr<=0)
        alert("折扣只能是整数且大于等于0");
    else
       {
        document.form1.discount.value=tmpstr;
        document.form1.submit();
       } 
}
</SCRIPT>
<title>用户激活</title>
</head>
<body background="bkg.bmp" onload="javascript:setup();">
<p align="center"><font size="5"><b>用户激活</b></font></p>
<hr color="#999966">
<?php
   $loginname=trim($_REQUEST["loginname"]);
   if ($loginname=="") {
      $loginname=$_REQUEST["loginname"];
   }
   $bValid=FALSE;
   if ($loginname!="") {
      $db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
      mysql_select_db(get_cfg_var("SIPDB"),$db);
      $sqlstr="select batusers.userid,batusers.batchid,batusers.loginname,batusers.password,batusers.money1,types.name,batusers.gpid from batusers,types where types.typeid=batusers.type and batusers.loginname='".$loginname."' and active='n'";
      $rs=mysql_query($sqlstr,$db);
      if ($row = mysql_fetch_array($rs)) {
      	$bValid=TRUE;
?>
<div align="center">
<form name="form1" method="POST" action="active_result.php">
<table border="1"  bordercolor="#008080" cellspacing="0" cellpadding="0">
   <tr>
      <td class="TD1">批次号</td>
      <td class="TD2">&nbsp;&nbsp;<?php echo strval($row[1]); ?></td>
   </tr>
   <tr>
      <td class="TD1">用户ID</td>
      <td class="TD2">&nbsp;&nbsp;<?php echo $row[2]; ?></td>
   </tr>
   <tr>
      <td class="TD1">用户密码</td>
      <td class="TD2">&nbsp;&nbsp;<?php echo $row[3]; ?></td>
   </tr>
   <tr>
      <td class="TD1">用户类型</td>
      <td class="TD2">&nbsp;&nbsp;<?php echo $row[5]; ?></td>
   </tr>
   <tr>
      <td class="TD1">用户组别</td>
      <td id="groupinfo" class="TD2">&nbsp;&nbsp;<input type="text" name="gpname" size="8" value="">&nbsp;&nbsp;
          <select size="1" name="gp_name" onclick="InputGP();">  
<?php
        $rs1 = mysql_query("select gpid,gpname from groups order by gpid",$db);
       while ($row1 = mysql_fetch_array($rs1)) {
	       echo("<option value=".chr(34).strval($row1["gpid"]).chr(34).">".$row1["gpname"]."</option>");
       }
		mysql_free_result($rs1);
?>
          </select>
          <input type="hidden" name="gpid" size="8" value="<?php echo strval($row[6]); ?>">
         <br>&nbsp&nbsp<font size="2">新用户组请直接输入,为空为无组别<br>&nbsp&nbsp已有的用户组请从右边的下拉菜单中选择,<font>
      </td>
   </tr>
   <tr>
      <td class="TD1">应付金额</td>
      <td class="TD2">&nbsp;&nbsp;<span id="money1"><?php echo $row[4]; ?></span>元</td>
   </tr>
   <tr>
      <td class="TD1">折扣</td>
      <td class="TD2">&nbsp;&nbsp;<input type="text" name="discount" value="100" size="3" onkeyup="setmoney2();">%</td>
   </tr>
   <tr>
      <td class="TD1">实收金额</td>
      <td class="TD2">&nbsp;
          <span id="money21"></span>元　
          <input type="hidden" name="money2" value="0">
      </td>
   </tr>
    <tr>
      <td colspan="2" class="TD3"><input type="hidden" name="userid" value="<?php echo $row[0]; ?>"><input type="button" name="b1" value="激活" onclick="checkdata();"></td>
   </tr>
</table>
</form>
</div>
<?php } else { ?>
<p align="center">该用户不存在或已经被激活</p>
<?php  }
    mysql_free_result($rs);
    mysql_close($db);
} else { ?>
<p align="center">用户ID不能为空</p>
<?php
}
if (!$bValid) {
	echo("<form name=form1><input type=hidden name=gpid value=none></form>");
}
?>
<hr>
<p align="center">SIP宽带上网计费管理系统</p>
  <p align="center">作者：<b>深圳市飞沃软件有限公司</b></p>
</body>

</html>