<?php

class Produto_EventoController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_nome_evento' => 'Nome',
		'ds_chave_evento' => 'Chave'
	);
	
	public function init() {
		$this->view->title = 'Produto » Cadastro » Eventos';
	}
	
	public function getModel() {
		return new Produto_Model_Eventos();
	}
	
	public function getForm() {
		return new Produto_Form_Evento();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_nome_evento')) {
			$where[] = array(
				'field' => 'ds_nome_evento',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_nome_evento').'%'
			);
		}
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array (
				'field' => 'fl_ativo',
				'operator' => ' = ',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		return $where;
	}
		
}
