Пример #1
0
 public function resultadoPcRegiaoUfCidadeAction()
 {
     header("Content-Type: text/html; charset=ISO-8859-1");
     $this->_helper->layout->disableLayout();
     $post = Zend_Registry::get('post');
     //recuperando filtros do POST
     $arrBusca = array("modalidade = ?" => 76);
     if ($post->regiao != "") {
         $arrBusca["u.Regiao = ?"] = $post->regiao;
     }
     if ($post->uf != "") {
         $arrBusca["u.CodUfIbge = ?"] = $post->uf;
     }
     //if($post->cidade != ""){ $arrBusca["i.Cidade = ?"] = $post->cidade; }
     if (!empty($post->cidade)) {
         $tblMunicipio = new Municipios();
         $rsMunicipio = $tblMunicipio->buscar(array("idMunicipioIBGE = ?" => $post->cidade))->current();
         $arrBusca["i.Cidade = ?"] = $rsMunicipio->Descricao;
     }
     //Varifica se foi solicitado a ordenação
     if (!empty($post->ordenacao)) {
         $ordem[] = "{$post->ordenacao} {$post->tipoOrdenacao}";
     } else {
         $ordem = array("5", "4", "3");
     }
     $tbl = new Projetos();
     $total = $tbl->pontoCulturaRegiaoUfCidade($arrBusca, $ordem, null, null);
     $total = count($total);
     if ($post->tipo == 'xls' || $post->tipo == 'pdf') {
         //buscando os registros no banco de dados
         $tamanho = -1;
         $inicio = -1;
         $pag = 0;
         $totalPag = 0;
         $fim = 0;
         $rs = $tbl->pontoCulturaRegiaoUfCidade($arrBusca, $ordem, $tamanho, $inicio);
         $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'relatorio/preparar-xls-pdf-pc-regiao-uf-cidade.phtml', 'tipo' => $post->tipo));
     } else {
         //controlando a paginacao
         $this->intTamPag = 10;
         $pag = 1;
         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;
         $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
         $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
         $rs = $tbl->pontoCulturaRegiaoUfCidade($arrBusca, $ordem, $tamanho, $inicio);
     }
     $this->view->registros = $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;
 }