コード例 #1
0
 public function imprimirMinhasSolicitacoesAction()
 {
     $this->intTamPag = 10;
     //DEFINE PARAMETROS DE ORDENACAO / QTDE. REG POR PAG. / PAGINACAO
     if ($this->_request->getParam("qtde")) {
         $this->intTamPag = $this->_request->getParam("qtde");
     }
     $order = array();
     //==== parametro de ordenacao  ======//
     if ($this->_request->getParam("ordem")) {
         $ordem = $this->_request->getParam("ordem");
         if ($ordem == "ASC") {
             $novaOrdem = "DESC";
         } else {
             $novaOrdem = "ASC";
         }
     } else {
         $ordem = "ASC";
         $novaOrdem = "ASC";
     }
     //==== campo de ordenacao  ======//
     if ($this->_request->getParam("campo")) {
         $campo = $this->_request->getParam("campo");
         $order = array($campo . " " . $ordem);
         $ordenacao = "&campo=" . $campo . "&ordem=" . $ordem;
     } else {
         $campo = null;
         $order = array(2, 4, 6);
         $ordenacao = null;
     }
     $pag = 1;
     $get = Zend_Registry::get('get');
     $this->view->idPreProjeto = $get->idPreProjeto;
     if (isset($get->pag)) {
         $pag = $get->pag;
     }
     $inicio = $pag > 1 ? ($pag - 1) * $this->intTamPag : 0;
     /* ================== PAGINACAO ======================*/
     $auth = Zend_Auth::getInstance();
     // pega a autenticação
     $where = array();
     $where['sol.idAgente = ?'] = $auth->getIdentity()->IdUsuario;
     $where['sol.stEstado = ?'] = 1;
     // Atendido
     if (isset($_POST['tipoFiltro']) || isset($_GET['tipoFiltro'])) {
         $filtro = isset($_POST['tipoFiltro']) ? $_POST['tipoFiltro'] : $_GET['tipoFiltro'];
         $this->view->filtro = $filtro;
         switch ($filtro) {
             case '':
                 $where['sol.stEstado = ?'] = 1;
                 // Atendido
                 $this->view->nmPagina = 'Atendido';
                 break;
             case 'solicitado':
                 $where['sol.stEstado = ?'] = 0;
                 // Solicitado
                 $this->view->nmPagina = 'Solicitado';
                 break;
             case 'negado':
                 $where['sol.stEstado = ?'] = 2;
                 // Negado
                 $this->view->nmPagina = 'Negado';
                 break;
         }
     } else {
         $where['sol.stEstado = ?'] = 1;
         // Atendido
         $this->view->nmPagina = 'Atendido';
     }
     $tbSolicitarItem = new tbSolicitarItem();
     $total = $tbSolicitarItem->buscarItens($where, $order, null, null, true);
     $fim = $inicio + $this->intTamPag;
     $totalPag = (int) ($total % $this->intTamPag == 0 ? $total / $this->intTamPag : $total / $this->intTamPag + 1);
     $tamanho = $fim > $total ? $total - $inicio : $this->intTamPag;
     $busca = $tbSolicitarItem->buscarItens($where, $order, $tamanho, $inicio);
     $this->view->qtdRegistros = $total;
     $this->view->dados = $busca;
     $this->_helper->layout->disableLayout();
     // Desabilita o Zend Layout
 }