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

//检查输入的信息
function checkinfo()        
{
    var givelength=document.FrontPage_Form1.givelength.value;
    var discount=document.FrontPage_Form1.discount.value;
    var cansubmit1=false;
    var cansubmit2=false;
        
    if (givelength!="")
       {
        var tmpstr=parseInt(givelength,"10");
        if (tmpstr==NaN||tmpstr!=givelength)
            alert("赠送数量必须为整数");
        else
           {
            if (tmpstr>=0)
               {
                document.FrontPage_Form1.givelength.value=tmpstr;
                cansubmit1=true;
               }
            else
                alert("赠送数量应为大于等于0的整数");
            }

        }  
    else
        alert("赠送数量不能为空");
    
    if (discount!="")
       {     
        tmpstr=parseInt(discount,"10")
        if (tmpstr==NaN||tmpstr!=discount)
            alert("折扣必须为整数");
        else
           {
            if (tmpstr>0&&tmpstr<=100)
               {
                document.FrontPage_Form1.discount.value=tmpstr;
                cansubmit2=true;
               }
            else
                alert("折扣应为大于0小于等于100的整数");
           }
       }
    else
        alert("折扣不能为空");

    if (cansubmit1&&cansubmit2)
       document.FrontPage_Form1.submit();
}
</script>
<title>修改优惠等级信息</title>
</head>

<body background="bkg.bmp" style="background-attachment: fixed; background-position-y:100;">

<p align="center"><font size="3"><b>修改优惠等级信息</b></font></p>
<center>
<?php
    $db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
    mysql_select_db(get_cfg_var("SIPDB"),$db);
    $viptype=$_REQUEST["viptype"];
    if ($viptype!="") {
       $rs=mysql_query("select * from vips where viptype='".$viptype."'",$db);
	   if ($row = mysql_fetch_array($rs)) {
          $discount=strval($row["discount"]);
          $givelength=strval($row["givelength"]);
          mysql_free_result($rs);
          echo("<form name='FrontPage_Form1' method='POST' action='revisevip_result.php'>");
          echo("<table border='1'bordercolor='#008080' cellspacing='0' cellpadding='0'>");
          echo("<tr><td align=center width=100>优惠等级名</td><td align=left width=100>&nbsp;&nbsp;".$viptype."</td></tr>");
          echo("<tr><td align=center width=100>默认折扣</td><td align=left width=100>&nbsp;&nbsp;<input type='text' name='discount' size=3 value=".$discount.">%</td></tr>");
          echo("<tr><td align=center width=100>默认赠送</td><td align=left width=100>&nbsp;&nbsp;<input type='text' name='givelength' size=8 value=".$givelength."></td></tr>");
          echo("<tr><td align=center colspan=2><input type='button' name='b1' value='确认' onclick='checkinfo();'></td></tr>");
          echo("<input type='hidden' name='viptype' value=".$viptype.">");
          echo("</table>");
          echo("</form>");
	   }
       else {
	      echo("没有要修改的优惠等级");
	   }
	}
    else {
	   echo("请选择要修改的优惠等级");
	}
    mysql_close($db);
?>
<p></p>
<table border="0">
<tr><td align="center"><font size="3"><b>备注</b></font></td></tr>
<tr><td align="left">
<font size="2">
<ul>
   <li><b>1.</b>添加优惠等级时填写的折扣及赠送信息为该优惠等级的默认<br>&nbsp;&nbsp;值,在将用户添加到该优惠等级时可以修改；<br></li>
   <li><b>2.</b>赠送的单位与用户类型有关,具体如下:</li>
   <ul>
      <li><b>2.1.</b>“包年”类型赠送数量是以月为单位；<br></li>
      <li><b>2.2.</b>“计流量(G)”类型赠送数量是以M为单位；<br></li>
      <li><b>2.3.</b>其它类型赠送数量的单位和该类型续费数量单位相同；<br>
      <li><b>2.4.</b>先使用后付款用户无赠送信息</li>
   </ul>
</ul>
</font>
</td></tr></table>
</center>
</body>

</html>

