<?php
if (!defined('IN_59MIAO'))
{
	exit('Access Defined');
}
//皇冠店铺控制器
class RecshopAction extends Action {
	public function __construct(){
		parent::__construct();
	}	
	public function index(){
		parent::page();		
		$this->_tpl->assign('RecShop',$this->_model->findAll());
		$this->_tpl->display(SMARTY_ADMIN.'recommendshop/show.tpl');
	}		
	public function add(){
		if (isset($_POST['send'])) $this->_model->add() ? $this->_redirect->succ('?a=recshop', '推荐店铺新增成功！') : $this->_redirect->error('推荐店铺新增失败！');

		$this->_tpl->assign('level',$this->level_array());
		$this->_tpl->display(SMARTY_ADMIN.'recommendshop/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('?a=recshop', '推荐店铺修改成功！') : $this->_redirect->error('推荐店铺修改失败！');
		if (isset($_GET['id'])) {
			$this->_tpl->assign('OneRecShop', $this->_model->findOne());
			$this->_tpl->assign('level',$this->level_array());
			$this->_tpl->display(SMARTY_ADMIN.'recommendshop/update.tpl');
		}
	}
	public function sort() {
		if (isset($_POST['send'])) $this->_model->sort() ? $this->_redirect->succ(Tool::getPrevPage()) : $this->_redirect->error('排序失败！');
	}
	private function level_array(){
		$array=array('1'=>'1黄冠','2'=>'2黄冠','3'=>'3黄冠','4'=>'4黄冠','5'=>'5黄冠','11'=>'1金冠','12'=>'2金冠','13'=>'3金冠','14'=>'4金冠','15'=>'5金冠');		
		return $array;
	}	
}
?>