<?php 
defined('IN_HS') or exit('Access Denied');
include admintpl('header');
?>
<style>
.selecton{BORDER-RIGHT: #e6cf87 1px dashed; PADDING-RIGHT: 20px; BORDER-TOP: #e6cf87 1px dashed; DISPLAY: block; PADDING-LEFT: 20px; FONT-SIZE: 12px; BORDER-LEFT: #e6cf87 1px dashed; PADDING-TOP: 0px; BORDER-BOTTOM: #e6cf87 1px dashed
}
#Loading{ display:none; position:absolute; background-color:#000000; filter:alpha(opacity=50);-moz-opacity:0.5;z-index:99999;left:0px;top:0px;border:2px #999999 solid;width:0px;}
#divload{ float:left;text-align:left; width: 100%;display:none; BORDER: #e6cf87 1px dashed;background:#fff8e7;padding:10px auto;height:300px}
#Loading_Bg{ position:absolute;z-index:999;left:0px;top:0px;color:#666666;background-color:#000000;filter:alpha(opacity=50);-moz-opacity:0.5;margin:0 auto;}
</style>
<body>
<div id="part_one" align=center STYLE="width:100%;margin-top:300px;position:absolute;color:#f00;font-size:14px;"><img src="/admin/skin/images/ajax_loader.gif">
<div style="padding-top:20px">正在读取数据，请等待...</div></div>
<table cellpadding='2' cellspacing='1' border='0' align='center' class='tableBorder'>
  <tr>
    <td class='pagemenu' align="center"><input type="button" class="btn" value="全部角色" onClick="javascript:location.href='?mod=<?=$mod?>&file=<?=$file?>&action=<?=$action?>&idserver=<?=$idserver?>'">
      <input type="button" class="btn" style="color:#F00" value="已删角色" onClick="javascript:location.href='?mod=<?=$mod?>&file=<?=$file?>&action=<?=$action?>&idserver=<?=$idserver?>&deleted=1'">	
	</td>
  </tr>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="10">
  <tr>
    <td ></td>
  </tr>
</table>
<table cellpadding="2" cellspacing="1" class="tableborder" width=100%>
<form method="get" name="search" action="?">
  <tr>
    <td width=20%><strong>角色搜索</strong></td>
    <td width=40%>角色名：
      <input name='Name' type='text' size='30' value='<?=$Name?>'></td>
	<td width=40%>
<input name='mod' type='hidden' value='<?=$mod?>'>
<input name='file' type='hidden' value='<?=$file?>'>
<input name='idserver' type='hidden' value='<?=$idserver?>'>
<input name='action' type='hidden' value='<?=$action?>'>
<input name='submit' type='submit' class='btn' value=' 搜索 '></td>
</tr>
</form>
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="30">
  <tr>
    <td style="text-align:center;color:darkgreen;font-size:14px;font-weight:bold">当前分区：<font color="blue"><?=$servername?></font> <?php if($deleted==1) { ?>已删除角色<?php }else{ ?>全部角色<? } ?>：共 <font color=red><?=$sumnums?></font> 条!&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;排列方式：
   <select name="select" onChange="location.href=this.options[this.selectedIndex].value;" style="background:#eee;font-size:14px;color:#900">
   <option value="">-------- 排序方式 --------</option>
   <option value="?mod=<?=$mod?>&file=fsolist&action=manage&idserver=<?=$idserver?>&deleted=<?=$deleted?>&username=<?=$username?>&ordertype=Level&Name=<?=$Name?>" <?php if($ordertype == "Level") { ?> selected<? } ?>>--- 按等级从高到低排列 ---</option>
   <option value="?mod=<?=$mod?>&file=fsolist&action=manage&idserver=<?=$idserver?>&deleted=<?=$deleted?>&username=<?=$username?>&ordertype=Gold&Name=<?=$Name?>" <?php if($ordertype == "Gold") { ?> selected<? } ?>>--- 按金钱从高到低排列 ---</option>
   <option value="?mod=<?=$mod?>&file=fsolist&action=manage&idserver=<?=$idserver?>&deleted=<?=$deleted?>&username=<?=$username?>&ordertype=Credit&Name=<?=$Name?>" <?php if($ordertype == "Credit") { ?> selected<? } ?>>--- 按声望从高到低排列 ---</option>
   </select><br>
   <span style="color:#555;font-size:12px">提示：单击ID链接可打开该角色的帐号，单击角色名称可打开仓库数据。双击角色名后面的空白可修改角色名。</span></td>
  </tr>
