<?php
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
//等级控制器
class LevelAction extends Action {
	public function __construct() {
		parent::__construct();
	}	
	public function index(){		
		parent::page();
		$this->_tpl->assign('AllLevel', $this->_model->findAll());
		$this->_tpl->display(SMARTY_ADMIN.'user_manage/level_show.tpl');
	}	
	//添加等级
	public function add() {		
		if (isset($_POST['send'])) $this->_model->add() ? $this->_redirect->succ('?a=level', '等级新增成功！') : $this->_redirect->error('等级新增失败！');
		$this->_tpl->display(SMARTY_ADMIN.'user_manage/level_add.tpl');
	}
	
	//删除等级
	public function delete() {
		if (isset($_GET['id'])) $this->_model->delete() ? $this->_redirect->succ(Tool::getPrevPage(), '等级删除成功！') : $this->_redirect->error('等级删除失败！');
	}
	//修改等级
	public function update() {
		if (isset($_POST['send'])) $this->_model->update() ? $this->_redirect->succ(Tool::getPrevPage(), '等级名称修改成功！') : $this->_redirect->error('等级名称修改失败！');
		if (isset($_GET['id'])) {			
			$this->_tpl->assign('OneLevel', $this->_model->findOne());
			$this->_tpl->display(SMARTY_ADMIN.'user_manage/level_update.tpl');
		}
	}
}
?>