<?php
require 'inc.php';
$obj_model=new cls_tab_sys_model();
$arr_sys_model=$obj_model->sysmodel;
if($get_act=="del"){
	$arr_return=$obj_model->on_del($get_id);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="del_sel"){
	$arr_return=$obj_model->on_del($get_modelid);
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="sort_up"){
	$arr_return=$obj_model->on_sort_act($get_id,"up");
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}
if($get_act=="sort_down"){
	$arr_return=$obj_model->on_sort_act($get_id,"down");
	if($arr_return["err"]!="") $obj_msg->alert($arr_return["err"]);
}

switch($get_act)
{	
	case 'save':
	{
		$arr_fields=array();
		$arr_fields["model_id"]=$get_id;
		if(isset($get_model_regkey)) $arr_fields["model_regkey"]=$get_model_regkey;
		$arr_fields["model_name"]=$get_model_name;
		$arr_fields["model_intro"]=$get_model_intro;
		$arr_fields["model_author"]=$get_model_author;
		$arr_fields["model_sort"]=$get_model_sort;
		$arr_msg=$obj_model->on_save($arr_fields);
		if($arr_msg["err"]=="") $get_id=$arr_msg["id"];
		include 'tpl/_msg.tpl.php';
	    break;
	}
	case 'edit':
	{
		$arr_model=array();
		$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."sys_model where model_id='".$get_id."'");
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$arr_model = $obj_rs;
		}
		include 'tpl/model.edit.tpl.php';
		break;
	}
	case 'add':
	{
		$get_id=0;
		include "tpl/model.add.tpl.php";
		break;
	}
	default:
	{
		$arr_model=array();
		$obj_result = $obj_db->query("SELECT * FROM ".DB_PRE."sys_model order by model_sort");
		while($obj_rs = $obj_db->fetch_array($obj_result))
		{
			$arr_model[] = $obj_rs;
		}
		include "tpl/model.tpl.php";
	}
}
?>