</table>

<table cellpadding="2" cellspacing="1" class="tableborder" width=100%>
<tr align="center">
<td width="10%" class="tablerowhighlight" style="font-size:14px;text-align:center;font-weight:bold">ID</td>
<td width="25%" class="tablerowhighlight" style="font-size:14px;font-weight:bold">角色名</td>
<td width="10%" class="tablerowhighlight" style="font-size:14px;text-align:center;font-weight:bold">等级</td>
<td width="10%" class="tablerowhighlight" style="font-size:14px;text-align:center;font-weight:bold">游戏币</td>
<td width="10%" class="tablerowhighlight" style="font-size:14px;text-align:center;font-weight:bold">声望</td>
<td width="10%" class="tablerowhighlight" style="font-size:14px;text-align:center;font-weight:bold">状态</td>
<td width="20%" class="tablerowhighlight" style="font-size:14px;text-align:center;font-weight:bold">管理</td>
</tr>
<?php 
if(is_array($members))
{
foreach($members as $member){ ?>

<tr align="center" id="trline_<?=$member['ID']?>" value="closes">
<td style="text-align:center" id="iduser_<?=$member[ID]?>"><a style="TEXT-DECORATION: underline" href="?mod=<?=$mod?>&file=acclist&action=manage&idserver=<?=$idserver?>&idx=<?=$member['AccountID']?>" target="_blank"  title="打开该角色帐号"><?=$member['ID']?></a></td>
<td title="双击空白处可进行修改" style="font-weight:bold;" id="name_<?=$member[ID]?>"  onDblClick="changename(<?=$member['ID']?>,<?=$idserver?>,this.value,<?=$member['AccountID']?>)" value="<?=$member['Name']?>" class=""><a style="TEXT-DECORATION: underline" href="?mod=<?=$mod?>&file=banklist&action=manage&idserver=<?=$idserver?>&AccountID=<?=$member['AccountID']?>" target="_blank"  title="打开该角色仓库"><?=$member['Name']?></a> <a style="TEXT-DECORATION: underline;color:orange" href="?mod=<?=$mod?>&file=loglist&action=manage&idserver=<?=$idserver?>&userID=<?=$member['ID']?>" target="_blank" title="打开该角色日志">[日志]</a></td>
<td style="text-align:center" id="Level_<?=$member['ID']?>"><?=$member['Level']?></td>
<td style="text-align:center" id="Gold_<?=$member['ID']?>"><?=$member['Gold']?></td>
<td style="text-align:center" id="Credit_<?=$member['ID']?>"><?=$member['Credit']?></td>
<td style="text-align:center" id="del_<?=$member[ID]?>"><?php if($member['deleted'] == 0){ ?> <input style="color:green" name="button" type="button" class="btn" onClick="savedel(<?=$member['ID']?>,<?=$idserver?>)" value=" 正常 "> <?php }else{ ?><input style="color:#F00" name="button" type="button" class="btn" onClick="savedel(<?=$member['ID']?>,<?=$idserver?>)" value="已删除"><? }?></td>
<td style="text-align:center" id="button_<?=$member['ID']?>">
<input style="color:#555" name="button" type="button" class="btn" onClick="showcontent(<?=$member[ID]?>)" value="修改数据"> <input style="color:#555" name="button" type="button" class="btn" onClick="chkcopy('<?=$idserver?>','<?=$member[ID]?>')" value="检查复制"></td>
</tr>
<tr align="center">
<td colspan="7" style="display:none;padding-left:0px;width:0px;height:0px" id="content_<?=$member['ID']?>">
<table cellpadding="2" cellspacing="1" class="tableborder2" width="100%">
  <tbody>
    <tr>
      <td width="14%" style="text-align:right"><strong>主要信息：</strong></td>
      <td width="50%">
	  <input type="text" id="Level<?=$member[ID]?>" value="<?=$member['Level']?>"  style="width:41px" onClick="this.select()">级 
	  <input type="text" id="EXP<?=$member[ID]?>" value="<?=$member['EXP']?>" size="15" onClick="this.select()">经验
	  <input type="text" id="Gold<?=$member[ID]?>" value="<?=$member['Gold']?>" size="12" onClick="this.select()">游戏币<br>

	  <select id="Faction<?=$member[ID]?>">
	  <option value="0" <?php if($member['Faction']=="0"){ ?> selected <?php } ?>>周</option>
	  <option value="1" <?php if($member['Faction']=="1"){ ?> selected <?php } ?>>商</option>
	  </select>朝 
	  <select id="MetierLevel<?=$member[ID]?>">
	  <option value="0" <?php if($member['MetierLevel']=="0"){ ?> selected <?php } ?>>未转职</option>
	  <option value="1" <?php if($member['MetierLevel']=="1"){ ?> selected <?php } ?>> 一转 </option>
	  <option value="2" <?php if($member['MetierLevel']=="2"){ ?> selected <?php } ?>> 二转 </option>
	  </select><font color="#990000"><?php if($member['Metier'] == 1) { ?>战士<?php }elseif($member['Metier'] == 2) { ?>凤舞<?php }elseif($member['Metier'] == 3) { ?>术士<?php }elseif($member['Metier'] == 4) { ?>道士<?php }else{ ?>异常<? } ?></font>
	  <input type="text" id="PK<?=$member[ID]?>" value="<?=$member['PK']?>" size="5" onClick="this.select()">PK值 
	  <input type="text" id="Credit<?=$member[ID]?>" value="<?=$member['Credit']?>" size="4" onClick="this.select()">声望
	  </td>
      <td width="13%" style="text-align:right"><strong>创建时间：<?php if($member[deleted] == 1) { ?><br><font color=red>删除时间：</font><? } ?></strong></td>
      <td width="23%">
      <?=$member['CreateDate']?><?php if($member[deleted] == 1) { ?><br><font color=red><?=$member['DeleteDate']?></font><? } ?>		</td>
    </tr>
	<tr>
      <td style="text-align:right"><strong>当前属性：<br>可用属性：</strong></td>
      <td>
	  <input type="text" id="Con<?=$member[ID]?>" value="<?=$member['Con']?>" size="4" onClick="this.select()">体 
	  <input type="text" id="Str<?=$member[ID]?>" value="<?=$member['Str']?>" size="4" onClick="this.select()">力 
	  <input type="text" id="Int<?=$member[ID]?>" value="<?=$member['Int']?>" size="4" onClick="this.select()">智 
	  <input type="text" id="Dex<?=$member[ID]?>" value="<?=$member['Dex']?>" size="4" onClick="this.select()">敏 
	  <input type="text" id="Hit<?=$member[ID]?>" value="<?=$member['Hit']?>" size="4" onClick="this.select()">精<br>
	  <input type="text" id="AP<?=$member[ID]?>" value="<?=$member['AP']?>" size="4" onClick="this.select()">AP 
	  <input type="text" id="SP<?=$member[ID]?>" value="<?=$member['SP']?>" size="4" onClick="this.select()">SP	  </td>
      <td style="text-align:right"><strong>在线时间：</strong></td>
      <td>
      <input type="text" id="OnlineTime<?=$member[ID]?>" value="<?=$member['OnlineTime']?>" size="13" onClick="this.select()">分钟	  </td>
    </tr>
	
	<tr>
      <td style="text-align:right"><strong>技能数据：</strong></td>
      <td>
	  <input type="text" id="Skills<?=$member[ID]?>" value="<?=$member['Skills']?>" size="55" onClick="this.select()"></td>
      <td style="text-align:right"><strong>任务数据：</strong></td>
      <td>
      <input type="text" id="Task<?=$member[ID]?>" value="<?=$member['Task']?>" size="22" onClick="this.select()"></td>
    </tr>
	<tr>
      <td style="text-align:right"><strong>装备数据：</strong></td>
      <td colspan="3">
	  <textarea type="text" id="Items<?=$member[ID]?>" cols="92" rows="8"><?=$member['Items']?></textarea></td>
      </tr>
	<tr>
      <td><input style="color:#f00;font-weight:bold" name="button" type="button" class="btn" onClick="javascript:openwinx('?mod=<?=$mod?>&file=searchitem&idserver=<?=$idserver?>','','800','600')" value=" !查询道具 "></td>
      <td><input style="color:#333" name="button" type="button" class="btn" onClick="savecontents('<?=$member[ID]?>','<?=$idserver?>')" value=" 保存数据 "> <input style="color:#f00" name="button" type="button" class="btn" onClick="checkonline('<?=$idserver?>','<?=$member[ID]?>')" value=" 检查是否在线 "> <input style="color:chocolate" name="button" type="button" class="btn" onClick="goback('<?=$member[ID]?>')" value=" 返回 "></td>
      <td colspan="2" style="color:darkgreen">提示：所有淡黄色区域均可进行修改!</td>
      </tr>
</table></td>
</tr>
<?php } 
}
?>
<!--
<div style="display:none"><input style="color:orange" name="button" type="button" class="btn" onClick="openwinx('?mod=<?=$mod?>&file=<?=$file?>&action=senditem&idserver=<?=$idserver?>&iduser=<?=$member[ID]?>','upload','800','600')" value="发送道具"></div>
-->
</table>
<table cellpadding="0" cellspacing="0" border="0" width="100%" height="30">
  <tr>
    <td align="center" id="pages"><?=$pages?></td>
  </tr>
