Ejemplo n.º 1
0
 public function resultadoExtratoPautaReuniaoCnicAction()
 {
     header("Content-Type: text/html; charset=ISO-8859-1");
     $this->_helper->layout->disableLayout();
     $post = Zend_Registry::get('post');
     $arrBusca = array("Mecanismo = ?" => 1);
     if (!empty($post->banco)) {
         $arrBusca["c.Banco = ?"] = $post->banco;
     }
     if (!empty($post->nrReuniao)) {
         $arrBusca["pa.NumeroReuniao = ?"] = $post->nrReuniao;
     }
     if (!empty($post->orgao)) {
         $arrBusca["o.Codigo = ?"] = $post->orgao;
     }
     if (!empty($post->tipoParecer)) {
         $arrBusca["pa.TipoParecer = ?"] = $post->tipoParecer;
     }
     if (!empty($post->area)) {
         $arrBusca["a.Codigo = ?"] = $post->area;
     }
     if (!empty($post->situacao)) {
         $arrBusca["s.Codigo = ?"] = $post->situacao;
     }
     //xd($arrBusca);
     foreach ($_POST["visaoAgente"] as $campo) {
         $arrCampos = explode("_", $campo);
         if ($arrCampos[0] == "cmpsOrd") {
             if (substr($arrCampos[1], 0, 1) != "#") {
                 $campos[] = $arrCampos[1];
             }
         }
     }
     //xd($campos);
     //        foreach($_POST["visaoAgente"] as $campo){
     //            $arrCampos = explode("_", $campo);
     //            if($arrCampos[0] == "cmpsOrd"){
     //                if(substr($arrCampos[1], 0, 1) != "#"){
     //                    $campos[] = $arrCampos[1];
     //                }
     //            }
     //        }
     //$campos = implode(", ", $campos);
     //xd($campos);
     //xd($_POST);
     $tbl = new Projetos();
     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->buscarProjetosPautaReuniao($arrBusca, array(new Zend_Db_expr("Area ASC")), $tamanho, $inicio);
         $this->_forward('preparar-xls-pdf', null, null, array('dados' => $rs, 'view' => 'operacional/preparar-xls-pdf-extrato-pauta-reuniao-cnic.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->pegaTotalProjetosPautaReuniao($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;
         }
         $rs = $tbl->buscarProjetosPautaReuniao($arrBusca, array(new Zend_Db_expr("Area ASC")), $tamanho, $inicio);
         //xd($rs);
     }
     $this->view->projetos = $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;
 }