<?php

class Sistema_ModelopreviaController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_titulo' => 'Nome'
	);
	
	public function init() {
		$this->view->title = 'Sistema » Configurações » Modelo de Laudo de Vistoria Prévia';
	}

	public function setBack() {
		$this->view->back = '/sistema/modeloprevia';
	}
	
	public function getModel() {
		return new Sistema_Model_ModeloPrevia();
	}
	
	public function getForm() {
		return new Sistema_Form_ModeloPrevia();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_titulo')) {
			$where[] = array (
				'field' => 'ds_titulo',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_titulo').'%'
			);
		}
		
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array (
				'field' => 'fl_ativo',
				'operator' => '=',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		
		return $where;
	}
}