</table>
<script language="javascript">
<?php
sajax_show_javascript();
?>
function savecontents(iduser,idserver){
 var Level=document.getElementById("Level"+iduser).value;
 var EXP=document.getElementById("EXP"+iduser).value;
 var PK=document.getElementById("PK"+iduser).value;
 var Credit=document.getElementById("Credit"+iduser).value;
 var Faction=document.getElementById("Faction"+iduser).value;
 var MetierLevel=document.getElementById("MetierLevel"+iduser).value;
 var Gold=document.getElementById("Gold"+iduser).value;
 var Con=document.getElementById("Con"+iduser).value;
 var Str=document.getElementById("Str"+iduser).value;
 var Int=document.getElementById("Int"+iduser).value;
 var Dex=document.getElementById("Dex"+iduser).value;
 var Hit=document.getElementById("Hit"+iduser).value;
 var AP=document.getElementById("AP"+iduser).value;
 var SP=document.getElementById("SP"+iduser).value;
 var OnlineTime=document.getElementById("OnlineTime"+iduser).value;
 var Skills=document.getElementById("Skills"+iduser).value;
 var Task=document.getElementById("Task"+iduser).value;
 var Items=document.getElementById("Items"+iduser).value;
 document.cookie="cookskills=";
 document.cookie="cooktask=";
 document.cookie="cookitems=";
 document.cookie="cookskills=" + Skills;
 document.cookie="cooktask=" + Task;
 document.cookie="cookitems=" + Items;


 x_savecontents(iduser,idserver,Level,EXP,PK,Credit,Faction,MetierLevel,Gold,Con,Str,Int,Dex,Hit,AP,SP,OnlineTime,savecontents_cb)
 
 function savecontents_cb(z){
  if( z == "true"){
   window.alert("更新成功！");
   
   var a = document.getElementsByTagName("tr");
   for (var i=0; i<a.length; i++)
   if (a[i].value == "closes") a[i].style.display = "block";
   document.getElementById("pages").style.display="block";
   document.getElementById("button_"+iduser).style.display="block";
   document.getElementById("content_"+iduser).style.display="none";
   document.getElementById("name_"+iduser).className="";
   document.getElementById("name_"+iduser).style.backgroundColor="";
   document.getElementById("del_"+iduser).className="";
   document.getElementById("del_"+iduser).style.backgroundColor="";
   document.getElementById("Level_"+iduser).innerHTML=Level;
   document.getElementById("Gold_"+iduser).innerHTML=Gold;
   document.getElementById("Credit_"+iduser).innerHTML=Credit;
   
	}else{
	window.alert(z);
	}
 }
}

