public function resultadoAgenciaBancariaAction()
 {
     header("Content-Type: text/html; charset=ISO-8859-1");
     $this->_helper->layout->disableLayout();
     $post = Zend_Registry::get('post');
     $arrBusca = array();
     if (!empty($post->banco)) {
         $arrBusca["c.Banco = ?"] = $post->banco;
     }
     if (!empty($post->uf)) {
         $tblUf = new Uf();
         $rsUf = $tblUf->buscar(array("idUF = ?" => $post->uf))->current();
         $arrBusca["a.Uf = ?"] = $rsUf->Sigla;
     }
     if (!empty($post->cidade)) {
         $tblMunicipio = new Municipios();
         $rsMunicipio = $tblMunicipio->buscar(array("idMunicipioIBGE = ?" => $post->cidade))->current();
         $arrBusca["a.Cidade = ?"] = $rsMunicipio->Descricao;
     }
     if (!empty($post->mecanismo)) {
         $arrBusca["c.Mecanismo = ?"] = $post->mecanismo;
     }
     if (!empty($post->area)) {
         $arrBusca["p.Area = ?"] = $post->area;
     }
     if (!empty($post->tipoPessoa)) {
         $arrBusca["i.tipoPessoa = ?"] = $post->tipoPessoa;
     }
     if (!empty($post->agencia)) {
         $arrBusca["c.Agencia = ?"] = retiraMascara($post->agencia);
     }
     if (!empty($post->dtLoteRemessaCB) || $post->tpDtLoteRemessaCB != '') {
         if ($post->tpDtLoteRemessaCB == "igual") {
             $arrBusca['DtLoteRemessaCB >= ?'] = ConverteData($post->dtLoteRemessaCB, 13) . " 00:00:00";
             $arrBusca['DtLoteRemessaCB <= ?'] = ConverteData($post->dtLoteRemessaCB, 13) . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCB == "maior") {
             $arrBusca['DtLoteRemessaCB >= ?'] = ConverteData($post->dtLoteRemessaCB, 13) . " 00:00:00";
         } elseif ($post->tpDtLoteRemessaCB == "menor") {
             $arrBusca['DtLoteRemessaCB <= ?'] = ConverteData($post->dtLoteRemessaCB, 13) . " 00:00:00";
         } elseif ($post->tpDtLoteRemessaCB == "OT") {
             $arrBusca['DtLoteRemessaCB = ?'] = date("Y-m-") . (date("d") - 1) . " 00:00:00";
         } elseif ($post->tpDtLoteRemessaCB == "U7") {
             $arrBusca['DtLoteRemessaCB > ?'] = date("Y-m-") . (date("d") - 7) . " 00:00:00";
             $arrBusca['DtLoteRemessaCB < ?'] = date("Y-m-d") . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCB == "SP") {
             $arrBusca['DtLoteRemessaCB > ?'] = date("Y-m-") . (date("d") - 7) . " 00:00:00";
             $arrBusca['DtLoteRemessaCB < ?'] = date("Y-m-d") . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCB == "MM") {
             $arrBusca['DtLoteRemessaCB > ?'] = date("Y-m-01") . " 00:00:00";
             $arrBusca['DtLoteRemessaCB < ?'] = date("Y-m-d") . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCB == "UM") {
             $arrBusca['DtLoteRemessaCB > ?'] = date("Y-") . (date("m") - 1) . "-01 00:00:00";
             $arrBusca['DtLoteRemessaCB < ?'] = date("Y-") . (date("m") - 1) . "-31 23:59:59";
         } else {
             $arrBusca['DtLoteRemessaCB > ?'] = ConverteData($post->dtLoteRemessaCB, 13) . " 00:00:00";
             if ($post->dtLoteRemessaCB_Final != "") {
                 $arrBusca['DtLoteRemessaCB < ?'] = ConverteData($post->dtLoteRemessaCB_Final, 13) . " 23:59:59";
             }
         }
     }
     if (!empty($post->dtLoteRemessaCL) || $post->tpDtLoteRemessaCL != '') {
         if ($post->tpDtLoteRemessaCL == "igual") {
             $arrBusca['DtLoteRemessaCL >= ?'] = ConverteData($post->dtLoteRemessaCL, 13) . " 00:00:00";
             $arrBusca['DtLoteRemessaCL <= ?'] = ConverteData($post->dtLoteRemessaCL, 13) . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCL == "maior") {
             $arrBusca['DtLoteRemessaCL >= ?'] = ConverteData($post->dtLoteRemessaCL, 13) . " 00:00:00";
         } elseif ($post->tpDtLoteRemessaCL == "menor") {
             $arrBusca['DtLoteRemessaCL <= ?'] = ConverteData($post->dtLoteRemessaCL, 13) . " 00:00:00";
         } elseif ($post->tpDtLoteRemessaCL == "OT") {
             $arrBusca['DtLoteRemessaCL = ?'] = date("Y-m-") . (date("d") - 1) . " 00:00:00";
         } elseif ($post->tpDtLoteRemessaCL == "U7") {
             $arrBusca['DtLoteRemessaCL > ?'] = date("Y-m-") . (date("d") - 7) . " 00:00:00";
             $arrBusca['DtLoteRemessaCL < ?'] = date("Y-m-d") . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCL == "SP") {
             $arrBusca['DtLoteRemessaCL > ?'] = date("Y-m-") . (date("d") - 7) . " 00:00:00";
             $arrBusca['DtLoteRemessaCL < ?'] = date("Y-m-d") . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCL == "MM") {
             $arrBusca['DtLoteRemessaCL > ?'] = date("Y-m-01") . " 00:00:00";
             $arrBusca['DtLoteRemessaCL < ?'] = date("Y-m-d") . " 23:59:59";
         } elseif ($post->tpDtLoteRemessaCL == "UM") {
             $arrBusca['DtLoteRemessaCL > ?'] = date("Y-") . (date("m") - 1) . "-01 00:00:00";
             $arrBusca['DtLoteRemessaCL < ?'] = date("Y-") . (date("m") - 1) . "-31 23:59:59";
         } else {
             $arrBusca['DtLoteRemessaCL > ?'] = ConverteData($post->dtLoteRemessaCL, 13) . " 00:00:00";
             if ($post->dtLoteRemessaCL_Final != "") {
                 $arrBusca['DtLoteRemessaCL < ?'] = ConverteData($post->dtLoteRemessaCL_Final, 13) . " 23:59:59";
             }
         }
     }
     //xd($arrBusca);
     $tbl = new ContaBancaria();
     //xd($_POST);
     if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
         //buscando os registros no banco de dados
         $tamanho = -1;
         $inicio = -1;
         $pag = 0;
         $totalPag = 0;
         $total = 0;
         $fim = 0;
         $rs = $tbl->buscar($arrBusca, array(), $tamanho, $inicio);
         $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-agencia-bancaria.phtml', 'tipo' => $post->tipo));
     } else {
         $pag = 1;
         //$get = Zend_Registry::get('get');
         if (isset($post->pag)) {
             $pag = $post->pag;
         }
         if (isset($post->tamPag)) {
             $this->intTamPag = $post->tamPag;
         }
         $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
         $fim = $inicio + $this->intTamPag;
         $total = $tbl->pegaTotal($arrBusca);
         $total = $total["total"];
         //xd($total);
         $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
         $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
         if ($fim > $total) {
             $fim = $total;
         }
         //Varifica se foi solicitado a ordenação
         if (!empty($post->ordenacao)) {
             $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
         } else {
             $ordem = array('Descricao ASC');
         }
         $rs = $tbl->buscar($arrBusca, $ordem, $tamanho, $inicio);
         //xd($total);
     }
     $this->view->contasBancarias = $rs;
     $this->view->pag = $pag;
     $this->view->total = $total;
     $this->view->inicio = $inicio + 1;
     $this->view->fim = $fim;
     $this->view->totalPag = $totalPag;
     $this->view->parametrosBusca = $_POST;
 }