<?php

class Produto_GruposestadiosfenologicosController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_nome_grupo' => 'Nome',
		'ds_chave_grupo' => 'Chave'
	);
	
	public function init() {
		$this->view->title = 'Produto » Cadastro » Grupos Estádios Fenológicos';
	}
	
	public function setBack() {
		$this->view->back = '/produto/gruposestadiosfenologicos';
	}
	
	public function getModel() {
		return new Produto_Model_GruposEstadiosFenologicos();
	}
	
	public function getForm() {
		return new Produto_Form_GruposEstadiosFenologicos();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_nome_grupo')) {
			$where[] = array (
				'field' => 'ds_nome_grupo',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_nome_grupo').'%'
			);
		}
		
		if ($this->getRequest()->getParam('ds_chave_grupo')) {
			$where[] = array (
				'field' => 'ds_chave_grupo',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_chave_grupo').'%'
			);
		}
		
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array (
				'field' => 'fl_ativo',
				'operator' => '=',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		
		return $where;
	}
}