function goback(iduser)
{
   var a = document.getElementsByTagName("tr");
   for (var i=0; i<a.length; i++)
   if (a[i].value == "closes") a[i].style.display = "block";
   document.getElementById("pages").style.display="block";
   document.getElementById("button_"+iduser).style.display="block";
   document.getElementById("content_"+iduser).style.display="none";
   document.getElementById("name_"+iduser).className="";
   document.getElementById("name_"+iduser).style.backgroundColor="";
   document.getElementById("del_"+iduser).className="";
   document.getElementById("del_"+iduser).style.backgroundColor="";
}
function changename(iduser,idserver,oldname,idacc){
 document.getElementById("name_"+iduser).innerHTML="<input id='iname_"+iduser+"' type='text' style='width:170px' value='"+oldname+"' onBlur=savename("+iduser+","+idserver+",'"+oldname+"',"+idacc+")>";
 document.getElementById("iname_"+iduser).select();
}
function savename(iduser,idserver,oldname,idacc){
  var newname = document.getElementById("iname_"+iduser).value;
  if(/\s/.test(oldname))
  {
    window.alert("原角色含有空格，不能修改！");
	document.getElementById("name_"+iduser).innerHTML="<a href='?mod=<?=$mod?>&file=acclist&action=manage&idserver=<?=$idserver?>&idx="+idacc+"' target='_blank'>"+oldname+"</a> <a style='TEXT-DECORATION: underline;color:orange' href='?mod=<?=$mod?>&file=loglist&action=manage&idserver=<?=$idserver?>&userID="+iduser+"' target='_blank'>[日志]</a>";
	return false;
  }
  if(/\s/.test(newname))
  {
    window.alert("新名字含有空格，不能修改！");
	document.getElementById("name_"+iduser).innerHTML="<a href='?mod=<?=$mod?>&file=acclist&action=manage&idserver=<?=$idserver?>&idx="+idacc+"' target='_blank'>"+oldname+"</a> <a style='TEXT-DECORATION: underline;color:orange' href='?mod=<?=$mod?>&file=loglist&action=manage&idserver=<?=$idserver?>&userID="+iduser+"' target='_blank'>[日志]</a>";
	return false;
  }
  if(oldname == newname){
    window.alert("新角色名不能与原角色名一样!");
	document.getElementById("name_"+iduser).innerHTML="<a href='?mod=<?=$mod?>&file=acclist&action=manage&idserver=<?=$idserver?>&idx="+idacc+"' target='_blank'>"+oldname+"</a> <a style='TEXT-DECORATION: underline;color:orange' href='?mod=<?=$mod?>&file=loglist&action=manage&idserver=<?=$idserver?>&userID="+iduser+"' target='_blank'>[日志]</a>";
	return false;
  }
 x_savename(iduser,idserver,oldname,newname,savename_cb)
 
 function savename_cb(z){
  if(z == "true"){
    document.getElementById("name_"+iduser).innerHTML="<a href='?mod=<?=$mod?>&file=acclist&action=manage&idserver=<?=$idserver?>&idx="+idacc+"' target='_blank'>"+newname+"</a> <a style='TEXT-DECORATION: underline;color:orange' href='?mod=<?=$mod?>&file=loglist&action=manage&idserver=<?=$idserver?>&userID="+iduser+"' target='_blank'>[日志]</a>";
	document.getElementById("name_"+iduser).value=newname;
  }else{
    window.alert(z);
	document.getElementById("name_"+iduser).innerHTML="<a href='?mod=<?=$mod?>&file=acclist&action=manage&idserver=<?=$idserver?>&idx="+idacc+"' target='_blank'>"+oldname+"</a> <a style='TEXT-DECORATION: underline;color:orange' href='?mod=<?=$mod?>&file=loglist&action=manage&idserver=<?=$idserver?>&userID="+iduser+"' target='_blank'>[日志]</a>";
  }
 }
}

