<?php
/**
 * 商品分类管理
 * $Id: product_category_list.php,v 1.1 2015/10/08 11:18:46 wanggb Exp $
 * @author wanggb
 * @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);
$level = ParamUtil::getRequestString("level", "N5");
$category_id = ParamUtil::getRequestString("category_id", "1");

$session_name = "subject_dat_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;
		$page_num = $_SESSION[$session_name]["page_num"];
		$level = $_SESSION[$session_name]["level"];
		$category_id = $_SESSION[$session_name]["category_id"];
	}
} else {
	if (isset($_SESSION[$session_name])){
		unset($_SESSION[$session_name]);
	}
	// 再設定
	$_SESSION[$session_name]["page_num"] = $page_num;
	$_SESSION[$session_name]["level"] = $level;
	$_SESSION[$session_name]["category_id"] = $category_id;
}

// 一览取得
$param = array();
$param["level"] = $level;
$param["category_id"] = $category_id;
$param["delete_flg"] = false;
$subject_dat_list = SubjectDat::getList($param, "id", "desc", 0, 200);
$total_count = SubjectDat::getListCount($param);

$category_list = SubjectCategory::getList();

// ページ
$_SCRIPT_FILE = array("scripts/validators.js", "scripts/subject.js");
$layout_pages = array();
$layout_pages["top"] = "menu.inc";
$layout_pages["menu_clicked"] = "li_data";
$layout_pages["middle"] = "subject_dat_list.inc";
require_once(MANAGER_TEMPLATE_DIR_PATH . "/layout/topmenutopsub_layout.inc");
exit;