<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=popbox}-->
<!--{include file=elements/header.js.html type=valid}-->
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="topContent">
				<div class="sitmap">
					<span class="r"><!--{include file="elements/uuadvad.html"}--></span>互动社区&nbsp;&gt;&nbsp;会员管理&nbsp;&gt;&nbsp;会员列表
				</div>
			</div>
			<div class="tabcontent">
				<a href="index.php?r=User.userlist" class="nolink">会员列表</a>
				<a href="index.php?r=SiteSet.userset" class="link">属性设置</a>
				<a href="index.php?r=User.honourlist" class="link">会员头衔</a>
				<a href="index.php?r=SiteSet.experienceset" class="link">会员经验</a>
				<a href="index.php?r=User.forumroleimg" class="link">管理员身份勋章</a>
				<a href="index.php?r=User.albumlist" class="link">会员相册</a>
				<a href="index.php?r=User.listphotoframe" class="link">会员相框</a>
				<a href="index.php?r=User.msglist" class="link">会员消息</a>
				<a href="index.php?r=SiteSet.msgboxset" class="link">信箱设置</a>
				<!--a href="index.php?r=Menu" class="link">菜单管理</a-->
			</div>
			<div id="secrightContent">
				<div class="tableContent2">
					<form id="searchForm" action="index.php" method="get" onSubmit="setDisabled('button', window.document);">
						<input type="hidden" name="r" value="user.userlist"/>
						<input type="hidden" id="honour_id" name="honour_id" value="<!--{$honour_id}-->"/>
						<input type="hidden" id="status" name="status" value="<!--{$status}-->"/>
						<div class="searchbar">
							用户昵称&nbsp;<input type="text" class="text" name="pet_name" value="<!--{$pet_name}-->"/>
							&nbsp;用户ID&nbsp;<input type="text" class="text" name="id" value="<!--{$id}-->"/>
							&nbsp;<button type="submit" class="but2font">查询</button>
						</div>
					</form>
					<div class="operation">
						<button type="button" class="but2font" onClick="window.location.href='index.php?r=User.add&returnParams=<!--{$returnParams}-->'">新增</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=User.deleteuser&returnParams=<!--{$returnParams}-->','recordId', 'ids', '删除之后，信息无法恢复，是否确定删除？')">删除</button>							
						<button type="button" class="but4font" onClick="sendMsg('user')">发信息</button>
						<button type="button" class="but5font" onClick="sendMsg('all')">全员发信息</button>
						<button type="button" class="but2font" onClick="updateUserStatus('1')">解锁</button>
						<button type="button" class="but2font" onClick="updateUserStatus('9')">锁定</button>
					</div>
					<table class="tbl_list" width="100%" cellpadding="0" cellspacing="0" border="0">
						<tr class="thead">
							<td width="5%"><input type="checkbox" class="checkall"/></td>
							<td width="13%">用户ID</td>
							<td width="13%">用户昵称</td>
							<td width="15%">注册日期</td>
							<td width="15%">最后登录时间</td>
							<td width="10%">管理权限</td>
							<td width="10%"><select onChange="$('#honour_id').val($(this).val());$('#searchForm').submit();">
								<option value="">头衔</option>
								<!--{foreach from=$honourList item=honour}-->
								<option value="<!--{$honour.id}-->" <!--{if $honour.id==$honour_id}-->selected<!--{/if}-->><!--{$honour.honour_name}--></option>
								<!--{/foreach}-->
							</select></td>
							<td width="10%"><select onChange="$('#status').val($(this).val());$('#searchForm').submit();">
								<option value="">状态</option>
								<option value="1" <!--{if $status == 1}-->selected<!--{/if}-->>正常</option>
								<option value="9" <!--{if $status == 9}-->selected<!--{/if}-->>锁定</option>
							</select></td>
							<td width="10%">操作</td>
						</tr>
						<!--{foreach from=$data item=data}-->
						<tr onMouseOver="chgTrColor(this)" onMouseOut="chgTrColor(this)">
							<td><!--{if $data.cms_role != 1}--><input type="checkbox" name="recordId" value="<!--{$data.id}-->" cms_role="<!--{$data.cms_role}-->"/><!--{/if}--></td>
							<td><!--{$data.id}--></td>
							<td><!--{$data.pet_name}--></td>
							<td><!--{$data.create_date|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
							<td><!--{$data.last_login_date|date_format:"%Y-%m-%d %H:%M:%S"}--></td>
							<td>
								<!--{if $data.cms_role == 1}-->超级管理员<!--{elseif $data.cms_role == 2}-->管理员 <br/><a href="index.php?r=User.usermenu&userId=<!--{$data.id}-->&returnParams=<!--{$returnParams}-->">设置权限</a><!--{else}-->普通用户 <br/> <a href="index.php?r=User.usermenu&userId=<!--{$data.id}-->&returnParams=<!--{$returnParams}-->">设置权限</a><!--{/if}-->
								</td>
							<td><!--{if $data.honour_name}--><!--{$data.honour_name}--><!--{else}--><!--{if $data.experience>0}--><!--{$honour_maxname}--><!--{else}--><!--{$honour_minname}--><!--{/if}--><!--{/if}--></td>
							<td><!--{if $data.status == 1}-->正常<!--{elseif $data.status == 9}-->锁定<!--{/if}--></td>
							<td><!--{if $admin.cms_role == 1 || $data.cms_role == 9 || $data.id == $admin.id}-->
								<a href="index.php?r=user.update&userId=<!--{$data.id}-->&returnParams=<!--{$returnParams}-->">修改</a>&nbsp;
								<a href="javascript:resetPassword('<!--{$data.id}-->', '<!--{$returnParams}-->')">重置密码</a>
								<!--{/if}--></td>
						</tr>
						<!--{/foreach}-->
					</table>
					<div class="operation">
						<button type="button" class="but2font" onClick="window.location.href='index.php?r=User.add&returnParams=<!--{$returnParams}-->'">新增</button>
						<button type="button" class="but2font" onClick="batchOperate('index.php?r=User.deleteuser&returnParams=<!--{$returnParams}-->','recordId', 'ids', '删除之后，信息无法恢复，是否确定删除？')">删除</button>							
						<button type="button" class="but4font" onClick="sendMsg('user')">发信息</button>
						<button type="button" class="but5font" onClick="sendMsg('all')">全员发信息</button>
						<button type="button" class="but2font" onClick="updateUserStatus('1')">解锁</button>
						<button type="button" class="but2font" onClick="updateUserStatus('9')">锁定</button>
					</div>
					<div class="page"><!--{$pager}--></div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
function sendMsg(type){
	if (type == "user") {
		var ids = "";
		$("input[name=recordId]").each(function(){
			if ($(this).attr("checked") == true) {
				ids = ids+","+$(this).val();
			}
		});
		if (ids == "") {
			alert("请选择用户");
			return false;
		} else {
			ids = ids.substr(1);
		}
	}
	var str = "<form id=\"msgForm\" action=\"index.php?r=User.sendmsg\" method=\"post\">";
	if (type == "user") {
		str += "<input type=\"hidden\" name=\"ids\" value=\""+ids+"\"/>";
	}
	str += "<table class=\"tbl_edit\" width=\"100%\"><tr>";
	if (type == "user") {
		str += "<td class=\"td_name\">发送用户ID</td>";
		str += "<td class=\"td_content\">"+ids+"</td>";
	} else {
		str += "<td class=\"td_name\">发送用户</td>";
		str += "<td class=\"td_content\">全员</td>";
	}
	str += "</tr><tr>";
	str += "<td class=\"td_name\">信息内容</td>";
	str += "<td class=\"td_content\"><textarea class=\"textarea\" id=\"msgContent\" name=\"msgContent\"></textarea><span id=\"span_msgContent\"></span></td>";
	str += "</tr><tr>";
	str += "<td class=\"noborder\"></td>";
	str += "<td class=\"noborder\"><button type=\"submit\" class=\"butsubmit\">提交</button></td>";
	str += "</tr></table></form>";
	$.popbox({title:"发送信息", content:str});
	$("#msgForm").validate({
		rules: {
			"msgContent": "required"
		},
		messages: {
			"msgContent": "请输入信息内容"
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			setDisabled(":button", window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		},
		onkeyup: false
	});
}

function resetPassword(userId, returnParams){
	var str = "<form id=\"resetForm\" action=\"index.php?r=User.resetpassword\" method=\"post\">";
	str += "<input type=\"hidden\" name=\"data[User][id]\" value=\""+userId+"\"/>";
	str += "<input type=\"hidden\" name=\"returnParams\" value=\""+decodeURIComponent(returnParams)+"\"/>";
	str += "<table class=\"tbl_edit\" width=\"100%\"><tr>";
	str += "<td class=\"td_name\">新密码<span class=\"red\">*</span></td>";
	str += "<td class=\"td_content\"><input class=\"text\" id=\"password\" name=\"data[User][password]\"><span id=\"span_password\"></span></td>";
	str += "</tr><tr>";
	str += "<td class=\"noborder\"></td>";
	str += "<td class=\"noborder\"><button type=\"submit\" class=\"butsubmit\">提交</button></td>";
	str += "</tr></table></form>";
	$.popbox({title:"重置密码", content:str});
	$("#resetForm").validate({
		rules: {
			"data[User][password]" : {
				required : true,
				rangelength : [4, 16]
			}
		},
		messages: {
			"data[User][password]" : {
				required : "密码不能为空",
				rangelength : jQuery.format("密码长度必须为{0}至{1}位")
			}
		},
		errorPlacement: function(error, element){
			$("#span_" + element.attr("id")).html(error).attr("class", "error");
		},
		submitHandler: function(form){
			setDisabled(":button",window.document);
			form.submit();
		},
		errorClass: "invalid",
		success: function(label){
			label.parent().html("&nbsp;").attr("class", "valid");
		},
		onkeyup: false
	});
}

function updateUserStatus(status){
	var item = $("[name=recordId]");
	var id = "";
	if (item.size() > 0) {
		item.each(function(){
			if ($(this).attr("checked") == true) {
				id += $(this).val();
				id += ",";
			}
		});
	}
	id = id.substr(0, id.lastIndexOf(","));
	if (id == "") {
		alert("请选择记录");
		return false;
	} else {
		var cmsRoleFlag = 0;
		item.each(function(){
			if ($(this).attr("checked") == true && $(this).attr("cms_role") <= <!--{$admin.cms_role}-->) {
				cmsRoleFlag = 1;
				return false;
			}
		});
		if (cmsRoleFlag == 1) {
			alert("不能修改其他管理员帐号");
			return false;
		}
		if (status == 1) {
			if (confirm("确定解锁？")) {
				window.location.href = "index.php?r=User.updateuserstatus&status=1&ids="+id+"&returnParams=<!--{$returnParams}-->";
			}
		} else {
			if (confirm("确定锁定？")) {
				window.location.href = "index.php?r=User.updateuserstatus&status=9&ids="+id+"&returnParams=<!--{$returnParams}-->";
			}
		}
	}
}
</script>
</html>