<?
include "../CheckUser.php";
include_once("../comm/db_sql.php");
include_once("../comm/config.php");
include_once("../comm/connect.php");
include_once("../comm/Function.php");
include_once("function.php");
include_once("../../Smarty/Smarty.class.php");

$page_show = new Smarty(); 
$page_show->template_dir = "./template";
$page_show->compile_dir = "./templates_c"; 
$page_show->left_delimiter = "<{";      
$page_show->right_delimiter = "}>";

$check=$_GET['action'];
$channel=$_GET['channel'];
if(empty($channel))
	{	
		$category_record=category_query_all_yes($db);
		$channel=1;
	}else
	{
		$category_record=category_query_channel_yes($db,$channel);
	}
	
$id=$_GET['id'];

$channel_record_select=channel_query_category($db);
$page_show->assign("channel_record_array", $channel_record_select);

if ($check=="edit"){
		$sub_category_record=sub_category_query_one($id,$db);
		$action="edit&id=".$id;
		$channel=$sub_category_record['channel'];
	}else if ($check=="copy"){
		$sub_category_record=sub_category_query_one($id,$db);
		$action="add";
		$channel=$sub_category_record['channel'];
	}else
	{	
		$action="add";
	}
//修改
$page_show->assign("category_name", $sub_category_record['category_name']);
$page_show->assign("name", $sub_category_record['name']);
$page_show->assign("channel", $sub_category_record['channel']);
$page_show->assign("category", $sub_category_record['category']);

//系统
$page_show->assign("action", $action);
$page_show->assign("check", $check);


//数组

$page_show->assign("category_record_array", $category_record);

$page_show->display("add_sub_category.html"); 
?>