<?php

class Sinistro_TipovistoriaController extends Agro_Controller_Action {
	public $_columnList = array(
		'ds_tipo_vistoria' => 'Nome',
		'ds_chave' => 'Chave'
	);
	
	public function setBack() {
		$this->view->back = '/sinistro/tipovistoria';
	}
	
	public function init() {
		$this->view->title = 'Sinistro » Cobrança » Configurações » Tipos de Vistoria';
	}
	
	public function getModel() {
		return new Sinistro_Model_Tiposvistoria();
	}
	
	public function getForm() {
		return new Sinistro_Form_Tipovistoria();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('ds_tipo_vistoria')) {
			$where[] = array (
				'field' => 'ds_tipo_vistoria',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_tipo_vistoria').'%'
			);
		}
		
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array (
				'field' => 'fl_ativo',
				'operator' => '=',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		
		return $where;
	}
	
}