<?php

class Seguro_PendenciasvistoriadorController extends Agro_Controller_Action
{
    protected $_backAfterSave = false;

    public function getFilter(): array
    {
        $where = [
            [
                'field' => 'id_departamento',
                'operator' => '=',
                'value' => Sistema_Model_Departamentos::AGRO_TECNICA
            ]
        ];

        if ($this->_requestParams['ds_descricao']) {
            $where[] = [
                'field' => 'ds_descricao',
                'operator' => 'ilike',
                'value' => "%{$this->_requestParams['ds_descricao']}%"
            ];
        }

        if ($this->_requestParams['fl_ativo']) {
            $where[] = [
                'field' => 'fl_ativo',
                'operator' => '=',
                'value' => $this->_requestParams['fl_ativo'] === 'true' ? 't' : 'f'
            ];
        }

        return $where;
    }

    public function getForm(): Seguro_Form_PendenciasVistoriador
    {
        return new Seguro_Form_PendenciasVistoriador();
    }

    public function getModel(): Seguro_Model_PendenciasVistoriador
    {
        return new Seguro_Model_PendenciasVistoriador();
    }

    public function init()
    {
        $this->view->title = 'Seguro » Vistorias Prévias » Configurações » Pendências Vistoriador';
    }
}
