<?php
if (!defined('USING_SYSTEM')) exit;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="admin/images/page.css" />
<script type="text/javascript" src="skins/common/images/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="admin/images/page.js"></script>
<title>Filiant Control Panel</title>
</head>
<body>
<div class="bigTips"<?php echo ($tips=='')?'':' style="display:block;"' ?>><?php echo $tips ?></div>
<form id="mainForm" action="" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th colspan="3">添加用户</th>
  </tr>
  <tr>
    <td class="title" width="150">用户名</td>
    <td width="400"><input name="usernameTxt" id="usernameTxt" type="text" class="textbox" /></td>
    <td class="tips">用户的登录账户名</td>
  </tr>
  <tr>
    <td class="title" width="150">邮箱</td>
    <td width="400"><input name="emailTxt" id="emailTxt" type="text" class="textbox" /></td>
    <td class="tips">用户的邮箱</td>
  </tr>
  <tr>
    <td class="title">密码</td>
    <td><input name="passwordTxt" id="passwordTxt" type="text" class="textbox" /></td>
    <td class="tips">用户的登录密码</td>
  </tr>
  <tr>
    <td class="title">用户组</td>
    <td class="dropdown">
      <select name="groupTxt" id="groupTxt">
<?php
$groups = xGroup::getAll();
foreach($groups as $group) {
	echo '<option value="'.$group['id'].'">'.$group['name'].'</option>';
}
?>
      </select>
<script type="text/javascript">
$('#groupTxt').val('<?php echo $_APP['register']['group'] ?>');
</script>
    </td>
    <td class="tips">添加用户后的默认用户组</td>
  </tr>
</table>
<div class="controls">
  <a class="button" href="javascript:void(0);" onclick="$('#mainForm').trigger('submit');return false;">添加<i></i></a>
</div>
</form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th colspan="3">用户列表</th>
  </tr>
  <tr>
    <th>用户名</th>
    <th>邮箱</th>
    <th width="100">操作</th>
  </tr>
<?php
$ucr = xGbl::$mysql->exec('SELECT COUNT(0) FROM `'.TB_USERS.'`;');
list($uc) = $ucr->fetch_array();
$ucr->free();
$xPage = xPages::makeList($page, $uc);
if($usersRes = xUser::listItems('`id`,`username`,`email`',false, $page)) {
	while($user = $usersRes->fetch_assoc()) {
?>
  <tr>
    <td><?php echo $user['username'] ?></td>
    <td><?php echo $user['email'] ?></td>
    <td align="center"><a class="button" href="?ac=p201edit&id=<?php echo $user['id'] ?>">编辑<i></i></a></td>
  </tr>
<?php
	}
	$usersRes->free();
}
?>
</table>
<div class="controls">
<?php echo xPages::makeHTML($xPage, '<a class="button" href="?ac=p201&page=[p]" style="padding:0 15px;">[p]<i></i></a> ', '<span style="padding:0 15px;display:inline-block;">[p]</span> ') ?>
</div>
</body>
</html>