<?php
	require("__include-common.php");
	require("../account/__logincheck.php");
	require("../__common__/include-common-mp-list.php");
	if ($_SESSION['システム管理者'] <> "YES") {
		error_exit("不正アクセス：編集権限がありません。", True);
	}
	$mp_list_arg = array();
	$mp_list_arg['account_id']	= "ALL";		// 共通
	$mp_list_arg['table_name_view']	= "v_category2";
	$mp_list_arg['table_name_edit']	= "v_category2";
	$mp_list_arg['table_name_update']	= "m_category2";
	$mp_list_arg['id_item']		= "id_category2";
	$mp_list_arg['must_item']	= "c_category2Name";
	$mp_list_arg['input_new']	= "no";
	$item_tbl = array();
	$item_tbl[] = array(	"表示名"=>"カテゴリ",	"列名"=>"id_category", "http_arg_GET名"=>"cat",
				"type"=>"select", "参照テーブル"=>"m_category", "参照テーブル表示列"=>"c_categoryName",
				"参照テーブル表示順"=>"c_categoryDisplayOrder");
	$item_tbl[] = array(	"表示名"=>"id2", "列名"=>"id_category2",
				"type"=>"no_edit");
	$item_tbl[] = array(	"表示名"=>"サブカテゴリ", "列名"=>"c_category2Name",
				"type"=>"text", "size"=>40, "ime-mode"=>"active", "文字検索"=>"Y");
	$item_tbl[] = array(	"表示名"=>"表示順", "列名"=>"c_category2DisplayOrder",
				"type"=>"text", "size"=>4, "ime-mode"=>"disabled", "toInt"=>"Y");
	$order_tbl = array();
	$order_tbl[] = array(	"表示名"=>"表示順", "get_order_name"=>"cate",
				"order_by"=>"c_categoryDisplayOrder,id_category, c_category2DisplayOrder,id_category2");		/* default */
	$order_tbl[] = array(	"表示名"=>"カテゴリ名順", "get_order_name"=>"date",
				"order_by"=>"c_category2Name");
	$http_arg = array();
	$http_arg['pl'] = PAGE_LINE_DEFAULT;		// mp_list 必須
	$http_arg['sort'] = '';				// mp_list 必須
	$http_arg['cat'] = '';				// mp_list 必須
	$http_arg['key'] = '';				// mp_list 必須
	if (isset($_POST['登録'])) {
		check_post_account($_POST['login_id'], $_POST['current_id']);
		mp_list_update($mp_list_arg, $item_tbl, $order_tbl, $http_arg);
	} else {
		_GET_to_http_arg_pool($http_arg, $table_name);
		html_header(HTML_TITLE, '', '#ffffff');
		page_header();
		contents_header('off');
		if ($_GET['edit'] == "y") {
			mp_list_edit($mp_list_arg, $item_tbl, $order_tbl, $http_arg);
		} else {
			mp_list_view($mp_list_arg, $item_tbl, $order_tbl, $http_arg);
		}
		page_footer();
		html_footer();
	}
	exit();
