/** * Construtor. */ public function __construct() { // Id do usuário na session $usuario = $this->getSession()->id_pessoa; $this->_service = new Avaliacao_Service_Boletim(array('matricula' => $this->getRequest()->matricula, 'usuario' => $usuario)); $this->_situacao = $this->_service->getSituacaoAluno(); // Se o parâmetro for passado, chama método para promover o aluno if (!is_null($this->getRequest()->promove)) { try { $this->_service->promover((bool) $this->getRequest()->promove); // Instancia o boletim para carregar service com as alterações efetuadas $this->_service = new Avaliacao_Service_Boletim(array('matricula' => $this->getRequest()->matricula, 'usuario' => $usuario)); } catch (CoreExt_Service_Exception $e) { // Ok, situação do aluno pode estar em andamento ou matrícula já foi promovida } } parent::__construct(); }
protected function _notasFaltasComponentes(Avaliacao_Service_Boletim $boletim) { $etapas = $boletim->getOption('etapas'); $notas = $boletim->getNotasComponentes(); if ($faltaPorComponente = $boletim->getRegra()->get('tipoPresenca') == RegraAvaliacao_Model_TipoPresenca::POR_COMPONENTE) { $faltas = $boletim->getFaltasComponentes(); } else { $faltas = $boletim->getFaltasGerais(); } $componentes = $boletim->getComponentes(); $medias = $boletim->getMediasComponentes(); $situacao = $boletim->getSituacaoAluno(); $etapas = range(0, $etapas - 1); $altura_linha = 15; // Calcula o espaço disponível para as notas e faltas $extraColumns = 2 + ($situacao->recuperacao == TRUE ? 1 : 0); $total = 782 - (80 + 60 * $extraColumns + 120); $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5); $this->pdf->escreve_relativo_center('Módulos', 30, $this->page_y + 2, 80, 13); $this->pdf->linha_relativa(30, $this->page_y, 0, $altura_linha, 0.1); $this->pdf->linha_relativa(80 + 30, $this->page_y, 0, $altura_linha, 0.1); $matriculaSituacao = App_Model_MatriculaSituacao::getInstance(); // Escreve as etapas $x = 80 + 30; $largura = $total / count($etapas); if ($faltaPorComponente) { $larguraDv = $largura / 2; } else { $larguraDv = $largura; } foreach ($etapas as $etapa) { $this->pdf->escreve_relativo_center($etapa + 1, $x, $this->page_y + 2, $largura, 13); $x += $largura; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } // Escreve os campos para Média final, Falta e Situação $labels = array(); $labels[] = 'Média final'; if ($situacao->recuperacao) { $labels[] = 'Exame'; } $labels[] = '% Presença'; $labels[] = 'Situação'; foreach ($labels as $label) { $largura = $label == 'Situação' ? 120 : 60; $this->pdf->escreve_relativo_center($label, $x, $this->page_y + 2, $largura, 13); $x += $largura; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } // Escreve os rótulos para notas e faltas $x = 80 + 30; // Nova linha $this->page_y += 15; $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5); $this->pdf->escreve_relativo_center('Componentes', 30, $this->page_y + 2, 80, 13); $this->pdf->linha_relativa(30, $this->page_y, 0, $altura_linha, 0.1); $this->pdf->linha_relativa(110, $this->page_y, 0, $altura_linha, 0.1); foreach ($etapas as $etapa) { $this->pdf->escreve_relativo_center('Nota', $x, $this->page_y + 2, $larguraDv, 13); $x += $larguraDv; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); if ($faltaPorComponente) { $this->pdf->escreve_relativo_center('Falta', $x, $this->page_y + 2, $larguraDv, 13); $x += $larguraDv; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } } for ($i = 0; $i < 3; $i++) { $x += 60; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } $yNotas = $this->page_y; // Imprime as notas dos componentes foreach ($componentes as $id => $componente) { $this->page_y += 15; $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5); $this->pdf->escreve_relativo_center($componente, 30, $this->page_y + 2, 80, 13); $this->pdf->linha_relativa(110, $this->page_y, 0, $altura_linha, 0.1); $x = 110; foreach ($etapas as $etapa) { if (!$this->em_branco) { $this->pdf->escreve_relativo_center($notas[$id][$etapa]->notaArredondada, $x, $this->page_y + 2, $larguraDv, 13); } $x += $larguraDv; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); if ($faltaPorComponente) { if (!$this->em_branco) { $this->pdf->escreve_relativo_center($faltas[$id][$etapa]->quantidade, $x, $this->page_y + 2, $larguraDv, 13); } $x += $larguraDv; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } } if ($faltaPorComponente) { $porcentagemPresenca = sprintf('%.2f', $situacao->falta->componentesCurriculares[$id]->porcentagemPresenca); } else { $porcentagemPresenca = '-'; } // Média, presenção e situação $data = array(); $data['media'] = $medias[$id][0]->mediaArredondada; if ($situacao->recuperacao) { $notaExame = $notas[$id][$etapa + 1]; $data['rc'] = $notaExame->etapa == 'Rc' ? $notaExame->notaArredondada : '-'; } $data['presenca'] = $porcentagemPresenca; $data['situacao'] = $matriculaSituacao->getValue($situacao->nota->componentesCurriculares[$id]->situacao); foreach ($data as $key => $value) { $largura = $key == 'situacao' ? 120 : 60; if (!$this->em_branco) { $this->pdf->escreve_relativo_center($value, $x, $this->page_y + 2, $largura, 13); } $x += $largura; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } } // Imprime a porcentagem total de presença e a situação $this->page_y += 15; $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5); $this->pdf->escreve_relativo_center('Faltas', 30, $this->page_y + 2, 80, 13); $this->pdf->linha_relativa(110, $this->page_y, 0, $altura_linha, 0.1); if (!$faltaPorComponente) { $x = 80 + 30; foreach ($etapas as $etapa) { $this->pdf->escreve_relativo_center($faltas[$etapa + 1]->quantidade, $x, $this->page_y + 2, $larguraDv, 13); $x += $larguraDv; $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); } $x = $x + 60 * ($situacao->recuperacao ? 2 : 1); } else { $x = $x - (120 + 60); } if (!$this->em_branco) { $this->pdf->escreve_relativo_center(sprintf('%.2f', $situacao->falta->porcentagemPresenca), $x, $this->page_y + 2, 60, 13); $this->pdf->escreve_relativo_center($matriculaSituacao->getValue($situacao->falta->situacao), $x + 60, $this->page_y + 2, 120, 13); } for ($i = 0; $i < 3; $i++) { $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1); $x += 60; } }
function renderHTML() { if ($_POST) { foreach ($_POST as $key => $value) { $this->{$key} = $value; } } if ($this->ref_ref_cod_serie) { $this->ref_cod_serie = $this->ref_ref_cod_serie; } $fonte = 'arial'; $corTexto = '#000000'; if (empty($this->ref_cod_turma)) { echo ' <script> alert("Erro ao gerar relatório!\\nNenhuma turma selecionada!"); window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1)); </script>'; return TRUE; } $obj_escola = new clsPmieducarEscola($this->ref_cod_escola); $det_escola = $obj_escola->detalhe(); $this->nm_escola = $det_escola['nome']; $obj_instituicao = new clsPmieducarInstituicao($det_escola['ref_cod_instituicao']); $det_instituicao = $obj_instituicao->detalhe(); $this->nm_instituicao = $det_instituicao['nm_instituicao']; $obj_turma = new clsPmieducarTurma($this->ref_cod_turma); $det_turma = $obj_turma->detalhe(); $this->nm_turma = $det_turma['nm_turma']; $obj_serie = new clsPmieducarSerie($this->ref_cod_serie); $det_serie = $obj_serie->detalhe(); $this->nm_serie = $det_serie['nm_serie']; $eh_multi_seriado = FALSE; if (is_numeric($det_turma['ref_ref_cod_serie_mult'])) { $series = array(); $series[$det_serie['cod_serie']] = $det_serie['nm_serie']; $obj_serie = new clsPmieducarSerie($det_turma['ref_ref_cod_serie_mult']); $det_serie = $obj_serie->detalhe(); $this->nm_serie .= ' / ' . $det_serie['nm_serie']; $series[$det_serie['cod_serie']] = $det_serie['nm_serie']; $eh_multi_seriado = TRUE; } $this->pdf = new clsPDF('Resultado Final', 'Resultado Final', 'A4', '', FALSE, FALSE); $this->pdf->OpenPage(); $this->addCabecalho(); $this->pdf->linha_relativa(30, 140, 540, 0); $this->pdf->linha_relativa(30, 140, 0, 30); $this->pdf->linha_relativa(570, 140, 0, 30); $this->pdf->linha_relativa(30, 170, 540, 0); $this->pdf->linha_relativa(60, 140, 0, 30); $this->pdf->linha_relativa(320, 140, 0, 30); $this->pdf->linha_relativa(380, 140, 0, 30); $this->pdf->linha_relativa(490, 140, 0, 30); $this->pdf->linha_relativa(380, 155, 190, 0); $this->pdf->linha_relativa(530, 155, 0, 15); $this->pdf->linha_relativa(450, 155, 0, 15); $this->pdf->escreve_relativo('Ord', 35, 150, 20, 20, NULL, 10); $this->pdf->escreve_relativo('Nome do aluno', 70, 150, 160, 20, NULL, 10); $this->pdf->escreve_relativo('Aprovado', 325, 150, 160, 20, NULL, 10); $this->pdf->escreve_relativo('Reprovado', 410, 142, 160, 20, NULL, 10); $this->pdf->escreve_relativo('Desempenho', 384, 156, 160, 20, NULL, 10); $this->pdf->escreve_relativo('Faltas', 455, 156, 160, 20, NULL, 10); $this->pdf->escreve_relativo('Alf.', 500, 156, 160, 20, NULL, 10); $this->pdf->escreve_relativo('N. Alf.', 535, 156, 160, 20, NULL, 10); $obj_matricula = new clsPmieducarMatriculaTurma(); $obj_matricula->setOrderby('m.ref_ref_cod_serie, nome_ascii'); if ($this->is_padrao) { $this->semestre = NULL; } $lst_matricula = $obj_matricula->lista(NULL, $this->ref_cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao, NULL, NULL, array(1, 2, 3), NULL, NULL, $this->ano, NULL, TRUE, NULL, NULL, TRUE, NULL, NULL, NULL, $det_turma['ref_ref_cod_serie_mult'], $this->semestre); $qtd_quebra = 43; $base = 155; $linha = 1; $total_aprovados = 0; $total_reprovados_desempenho = 0; $total_reprovados_nota = 0; $total_analfabetos = 0; $total_nao_analfabetos = 0; $ordem_mostra = 0; if (is_array($lst_matricula)) { foreach ($lst_matricula as $ordem => $matricula) { $obj_matricula = new clsPmieducarMatricula($matricula['ref_cod_matricula']); $det_matricula = $obj_matricula->detalhe(); // Verifica se o aluno está aprovado ou reprovado $situacoes = array(App_Model_MatriculaSituacao::APROVADO, App_Model_MatriculaSituacao::REPROVADO); if (in_array($det_matricula['aprovado'], $situacoes)) { $ordem_mostra++; $ordem_mostra = sprintf('%02d', $ordem_mostra); if ($linha % $qtd_quebra == 0) { //nova pagina $this->pdf->ClosePage(); $this->pdf->OpenPage(); $base = 30; $linha = 0; $this->pdf->linha_relativa(30, 30, 540, 0); $qtd_quebra = 51; } $this->pdf->linha_relativa(30, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(60, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(30, $base + 15 + $linha * 15, 540, 0); $this->pdf->linha_relativa(570, $base + $linha * 15, 0, 15); // fim $this->pdf->escreve_relativo($ordem_mostra, 40, $base + 3 + $linha * 15, 15, 15, NULL, 8); if ($eh_multi_seriado) { $this->pdf->escreve_relativo($matricula['nome'] . ' (' . $series[$det_matricula['ref_ref_cod_serie']] . ')', 65, $base + 3 + $linha * 15, 250, 15, NULL, 8); } else { $this->pdf->escreve_relativo($matricula['nome'], 65, $base + 3 + $linha * 15, 250, 15, NULL, 8); } /** * Instancia o service de boletim e requisita os dados da situação * do aluno. Graças ao service, são "apenas" 147 linhas de código * mal-escrito a menos. */ $boletim = new Avaliacao_Service_Boletim(array('matricula' => $matricula['ref_cod_matricula'])); $situacao = $boletim->getSituacaoAluno(); if (TRUE == $situacao->aprovado) { $this->pdf->escreve_relativo('X', 345, $base + 3 + $linha * 15, 250, 15, NULL, 8); $total_aprovados++; } elseif (TRUE == $situacao->retidoFalta) { $total_reprovados_desempenho++; $this->pdf->escreve_relativo('X', 465, $base + 3 + $linha * 15, 250, 15, NULL, 8); } else { $total_reprovados_nota++; $this->pdf->escreve_relativo('X', 410, $base + 3 + $linha * 15, 250, 15, NULL, 8); } // analfabeto $obj_aluno = new clsPmieducarAluno($det_matricula['ref_cod_aluno']); $obj_aluno->setCamposLista('analfabeto'); $det_aluno = $obj_aluno->detalhe(); if ($det_aluno['analfabeto'] == 0) { $this->pdf->escreve_relativo('X', 507, $base + 3 + $linha * 15, 250, 15, NULL, 8); // não alfabetizado $total_analfabetos++; } else { $this->pdf->escreve_relativo('X', 545, $base + 3 + $linha * 15, 250, 15, NULL, 8); // alfabetizado $total_nao_analfabetos++; } $this->pdf->linha_relativa(320, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(380, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(490, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(530, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(450, $base + $linha * 15, 0, 15); $linha++; } } } // Escrever total $this->pdf->linha_relativa(30, $base + $linha * 15, 0, 15); $this->pdf->escreve_relativo("Total", 35, $base + 3 + $linha * 15, 20, 15, NULL, 8); $this->pdf->escreve_relativo($total_aprovados, 345, $base + 3 + $linha * 15, 250, 15, null, 8); // aprovado $this->pdf->escreve_relativo($total_reprovados_desempenho, 465, $base + 3 + $linha * 15, 250, 15, NULL, 8); // desempenho $this->pdf->escreve_relativo($total_reprovados_nota, 410, $base + 3 + $linha * 15, 250, 15, NULL, 8); // faltas $this->pdf->escreve_relativo($total_analfabetos, 507, $base + 3 + $linha * 15, 250, 15, NULL, 8); // não alfabetizado $this->pdf->escreve_relativo($total_nao_analfabetos, 545, $base + 3 + $linha * 15, 250, 15, NULL, 8); // alfabetizado $this->pdf->linha_relativa(60, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(320, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(380, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(490, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(530, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(450, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(570, $base + $linha * 15, 0, 15); $this->pdf->linha_relativa(30, $base + ($linha + 1) * 15, 540, 0); $this->pdf->ClosePage(); $this->pdf->CloseFile(); $this->get_link = $this->pdf->GetLink(); echo sprintf(' <script> window.onload = function() { parent.EscondeDiv("LoadImprimir"); window.location="download.php?filename=%s" } </script>', $this->get_link); echo sprintf(' <html> <center> Se o download não iniciar automaticamente <br /><a target="blank" href="%s" style="font-size: 16px; color: #000000; text-decoration: underline;">clique aqui!</a><br><br> <span style="font-size: 10px;">Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br> Clique na Imagem para Baixar o instalador<br><br> <a href="http://www.adobe.com.br/products/acrobat/readstep2.html" target="new"><br><img src="imagens/acrobat.gif" width="88" height="31" border="0"></a> </span> </center> </html>', $this->get_link); }