function savedel(iduser,idserver){

 x_savedel(iduser,idserver,savedel_cb)
 
 function savedel_cb(z){
    if(z == "toomuck"){
	 window.alert("该角色帐号下有两个以上的可用角色，不能进行恢复！");
	 return false;
	}else{
    document.getElementById("del_"+iduser).innerHTML=z;
	}
 }
}

function checkonline(idserver,AccountID){

 x_checkonline(idserver,AccountID,checkonline_cb)
 
 function checkonline_cb(z){
    window.alert(z);
 }
}

function chkcopy(idserver,iduser){
if(confirm("该操作比较耗时且占用数据库资源，你确认要查询吗？检查结果将出现在框架左上角！")){ 
 OpenDiv();
 $("checksuess").innerHTML="<span style='font-size:14px;color:blue;font-weight:bold'>正在查询，请稍等...</span>";
 x_chkcopy(idserver,iduser,chkcopy_cb)
 }
 function chkcopy_cb(z){
	$("checksuess").innerHTML=z;
	//window.alert(z);
 }
}

function showcontent(iduser)
{
   var a = document.getElementsByTagName("tr");
   for (var i=0; i<a.length; i++)
   if (a[i].value == "closes") a[i].style.display = "none";
   document.getElementById("trline_"+iduser).style.display="block";
   document.getElementById("content_"+iduser).style.display="block";
   document.getElementById("pages").style.display="none";
   document.getElementById("button_"+iduser).style.display="none";
   document.getElementById("name_"+iduser).className="selecton";
   document.getElementById("name_"+iduser).style.backgroundColor="#fff8e7";
   document.getElementById("del_"+iduser).className="selecton";
   document.getElementById("del_"+iduser).style.backgroundColor="#fff8e7";
  
}

 function window.onload(){
   if(document.body.readyState=="complete"){
     part_one.style.display='none';
   }
 }
