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

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="jscript">
function setresult()
{
   parent.vip2.location.href="vipquery2.php?viptype="+document.form1.viptype.value.toString();
}
</script>
<title>修改优惠等级信息响应</title>
<body background="bkg.bmp" onload="setresult();" style="background-attachment: fixed; background-position-y:100;">
<p align="center"><font size="3"><b>修改优惠等级信息响应</b></font></p>
<center>
<?php
$viptype=$_REQUEST["viptype"];
$discount=trim($_REQUEST["discount"]);
$givelength=trim($_REQUEST["givelength"]);
if ($viptype!="") {
   $timestr=strftime("%Y-%m-%d %H:%M:%S");
   $db=mysql_pconnect(get_cfg_var("SIPSERVER"),get_cfg_var("SIPUSER"),get_cfg_var("SIPPWD"));
   mysql_select_db(get_cfg_var("SIPDB"),$db);
   if ($discount!="" && $givelength!="") {
      $rs=mysql_query("select discount,givelength from vips where viptype='".$viptype."'",$db);
      if ($row = mysql_fetch_array($rs)) {
         $olddiscount=$row["discount"];
         $oldgivelength=$row["givelength"];
         mysql_free_result($rs);
         if (intval($discount)<>$olddiscount || intval($givelength)<>$oldgivelength) {
            mysql_query("update vips set discount=".$discount.",givelength=".$givelength." where viptype='".$viptype."'",$db);
            mysql_query( "insert into operation values('".$_SESSION["operator"]."','".$timestr."','修改优惠等级，等级名：".$viptype."')",$db);
            echo("修改成功");
		 }
         else {
            echo("没有改变不用修改");
         }
	  }
      else {
         mysql_free_result($rs);
         echo("要修改的优惠等级不存在");
      }
   }
   else {
      echo("输入的优惠等级信息不全");
   }
   mysql_close($db);
}
else {
   echo("优惠等级名不能为空");
}
?>
<form name="form1" method="get" action="_self">
<input type="hidden" name="viptype" value="<?php echo $viptype; ?>">
</form>
</center>

</body>

</html>
