<?php

class Sistema_TipoArquivoController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_tipo_arquivo' => 'Tipo'
	);
	
	public function init() {
		$this->view->title = 'Sistema » Configurações » Tipo de Arquivo';	
	}
	
	public function setBack() {
		$this->view->back = '/sistema/tipoarquivo';
	}
	
	public function getModel() {
		return new Sistema_Model_TipoArquivo();
	}
	
	public function getForm() {
		return new Sistema_Form_TipoArquivo();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_tipo_arquivo')) {
			$where[] = array(
				'field' => 'ds_tipo_arquivo',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_tipo_arquivo').'%'
			);
		}
		
		if ($this->getRequest()->getParam('ds_nome_arquivo')) {
			$where[] = array(
				'field' => 'ds_nome_arquivo',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_nome_arquivo').'%'
			);
		}
		
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array(
				'field' => 'fl_ativo',
				'operator' => '=',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		
		return $where;
	}
}
