<?php
	$acl=$_SESSION["acl"];
	if (strlen($acl)<1 || !strpos($acl,"<2026>")) {	//没有权限
		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>
</head>

<body background="bkg.bmp">

<p align="center"><font size="5"><b>更换计费类型</b></font></p>
<hr color="#999966">


<p align="center">
<b>
<?php
	$loginname = trim($_REQUEST["loginname"]);
	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);
		$rs = mysql_query("select users.userid,users.type,types.name,types.typemode from users,types where users.type=types.typeid and users.loginname='".$loginname."' and users.checked='n'",$db);	//取该用户开号数据
		if ($row = mysql_fetch_array($rs)) {
			$userid=$row[0];
			$usertype=$row[1];
			$usertypename=$row[2];
			$typemode=$row[3];
			mysql_free_result($rs);
			if ( $typemode=="2" ) {			//原类型可以更改
				echo("<form method=POST action=changetype_result2.php>");
				echo("  <input type=hidden name=userid value=".$userid.">");
				echo("  <input type=hidden name=oldtype value=".$usertype.">");
				echo("  <div align=center>");
				echo("    <center>");
				echo("    <table border=1 cellpadding=0 cellspacing=0 bordercolor=#008080 width=423 height=138>");
				echo("      <tr>");
				echo("        <td width=130 height=30>");
				echo("          <p align=center>用户ID</td>");
				echo("        <td width=287 height=30>");
				echo("          <p align=center>".$loginname."</td>");
				echo("      </tr>");
				echo("      <tr>");
				echo("        <td width=130 align=center height=30>原计费类型</td>");
				echo("        <td width=287 height=30>");
				echo("          <p align=center>".$usertypename."</td>");
				echo("      </tr>");
				echo("      <tr>");
				echo("        <td width=130 height=33>");
				echo("          <p align=center>新计费类型</td>");
				echo("        <td width=287 height=33>");
				echo("          <p align=center>");
				echo("          <select size=1 name=newtype>");
				$rs = mysql_query("select typeid,name from types where typemode='2'",$db);		//读取结帐类型列表，只列出先使用后结算类型
				if ($row = mysql_fetch_array($rs)) {
					$n=1;
   		       		while ($row) {
	   	        		if ($row["typeid"]!=$usertype) {			//只列出和原来不同的计费类型
		   	        		if ($n==1) {
					           echo("<option selected value=".chr(34).$row["typeid"].chr(34).">".$row["name"]."</option>");	//缺省选择小时类型
							}
       	    				else {
			    	   	    	echo("<option value=".chr(34).$row["typeid"].chr(34).">".$row["name"]."</option>");
		    	   		    }
		    	   	    	$n=$n+1;
			           }
			           $row = mysql_fetch_array($rs);
    		       }
				}
				mysql_free_result($rs);
				echo("          </select>");
				echo("          </td>");
				echo("      </tr>");
				echo("      <tr>");
				echo("        <td colspan=2 align=center width=419 height=37><input type=submit value=提交 name=B1></td>");
				echo("      </tr>");
				echo("    </table>");
				echo("    </center>");
				echo("  </div>");
				echo("</form>");
			}
			else {
				echo("该用户计费类型不是先使用后结算类型，不能中途更换计费类型！");
			}
		}
		else {
			mysql_free_result($rs);
			echo("找不到该用户ID!");
		}
		mysql_close($db);
	}
	else {
		echo("必须输入需要更换计费类型的用户ID！");
	}
?>
</b></p>


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

</body>

</html>
