<?php

class Sistema_VariavelController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_nome' => 'Nome'
	);
	
	public function init() {
		$this->view->title = 'Sistema » Configurações » Variáveis';
	}
	
	public function setBack() {
		$this->view->back = '/sistema/variavel';
	}
	
	public function getModel() {
		return new Sistema_Model_Variaveis();
	}
	
	public function getForm() {
		return new Sistema_Form_Variavel();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_nome')) {
			$where[] = array(
				'field' => 'ds_nome',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_nome').'%'
			);
		}
		
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array(
				'field' => 'fl_ativo',
				'operator' => '=',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		
		return $where;
	}
}