<?php
/*秀影广告控制器*/
class BillController extends Easy_Controller_Action{
	public $position = array();
	public $type = array();
	public function Init(){
		$this->_Bill = new BillModel();
		$this->_View->position = array('index_banner'=>'顶部banner', 'inddex_body'=>'首页中部',
			'index_bottom'=>'首页底部', 'category'=>'分类中间', 'display'=>'播放页面');
		$this->_View->type = array('picture'=>'图片', 'swf'=>'FLASH', 'text'=> '文字', 'code'=> 'js代码', 'html'=>'HTML代码' );
	}
	public function indexAction(){
		$this->_View->rows = $this->_Bill->getAll();
		$this->_View->printpage = $this->_Bill->printPage;
	}
	public function AddAction(){
		if ($this->_Request->isPost()){
			if ($this->_Bill->add($this->_Request->getPost())===false){
				$this->_View->message = $this->_Bill->error;
			}else{
				$this->_View->message = _('发布成功!');
			}
			exit($this->_View->render('message'));
		}
	}
	public function modifyAction(){
		if ($this->_Request->isPost()){
			if ($this->_Bill->modify($this->_Request->getPost())===false){
				$this->_View->message = $this->_Bill->error;
			}else{
				$this->_View->message = _('修改保存成功!');
			}
			exit($this->_View->render('message'));
		}else{
			$id = (int)$this->_Request->getParam('id');
			$this->_View->modify = $this->_Bill->getRow(array('id'=>$id));
		}
	}
	public function deleteAction(){
		$id = (int)$this->_Request->getParam('id');
		$this->_Bill->delete($id);
		$this->_View->message = _('删除成功!!');
		exit($this->_View->render('message'));
	}
	public function lockedAction(){
		$id = (int)$this->_Request->getParam('id');
		$this->_Bill->locked($id);
		header('location:'.$_SERVER['HTTP_REFERER']);
		exit;
	}
}
?>