<?php
require("../../class/connect.php");
include("../../class/db_sql.php");
include("../../class/config.php");
include("../../class/user.php");
include("../../class/functions.php");
$link=db_connect();
$empire=new mysqlquery();
$logininid=getcvar('loginuserid');
$loginin=getcvar('loginusername');
$loginrnd=getcvar('loginrnd');
$loginlevel=getcvar('loginlevel');
$editor=1;
is_login($logininid,$loginin,$loginrnd);
//验证权限
CheckLevel($logininid,$loginin,$classid,"member");
$userdate=0;
$enews=$_GET['enews'];
$url="<a href=ListMember.php>管理会员</a>&nbsp;->&nbsp;增加会员";
if($enews=="EditMember")
{
	$userid=(int)$_GET['userid'];
	//取得用户资料
	$r=ReturnUserInfo($userid);
	$addr=$empire->fetch1("select truename,oicq,msn,`call`,phone,address,zip from {$dbtbpre}enewsmemberadd where userid='$userid' limit 1");
	$url="<a href=ListMember.php>管理会员</a>&nbsp;->&nbsp;修改会员资料：<b>".$r[username]."</b>";
	//时间
	if($r[userdate])
	{
		$userdate=$r[userdate]-time();
		if($userdate<=0)
		{
			OutTimeZGroup($userid,$r['zgroupid']);
			if($r['zgroupid'])
			{
				$r['groupid']=$r['zgroupid'];
				$r['zgroupid']=0;
			}
			$userdate=0;
		}
		else
		{
			$userdate=round($userdate/(24*3600));
		}
	}
}
//----------会员组
$sql=$empire->query("select groupid,groupname from {$dbtbpre}enewsmembergroup order by level");
while($level_r=$empire->fetch($sql))
{
	if($r[groupid]==$level_r[groupid])
	{$select=" selected";}
	else
	{$select="";}
	$group.="<option value=".$level_r[groupid].$select.">".$level_r[groupname]."</option>";
	if($r[zgroupid]==$level_r[groupid])
	{$zselect=" selected";}
	else
	{$zselect="";}
	$zgroup.="<option value=".$level_r[groupid].$zselect.">".$level_r[groupname]."</option>";
}
db_close();
$empire=null;
//风格
$loginadminstyleid=(int)getcvar('loginadminstyleid');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>修改资料</title>
<link href="../adminstyle/<?=$loginadminstyleid?>/adminstyle.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="98%" border="0" align="center" cellpadding="3" cellspacing="1">
  <tr>
    <td>位置：<?=$url?></td>
  </tr>
</table>
<form name="form1" method="post" action="ListMember.php">
  <table width="98%%" border="0" align="center" cellpadding="3" cellspacing="1" class="tableborder">
    <input type=hidden name=add[oldusername] value='<?=$r[username]?>'>
    <input type=hidden name=add[userid] value='<?=$userid?>'>
    <tr class="header"> 
      <td height="25" colspan="2">修改资料 
        <input name="enews" type="hidden" id="enews" value="<?=$enews?>">
        </td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">用户名</td>
      <td width="75%" height="25"><input name=add[username] type=text id="add[username]" value='<?=$r[username]?>'></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">密码</td>
      <td height="25"><input name="add[password]" type="password" id="add[password]">
        (修改时：如不想修改,请留空)</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25" valign="top">所属会员组<br>
        <br>
        <input type="button" name="Submit3" value="管理会员组" onclick="window.open('ListMemberGroup.php');"> </td>
      <td height="25"><select name="add[groupid]" size="6" id="add[groupid]">
          <?=$group?>
        </select></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">邮箱</td>
      <td height="25"><input name="add[email]" type="text" id="add[email]" value="<?=$r[email]?>" size="35"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">剩余天数</td>
      <td height="25"><input name=add[userdate] type=text id="add[userdate]" value='<?=$userdate?>' size="6">
        天，到期后转向用户组:
        <select name="add[zgroupid]" id="add[zgroupid]">
          <option value="0">不设置</option>
		  <?=$zgroup?>
        </select></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">点数</td>
      <td height="25"><input name=add[userfen] type=text id="add[userfen]" value='<?=$r[userfen]?>' size="6">
        点</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">帐户余额</td>
      <td height="25"><input name=add[money] type=text id="add[money]" value='<?=$r[money]?>' size="6">
        元 </td>
    </tr>
    <tr bgcolor="#FFFFFF" class="header"> 
      <td height="25" colspan="2">其他信息</td>
    </tr>
	<tr bgcolor="#FFFFFF"> 
      <td width="25%" height="25">真实姓名:</td>
      <td width="75%" height="25"> <input name="add[truename]" type="text" id="add[truename]" value="<?=$addr[truename]?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">OICQ:</td>
      <td height="25"> <input name="add[oicq]" type="text" id="add[oicq]" value="<?=$addr[oicq]?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">MSN:</td>
      <td height="25"> <input name="add[msn]" type="text" id="add[msn]" value="<?=$addr[msn]?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">固定电话:</td>
      <td height="25"> <input name="add[call]" type="text" id="add[call]" value="<?=$addr[call]?>">
        (区号+电话号码)</td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">移动电话:</td>
      <td height="25"> <input name="add[phone]" type="text" id="add[phone]" value="<?=$addr[phone]?>"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">联系地址:</td>
      <td height="25"> <input name="add[address]" type="text" id="call3" value="<?=$addr[address]?>" size="60"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">邮编:</td>
      <td height="25"> <input name="add[zip]" type="text" id="add[zip]" value="<?=$addr[zip]?>" size="8"></td>
    </tr>
    <tr bgcolor="#FFFFFF"> 
      <td height="25">&nbsp;</td>
      <td height="25"><input type="submit" name="Submit" value="修改"> <input type="reset" name="Submit2" value="重置"></td>
    </tr>
  </table>
</form>
</body>
</html>
