 <?
/**
 * 用户管理
 * $Id: user_list.php
 * @author taocy
 * @package manager.public_html
 */

// 底层包含
require_once("manager_include.inc");

// 登录检查
require_once("check_login.inc");

// 不做权限检查
if (!checkAuthority("ADMIN,MANAGER,STAFF")) {
	// エラー表示
	$layout_pages = array();
	$layout_pages["footer"] = "footer.inc";
	$layout_pages["top"] = "menu.inc";
	$layout_pages["middle"] = "error.inc";
	$message = "权限不足，请联系系统管理员。";
	require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/topmenutopsub_layout.inc");
	exit;
}

//取得参数
$search_flg = ParamUtil::getRequestBoolean("search_flg",false);
$page_num = ParamUtil::getRequestNumber("page_num", 1);
$mobile = ParamUtil::getRequestNumber("mobile");
$nickname = ParamUtil::getRequestString("nickname");

$order_key = ParamUtil::getRequestString("order_key","update_date");
$direction = ParamUtil::getRequestString("direction","desc");

$session_name = "user_class_list";
if (!$search_flg) {
	if (isset($_SESSION[$session_name])){
		// ページ番、ソート順など保存
		if (isset($_SESSION[$session_name]["page_num"]) && !isset($_REQUEST["page_num"])) {
			$page_num = $_SESSION[$session_name]["page_num"];
		}
		$_SESSION[$session_name]["page_num"] = $page_num;
		$mobile = $_SESSION[$session_name]["mobile"];
		$nickname = $_SESSION[$session_name]["nickname"];
		$order_key = $_SESSION[$session_name]["order_key"];
		$direction = $_SESSION[$session_name]["direction"];
	}
} else {
	if (isset($_SESSION[$session_name])){
		unset($_SESSION[$session_name]);
	}
	// 再設定
	$_SESSION[$session_name]["mobile"] = $mobile;
	$_SESSION[$session_name]["nickname"] = $nickname;
	$_SESSION[$session_name]["order_key"] = $order_key;
	$_SESSION[$session_name]["direction"] = $direction;
}

//当前页取得
$paging_url_link = "user_class_list.php";

$param = array();
$param["delete_flg"] = false;
if (!empty($mobile)) {
	$param["mobile"] = $mobile;
}

if (!empty($nickname)) {
	$param["nickname"] = $nickname;
}

$total_count = 0;
//总页数取得
$total_count = UserClassDat::getListCount($param);

if ($total_count > 0) {
	$page_row = MANAGER_DEFAULT_ROW_COUNT;
	$offset = ($page_num - 1) * $page_row;
	//一览取得
	$user_class_list = UserClassDat::getList($param, $order_key, $direction, $offset, $page_row);
	$page_count = ceil($total_count / $page_row);
	$show_page_num = 5;
	$page_range = PagingHandler::getPageRange($page_num, $page_count, $show_page_num);
	$page_first = $page_range[0];
	$page_end = $page_range[1];
}

// 页面
$_SCRIPT_FILE = array("scripts/validators.js", "scripts/user_class.js");
$layout_pages = array();
$layout_pages["top"] = "menu.inc";
$layout_pages["menu_clicked"] = "li_user";
$layout_pages["middle"] = "user_class_list.inc";
require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/topmenutopsub_layout.inc");
exit;
?>