</script>
<script type="text/javascript">
//function $(){return document.getElementById?document.getElementById(arguments[0]):eval(arguments[0]);}
var OverH,OverW,ChangeDesc,ChangeH=60,ChangeW=100;
var Nw=10,Nh=10;
   function OpenDiv(_Dw,_Dh) {
	_Dw =350;
	_Dh = 310;
	window.scrollTo(0, 0);
	OverH=_Dh;OverW=_Dw;ChangeDesc='';
	$("Loading").style.display='block';
	$("Loading_Bg").style.display='';
	var _H = document.documentElement.scrollHeight;
	_H = _H<document.documentElement.clientHeight ? document.documentElement.clientHeight : _H;
	$("Loading_Bg").style.width = document.documentElement.clientWidth+"px";
	$("Loading_Bg").style.height = document.documentElement.clientHeight+"px";
	if(_Dw>_Dh){
		ChangeH=Math.ceil((_Dh-10)/((_Dw-10)/50));
	}else if(_Dw<_Dh){
		ChangeW=Math.ceil((_Dw-10)/((_Dh-10)/50));
	}
	OpenNow();
}
function OpenNow() {
	if (Nw>OverW-ChangeW)ChangeW=8;
	if (Nh>OverH-ChangeH)ChangeH=8;
	Nw=Nw+ChangeW;Nh=Nh+ChangeH;
	if(OverW>Nw||OverH>Nh) {
		if(OverW>Nw) {
			$("Loading").style.width=Nw+100+"px";
			var _L=(document.documentElement.clientWidth-Nw)/2-30;if(_L<0)_L=0;
			$("Loading").style.left=_L+"px";
		}
		if(OverH>Nh) {
			$("Loading").style.height=Nh+"px";
			var _T=(document.documentElement.clientHeight-Nh)/2+0;if(_T<0)_T=0;
			$("Loading").style.top=_T+"px"
		}
		//window.setTimeout("OpenNow()",10);
                OpenNow();
	}else{
		Nw=10;Nh=10;ChangeH=50;ChangeW=50;
		$('divload').style.display='block';
		$("Loading").style.background='transparent';
		$("Loading").style.border='0px';
		$("Loading").style.filter='alpha(opacity=100)';
		$("Loading").style.opacity='1';
		$("Loading_Bg").style.filter='alpha(opacity=50)';
	}
}
function CloseLoad() {
	if(Nw!=10) return;
	$("Loading").style.display='none';
	$("Loading_Bg").style.display='none';
}


//-->
</script>
<div id="Loading_Bg"></div>
<div id="Loading">
<div id='divload'>
<span style="float:right;padding-right:10px"><A href="javascript:void(0)" onclick="CloseLoad()">关闭</A></span>
<H4 style="color:#333">检查结果：</H4>
<TABLE class=mw_tabA cellSpacing=0 cellPadding=0 width="90%" align=center 
border=0>
  <TBODY>
  <TR>
    <TD id="checksuess"><span style='font-size:14px;color:blue;font-weight:bold'>正在查询，请稍等...</span></TD>
</TR>
</TBODY></TABLE>
</DIV>
</div>
</div>
</body>
</html>
