<?php

class Sistema_AgenciaController extends Agro_Controller_Action {
    public $_columnList = array(
        'ds_agencia' => 'Nr. Agência',
        'ds_nome_agencia' => 'Agência',
        'ds_cnpj' => 'CNPJ',
        'ds_nome_banco' => 'Banco'
    );

    public function init() {
         $this->view->title = 'Sistema » Configurações » Agências';
    }

    public function getModel() {
        return new Sistema_Model_Agencias();
    }

    public function getForm() {
        return new Sistema_Form_Agencia();
    }

    public function getFilter() {
        $where = array();

        if ($this->getRequest()->getParam('ds_nome_agencia')) {
            $where[] = array(
                'field' => 'ds_nome_agencia',
                'operator' => 'ilike',
                'value' => '%'.$this->getRequest()->getParam('ds_nome_agencia').'%'
            );
        }

        if ($this->getRequest()->getParam('id_banco')) {
            $where[] = array(
                'field' => 'id_banco',
                'operator' => '=',
                'value' => $this->getRequest()->getParam('id_banco')
            );
        }

        if ($this->getRequest()->getParam('fl_ativo')) {
            $where[] = array(
                'field' => 'fl_ativo',
                'operator' => '=',
                'value' => $this->getRequest()->getParam('fl_ativo')
            );
        }

        return $where;
    }
}
