<?php

class Produto_ValidacoesController extends Agro_Controller_Action {
	
	public function init() {
		$this->view->title = 'Produto » Cadastro » Validações';
		$this->view->orderby = $this->getRequest()->getParam('o');
		$this->view->orderDirection = $this->getRequest()->getParam('s');
	}

	public function itensseguradosAction() {
		$this->view->id_validacao = $this->getRequest()->getParam('id_validacao');
		parent::indexAction();
	}
		
	public function getModel() {
		return new Produto_Model_Validacoes();
	}
	
	public function getForm() {
		return new Produto_Form_Validacoes();
	}
	
	public function getFilter() {
		$where = array();
		
		if ($this->getRequest()->getParam('id_tipo_validacao')) {
			$where[] = array (
				'field' => 'v.id_tipo_validacao',
				'operator' => ' = ',
				'value' => $this->getRequest()->getParam('id_tipo_validacao')
			);
		}
		
		if ($this->getRequest()->getParam('fl_ativo')) {
			$where[] = array (
				'field' => 'v.fl_ativo',
				'operator' => ' = ',
				'value' => $this->getRequest()->getParam('fl_ativo')
			);
		}
		
		if ($this->getRequest()->getParam('ds_nome_validacao')) {
			$where[] = array (
				'field' => 'ds_nome_validacao',
				'operator' => 'ilike',
				'value' => '%'.$this->getRequest()->getParam('ds_nome_validacao').'%'
			);
		}
		return $where;
	}

}