<?php

class Produto_GrupamentoculturasController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_nome_grupamento_cultura' => 'Nome',
		'ds_chave_grupamento_cultura' => 'Chave'
	);	
	
	public function init() {
		$this->view->title = 'Produto » Cadastro » Grupamento Culturas';
	}
	
	public function setBack() {
		$this->view->back = '/produto/grupamentoculturas';
	}
	
	public function getModel() {
		return new Produto_Model_GrupamentoCulturas();
	}
	
	public function getForm() {
		return new Produto_Form_GrupamentoCulturas();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_nome_grupamento_cultura')) {
			$where[] = array (
				'field' => 'ds_nome_grupamento_cultura',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_nome_grupamento_cultura').'%'
			);
		}
		
		if ($this->getRequest()->getParam('ds_chave_grupamento_cultura')) {
			$where[] = array (
				'field' => 'ds_chave_grupamento_cultura',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_chave_grupamento_cultura').'%'
			);
		}
				
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array (
				'field' => 'fl_ativo',
				'operator' => ' = ',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}		
		
		return $where;
	}
}