/** * Busca os dados necessários para preencher o relatório */ public function consultarAction() { parent::noLayout(); $oForm = new Fiscal_Form_RelatorioNfsePeriodo(); $this->view->form = $oForm; try { $aParametros = $this->getRequest()->getParams(); if (!$oForm->isValid($aParametros)) { throw new Exception('Informe um período válido!'); } $oNotaModel = new Contribuinte_Model_Nota(); $aNotas = $oNotaModel->getNotaPorPeriodo($aParametros); if (count($aNotas) == 0) { throw new Exception('Nenhum registro encontrado!'); } $oArquivoPDF = $this->gerarPdf($aNotas); $aRetornoJson['status'] = TRUE; $aRetornoJson['url'] = $this->view->baseUrl("/fiscal/relatorio-nfse-periodo/download/arquivo/{$oArquivoPDF->filename}"); $aRetornoJson['success'] = $this->translate->_('Relatório gerado com sucesso.'); } catch (Exception $oErro) { $aRetornoJson['status'] = FALSE; $aRetornoJson['error'][] = $this->translate->_($oErro->getMessage()); } echo $this->getHelper('json')->sendJson($aRetornoJson); }