public function downloadLoteArtigosAction() { $this->autenticacao(); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $ano = (int) $this->getRequest()->getParam("ano", 0); $encontro = (int) $this->getRequest()->getParam("encontro", 0); $status = $this->getRequest()->getParam("status", "todos"); $model_encontro = new Application_Model_Encontro(); if ($ano < 1980 && $encontro > 0) { // busca por encontro $encontros = array($model_encontro->buscaEncontro($encontro)); } elseif ($ano > 1980 && $encontro < 1) { // busca por ano $encontros = $model_encontro->buscaEncontrosPorAno($ano); } else { // erro $this->_helper->flashMessenger->addMessage(array('error' => "Parâmetro(s) inválido(s). Utilize <b>ano</b> ou <b>encontro</b>.")); return $this->_helper->redirector->goToRoute(array(), 'default', true); } if (empty($encontros)) { $this->_helper->flashMessenger->addMessage(array('warning' => "Nenhum encontro cadastrado.")); return $this->_helper->redirector->goToRoute(array('module' => 'admin', 'controller' => 'relatorios', 'action' => 'index'), 'default', true); } // Compativel com PHP < 5.5 $id_encontros_array = array(); foreach ($encontros as $encontro) { array_push($id_encontros_array, $encontro["id_encontro"]); } // PHP >= 5.5 // $id_encontros_array = array_column($encontros, "id_encontro"); $model_artigo = new Application_Model_Artigo(); $rel = $model_artigo->buscaArtigos($id_encontros_array, $status); if (empty($rel)) { $this->_helper->flashMessenger->addMessage(array("alert" => "Não há registros a serem mostrados.")); return $this->_helper->redirector->goToRoute(array('module' => 'admin', 'controller' => 'relatorios', 'action' => 'index'), 'default', true); } $this->_exportLoteZip($rel); }
public function artigosListaXlsAction() { $this->autenticacao(); $ano = (int) $this->getRequest()->getParam("ano", 0); $status = $this->getRequest()->getParam("status"); if ($ano < 1980) { $this->_helper->flashMessenger->addMessage(array('error' => "Ano inválido. Comece de novo. " . "Caso o erro persista, contate o administrador.")); return $this->_helper->redirector->goToRoute(array(), 'default', true); } $model_encontro = new Application_Model_Encontro(); $encontros = $model_encontro->buscaEncontrosPorAno($ano); if (empty($encontros)) { $this->_helper->flashMessenger->addMessage(array('warning' => "Nenhum encontro cadastrado para o ano {$ano}.")); return $this->_helper->redirector->goToRoute(array('module' => 'admin', 'controller' => 'relatorios', 'action' => 'index'), 'default', true); } // Compativel com PHP < 5.5 $id_encontros_array = array(); foreach ($encontros as $encontro) { array_push($id_encontros_array, $encontro["id_encontro"]); } // PHP >= 5.5 // $id_encontros_array = array_column($encontros, "id_encontro"); $model_artigo = new Application_Model_Artigo(); $rel = $model_artigo->buscaArtigos($id_encontros_array, $status); if (empty($rel)) { $this->_helper->flashMessenger->addMessage(array("alert" => "O relatório não possui nenhum registro.")); return $this->_helper->redirector->goToRoute(array('module' => 'admin', 'controller' => 'relatorios', 'action' => 'index'), 'default', true); } $xls = new Sige_Xls_Exportar($rel, array('apelido_encontro', 'titulo', 'nome', 'email'), array('Evento', 'Título', 'Nome', 'E-mail')); $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $xls->exportar("relatorio_artigos_sige_" . date("Y-m-d-His") . ".xls"); }
private function _artigoSalvaPdf($p_arquivo, $responsavel, $id_encontro, $titulo) { $files = $p_arquivo->getFileInfo(); $artigos = array(); foreach ($files as $fileInfo) { try { $source = $fileInfo['tmp_name']; $nome = $fileInfo['name']; $tamanho = $fileInfo['size']; $finfo = finfo_open(FILEINFO_MIME_TYPE); $mime = finfo_file($finfo, $source); if (strcmp($mime, 'application/pdf') == 0) { $data = file_get_contents($source); $escaped = bin2hex($data); $model = new Application_Model_Artigo(); $id_artigo = $model->inserirDocumento($escaped, $nome, $tamanho, $responsavel, $id_encontro, $titulo); array_push($artigos, $id_artigo); } else { //throw new Exception("Este arquivo PDF pode estar corrompido. " // . "Por favor, verifique se o arquivo é realmente um PDF válido."); throw new Exception(_("This PDF file might be corrupted. Please check if this is a valid PDF file.")); } } catch (Zend_Db_Exception $e) { throw $e; } catch (Exception $e) { throw $e; } } return $artigos; }