Commit f7c07e89d07754a9ade13b64b27c19190080689a

Authored by Eriksen Costa Paixão
1 parent 5abcf67f
Exists in master

Alterado relatório de emissão de boletim para usar o service {{{Avaliacao_Service_Boletim}}}

Showing 1 changed file with 248 additions and 1082 deletions   Show diff stats
ieducar/intranet/educar_relatorio_boletim_proc.php
... ... @@ -34,6 +34,9 @@ require_once 'include/clsBanco.inc.php';
34 34 require_once 'include/pmieducar/geral.inc.php';
35 35 require_once 'include/clsPDF.inc.php';
36 36  
  37 +require_once 'RegraAvaliacao/Model/RegraDataMapper.php';
  38 +require_once 'Avaliacao/Service/Boletim.php';
  39 +
37 40 /**
38 41 * clsIndexBase class.
39 42 *
... ... @@ -69,61 +72,26 @@ class indice extends clsCadastro
69 72 {
70 73 var $pessoa_logada;
71 74  
  75 + var $em_branco;
72 76 var $ref_cod_instituicao;
73 77 var $ref_cod_escola;
74 78 var $ref_cod_serie;
75 79 var $ref_cod_turma;
76 80  
77   - var $ano;
78   - var $mes;
79   -
80   - var $nm_escola;
81   - var $nm_instituicao;
82   - var $ref_cod_curso;
83   - var $sequencial;
84 81 var $pdf;
85 82 var $pagina_atual = 1;
86 83 var $total_paginas = 1;
87   - var $nm_professor;
88   - var $nm_turma;
89   - var $nm_serie;
90   - var $nm_disciplina;
91   - var $curso_com_exame = 0;
92   - var $ref_cod_matricula;
93 84  
94 85 var $page_y = 135;
95 86  
96   - var $nm_aluno;
97 87 var $array_modulos = array();
98 88 var $nm_curso;
99 89 var $get_link = false;
100 90  
101 91 var $total;
102 92  
103   - var $ref_cod_modulo;
104 93 var $inicio_y;
105 94  
106   - var $numero_registros;
107   - var $em_branco;
108   -
109   - var $meses_do_ano = array(
110   - 1 => 'JANEIRO',
111   - 2 => 'FEVEREIRO',
112   - 3 => 'MARÇO',
113   - 4 => 'ABRIL',
114   - 5 => 'MAIO',
115   - 6 => 'JUNHO',
116   - 7 => 'JULHO',
117   - 8 => 'AGOSTO',
118   - 9 => 'SETEMBRO',
119   - 10 => 'OUTUBRO',
120   - 11 => 'NOVEMBRO',
121   - 12 => 'DEZEMBRO'
122   - );
123   -
124   - var $segue_padrao_escolar = TRUE;
125   - var $mostra_cabecalho_modulo = array();
126   -
127 95 function renderHTML()
128 96 {
129 97 if ($_POST) {
... ... @@ -136,886 +104,289 @@ class indice extends clsCadastro
136 104 $this->pessoa_logada = $_SESSION['id_pessoa'];
137 105 @session_write_close();
138 106  
139   - if ($this->ref_ref_cod_serie) {
140   - $this->ref_cod_serie = $this->ref_ref_cod_serie;
141   - }
142   -
143   - $fonte = 'arial';
144   - $corTexto = '#000000';
  107 + // Instancia o objeto clsPDF
  108 + $this->pdf = new clsPDF('Boletim', 'BolTit', 'A4', '');
145 109  
146   - if (empty($this->ref_cod_turma) && !$this->em_branco) {
147   - echo '
148   - <script>
149   - alert("Erro ao gerar relatório!\nNenhuma turma selecionada!");
150   - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
151   - </script>';
  110 + $this->pdf->largura = 842.0;
  111 + $this->pdf->altura = 595.0;
152 112  
153   - return TRUE;
154   - }
  113 + $this->pdf->topmargin = 5;
  114 + $this->pdf->bottommargirn = 5;
155 115  
156   - if ($this->ref_cod_escola) {
157   - $obj_escola = new clsPmieducarEscola($this->ref_cod_escola);
158   - $det_escola = $obj_escola->detalhe();
159   - $this->nm_escola = $det_escola['nome'];
160   - }
  116 + $altura_linha = 13;
161 117  
162   - $obj_instituicao = new clsPmieducarInstituicao($this->ref_cod_instituicao);
163   - $det_instituicao = $obj_instituicao->detalhe();
164   - $this->nm_instituicao = $det_instituicao['nm_instituicao'];
  118 + // Instituição
  119 + $instituicao = App_Model_IedFinder::getInstituicoes();
  120 + $instituicao = $instituicao[$this->ref_cod_instituicao];
165 121  
166   - $obj_calendario = new clsPmieducarEscolaAnoLetivo();
167   - $lista_calendario = $obj_calendario->lista($this->ref_cod_escola, $this->ano,
168   - NULL, NULL, NULL, NULL, NULL, NULL, NULL,1, NULL);
  122 + // Escola
  123 + $escola = new clsPmieducarEscola();
  124 + $escola->cod_escola = $this->ref_cod_escola;
  125 + $escola = $escola->detalhe();
  126 + $escola = $escola['nome'];
169 127  
170   - $obj_turma = new clsPmieducarTurma($this->ref_cod_turma);
171   - $det_turma = $obj_turma->detalhe();
172   - $this->nm_turma = $det_turma['nm_turma'];
  128 + // Carrega as informações do curso
  129 + $serie = new clsPmieducarSerie($this->ref_ref_cod_serie, NULL, NULL,
  130 + $this->ref_cod_curso);
173 131  
174   - $obj_serie = new clsPmieducarSerie($this->ref_cod_serie);
175   - $det_serie = $obj_serie->detalhe();
176   - $this->nm_serie = $det_serie['nm_serie'];
  132 + // Dados da série
  133 + $serie = $serie->detalhe();
177 134  
178   - $obj_pessoa = new clsPessoa_($det_turma["ref_cod_regente"]);
179   - $det = $obj_pessoa->detalhe();
180   - $this->nm_professor = $det["nome"];
  135 + // Recupera a regra da série
  136 + $regraMapper = new RegraAvaliacao_Model_RegraDataMapper();
  137 + $regra = $regraMapper->find($serie['regra_avaliacao_id']);
181 138  
182   - if (!$lista_calendario) {
183   - echo '
184   - <script>
185   - alert("Escola não possui calendário definido para este ano");
186   - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
187   - </script>';
  139 + // Carrega alunos matriculados
  140 + $matriculaTurma = new clsPmieducarMatriculaTurma();
  141 + $matriculaTurma->setOrderby('nome_aluno');
188 142  
189   - return TRUE;
190   - }
  143 + $matriculados = $matriculaTurma->lista($this->ref_cod_matricula,
  144 + $this->ref_cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1,
  145 + $this->ref_cod_serie, $this->ref_cod_curso, $this->ref_cod_escola,
  146 + $this->ref_cod_instituicao, NULL, NULL, NULL, NULL, NULL, $this->ano,
  147 + NULL, TRUE);
191 148  
192   - $prox_mes = $this->mes + 1;
  149 + foreach ($matriculados as $matriculado) {
  150 + $this->pdf->OpenPage();
  151 + $this->page_y = 10;
193 152  
194   - $obj = new clsPmieducarSerie();
195   - $obj->setOrderby('cod_serie,etapa_curso');
  153 + $codMatricula = $matriculado['ref_cod_matricula'];
  154 + $nomeAluno = $matriculado['nome_aluno'];
  155 + $turma = $matriculado['nm_turma'];
196 156  
197   - $lista_serie_curso = $obj->lista(NULL, NULL, NULL,$this->ref_cod_curso, NULL,
198   - NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
  157 + $boletim = new Avaliacao_Service_Boletim(array(
  158 + 'matricula' => $codMatricula
  159 + ));
199 160  
200   - $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);
201   - $det_curso = $obj_curso->detalhe();
  161 + $matriculaData = $boletim->getOption('matriculaData');
  162 + $curso = $matriculaData['curso_nome'];
  163 + $serie = $matriculaData['serie_nome'];
202 164  
203   - $this->nm_curso = $det_curso['nm_curso_upper'];
  165 + $this->addCabecalho($instituicao, $escola, $codMatricula, $nomeAluno, $curso, $turma, $serie);
  166 + $this->inicio_y = $this->page_y - 25;
204 167  
205   - if (!$this->em_branco) {
206   - if ($det_curso['padrao_ano_escolar']) {
207   - $obj_ano_letivo_modulo = new clsPmieducarAnoLetivoModulo();
208   - $obj_ano_letivo_modulo->setOrderby("data_inicio asc");
209   - $lst_ano_letivo_modulo = $obj_ano_letivo_modulo->lista($this->ano,
210   - $this->ref_cod_escola, NULL, NULL);
211   -
212   - if ($lst_ano_letivo_modulo) {
213   - foreach ($lst_ano_letivo_modulo as $modulo) {
214   - $obj_modulo = new clsPmieducarModulo($modulo['ref_cod_modulo']);
215   - $det_modulo = $obj_modulo->detalhe();
216   - $this->array_modulos[] = $det_modulo;
217   - }
218   - }
  168 + $this->_notasFaltasComponentes($boletim);
219 169  
220   - if (!$this->em_branco) {
221   - $obj_disc_serie = new clsPmieducarEscolaSerieDisciplina();
222   - $lst_disc_serie = $obj_disc_serie->lista($this->ref_cod_serie,
223   - $this->ref_cod_escola, NULL, 1);
224   -
225   - if (is_array($lst_disc_serie)) {
226   - foreach ($lst_disc_serie as $key => $disciplina) {
227   - $obj_disc = new clsPmieducarDisciplina($disciplina['ref_cod_disciplina']);
228   - $det_disc = $obj_disc->detalhe();
229   - $lst_disc_serie[$key]['nm_disciplina'] = $det_disc['nm_disciplina'];
230   - $array_disc[$key] = $det_disc['nm_disciplina'];
231   - }
232   -
233   - array_multisort($array_disc,SORT_ASC,$lst_disc_serie);
234   - }
235   - }
236   - }
237   - else {
238   - $obj_turma_modulo = new clsPmieducarTurmaModulo();
239   - $lst_turma_modulo = $obj_turma_modulo->lista($this->ref_cod_turma, NULL,
240   - NULL, NULL, NULL, NULL, NULL);
  170 + $situacao = $boletim->getSituacaoAluno();
241 171  
242   - if ($lst_turma_modulo) {
243   - $this->segue_padrao_escolar = FALSE;
  172 + $this->page_y += 25;
  173 + $this->rodape($codMatricula, $nomeAluno, $matriculaData['aprovado']);
244 174  
245   - foreach ($lst_turma_modulo as $modulo) {
246   - $obj_modulo = new clsPmieducarModulo($modulo['ref_cod_modulo']);
247   - $det_modulo = $obj_modulo->detalhe();
248   - $this->array_modulos[] = $det_modulo;
  175 + $this->pdf->ClosePage();
  176 + }
249 177  
250   - $nm_modulo = substr(strtoupper($det_modulo['nm_tipo']), 0, 1);
251   - }
  178 + $this->pdf->CloseFile();
  179 + $this->get_link = $this->pdf->GetLink();
252 180  
253   - for ($i = 0; $i < count($this->array_modulos); $i++) {
254   - $this->mostra_cabecalho_modulo[$i] = ($i + 1) . 'º' . $nm_modulo;
255   - }
  181 + echo sprintf('
  182 + <script>
  183 + window.onload = function()
  184 + {
  185 + parent.EscondeDiv("LoadImprimir");
  186 + window.location="download.php?filename=%s"
256 187 }
  188 + </script>', $this->get_link);
257 189  
258   - if (!$this->em_branco) {
259   - $obj_disc_serie = new clsPmieducarEscolaSerieDisciplina();
260   - $lst_disc_serie = $obj_disc_serie->lista($this->ref_cod_serie,$this->ref_cod_escola,null,1);
261   -
262   - if (is_array($lst_disc_serie)) {
263   - foreach ($lst_disc_serie as $key => $disciplina) {
264   - $obj_disc = new clsPmieducarDisciplina($disciplina['ref_cod_disciplina']);
265   - $det_disc = $obj_disc->detalhe();
266   - $lst_disc_serie[$key]['nm_disciplina'] = $det_disc['nm_disciplina'];
267   - }
268   - }
269   - }
270   - }
  190 + echo sprintf('
  191 + <html>
  192 + <center>
  193 + 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>
  194 + <span style="font-size: 10px;">Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>
  195 + Clique na Imagem para Baixar o instalador<br><br>
  196 + <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>
  197 + </span>
  198 + </center>
  199 + </html>', $this->get_link);
  200 + }
  201 +
  202 + protected function _notasFaltasComponentes(Avaliacao_Service_Boletim $boletim)
  203 + {
  204 + $etapas = $boletim->getOption('etapas');
  205 + $notas = $boletim->getNotasComponentes();
  206 +
  207 + if ($faltaPorComponente = ($boletim->getRegra()->get('tipoPresenca') == RegraAvaliacao_Model_TipoPresenca::POR_COMPONENTE)) {
  208 + $faltas = $boletim->getFaltasComponentes();
271 209 }
272 210 else {
273   - $this->array_modulos = array(
274   - array('nm_tipo' => 'Bimestre'),
275   - array('nm_tipo' => 'Bimestre'),
276   - array('nm_tipo' => 'Bimestre'),
277   - array('nm_tipo' => 'Bimestre')
278   - );
279   - }
280   -
281   - if ($det_curso['media_exame']) {
282   - $this->curso_com_exame = 1;
  211 + $faltas = $boletim->getFaltasGerais();
283 212 }
284 213  
285   - $media_curso = $det_curso['media'];
  214 + $componentes = $boletim->getComponentes();
  215 + $medias = $boletim->getMediasComponentes();
  216 + $situacao = $boletim->getSituacaoAluno();
286 217  
287   - if (!$this->em_branco) {
288   - $obj_matricula_turma = new clsPmieducarMatriculaTurma();
289   - $obj_matricula_turma->setOrderby("nome_aluno");
290   - $lista_matricula = $obj_matricula_turma->lista($this->ref_cod_matricula,
291   - $this->ref_cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1,
292   - $this->ref_cod_serie, $this->ref_cod_curso, $this->ref_cod_escola,
293   - $this->ref_cod_instituicao, NULL, NULL, NULL, NULL, NULL,$this->ano,
294   - NULL, TRUE);
295   - }
  218 + $etapas = range(0, $etapas - 1);
296 219  
297   - $obj_tipo_avaliacao = new clsPmieducarTipoAvaliacao($det_curso['ref_cod_tipo_avaliacao']);
298   - $det_tipo_avaliacao = $obj_tipo_avaliacao->detalhe();
299   - $curso_conceitual = $det_tipo_avaliacao['conceitual'];
  220 + $altura_linha = 15;
300 221  
301   - if ($lista_matricula || $this->em_branco) {
302   - if ($this->em_branco) {
303   - $lista_matricula = array();
304   - $lista_matricula[] = '';
305   - $this->numero_registros = $this->numero_registros? $this->numero_registros : 20;
  222 + // Calcula o espaço disponível para as notas e faltas
  223 + $extraColumns = 2 + ($situacao->recuperacao == TRUE ? 1: 0);
  224 + $total = 782 - (80 + (60 * $extraColumns) + 120);
306 225  
307   - for ($i = 0 ; $i < $this->numero_registros; $i++) {
308   - $lst_disc_serie[] = '';
309   - }
310   - }
  226 + $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5);
  227 + $this->pdf->escreve_relativo_center('Módulos', 30, $this->page_y + 2, 80, 13);
  228 + $this->pdf->linha_relativa(30, $this->page_y, 0, $altura_linha, 0.1);
  229 + $this->pdf->linha_relativa(80 + 30, $this->page_y, 0, $altura_linha, 0.1);
311 230  
312   - if (!$curso_conceitual) {
313   - $this->pdf = new clsPDF('Boletim', 'Boletim ' . $this->ano, 'A4', '', FALSE, FALSE);
  231 + $matriculaSituacao = App_Model_MatriculaSituacao::getInstance();
314 232  
315   - $this->pdf->largura = 842.0;
316   - $this->pdf->altura = 595.0;
  233 + // Escreve as etapas
  234 + $x = 80 + 30;
  235 + $largura = $total / count($etapas);
317 236  
318   - $this->pdf->topmargin = 5;
319   - $this->pdf->bottommargirn = 5;
  237 + if ($faltaPorComponente) {
  238 + $larguraDv = $largura / 2;
  239 + }
  240 + else {
  241 + $larguraDv = $largura;
  242 + }
320 243  
321   - $altura_linha = 13;
  244 + foreach ($etapas as $etapa) {
  245 + $this->pdf->escreve_relativo_center($etapa + 1, $x, $this->page_y + 2, $largura, 13);
  246 + $x += $largura;
  247 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  248 + }
322 249  
323   - $this->pdf->OpenPage();
324   - $this->page_y = 10;
  250 + // Escreve os campos para Média final, Falta e Situação
  251 + $labels = array();
  252 + $labels[] = 'Média final';
325 253  
326   - $flag_tamanho = false;
327   - $tamanho = $this->page_y;
  254 + if ($situacao->recuperacao) {
  255 + $labels[] = 'Exame';
  256 + }
328 257  
329   - foreach ($lista_matricula as $matricula) {
330   - $reprovou = false;
  258 + $labels[] = '% Presença';
  259 + $labels[] = 'Situação';
331 260  
332   - if (!$this->em_branco) {
333   - $obj_matricula = new clsPmieducarMatricula($matricula['ref_cod_matricula']);
334   - $det_matricula = $obj_matricula->detalhe();
335   - $this->ref_cod_matricula = $matricula['ref_cod_matricula'];
336   - $this->nm_aluno = $matricula['nome_aluno'];
337   - }
  261 + foreach ($labels as $label) {
  262 + $largura = $label == 'Situação' ? 120 : 60;
338 263  
339   - if ($this->page_y + $tamanho > 540) {
340   - $this->pdf->ClosePage();
341   - $this->pdf->OpenPage();
342   - $this->page_y = 10;
343   - }
344   -
345   - $this->addCabecalho();
346   - $this->inicio_y = $this->page_y - 25;
  264 + $this->pdf->escreve_relativo_center($label, $x, $this->page_y + 2, $largura, 13);
  265 + $x += $largura;
  266 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  267 + }
347 268  
348   - if (!$this->em_branco) {
349   - $obj_matricula = new clsPmieducarMatricula($matricula['ref_cod_matricula']);
350   - $det_matricula = $obj_matricula->detalhe();
  269 + // Escreve os rótulos para notas e faltas
  270 + $x = 80 + 30;
351 271  
352   - $obj_aluno = new clsPmieducarAluno();
353   - $det_aluno = array_shift($obj_aluno->lista($det_matricula['ref_cod_aluno']));
354   - }
  272 + // Nova linha
  273 + $this->page_y += 15;
355 274  
356   - foreach ($lst_disc_serie as $key => $disciplina) {
357   - $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5);
358   -
359   - $inc = (strlen($det_disc['nm_disciplina']) > 40) ? -2 : +2;
360   - $fonte_dis = 7;
361   -
362   - $this->pdf->escreve_relativo($disciplina['nm_disciplina'] , 33,
363   - $this->page_y + $inc, 170, 15, $fonte, $fonte_dis, $corTexto, 'left');
364   -
365   - /**
366   - * notas
367   - */
368   - $largura_anos = 620;
369   - $altura = 30;
370   -
371   - if (sizeof($this->array_modulos) + $this->curso_com_exame + 2 >= 1) {
372   - $incremental = (int) ceil($largura_anos / (sizeof($this->array_modulos) + $this->curso_com_exame + 2));
373   - }
374   - else {
375   - $incremental = 1;
376   - }
377   -
378   - $reta_ano_x = 209;
379   - $anos_x = 209;
380   -
381   - if (!$this->em_branco) {
382   - $obj_nota = new clsPmieducarNotaAluno();
383   - $obj_nota->setOrderby('cod_nota_aluno asc');
384   -
385   - if ($det_curso['padrao_ano_escolar'] == 1) {
386   - $det_nota = $obj_nota->lista(NULL,NULL, NULL,$this->ref_cod_serie,
387   - $this->ref_cod_escola, $disciplina['ref_cod_disciplina'],
388   - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL, NULL,
389   - NULL,1, NULL);
390   - }
391   - else {
392   - $det_nota = $obj_nota->lista(NULL, NULL, NULL, $this->ref_cod_serie,
393   - $this->ref_cod_escola, NULL, $matricula['ref_cod_matricula'],
394   - NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL,
395   - $disciplina['ref_cod_disciplina']);
396   - }
397   -
398   - if (is_array($det_nota)) {
399   - usort($det_nota, 'cmp');
400   - }
401   -
402   - $obj_dispensa = new clsPmieducarDispensaDisciplina();
403   -
404   - $matricula_dispensa_disciplina = $obj_dispensa->lista(
405   - $matricula['ref_cod_matricula'], $this->ref_cod_serie,
406   - $this->ref_cod_escola, $disciplina['ref_cod_disciplina'],
407   - NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
408   - }
409   -
410   - $dispensas = array();
411   - $completo = TRUE;
412   -
413   - if (count($det_nota) < count($this->array_modulos) || !$det_nota) {
414   - if (!$det_nota) {
415   - $det_nota = array();
416   - }
417   -
418   - for ($ct = count($det_nota); $ct <= count($this->array_modulos); $ct++) {
419   - if ($matricula_dispensa_disciplina) {
420   - $det_nota[$ct] = array('D');
421   - $dispensas[$ct] = 1;
422   - }
423   - else {
424   - $det_nota[$ct] = array('');
425   - }
426   -
427   - $completo = FALSE;
428   - }
429   - }
430   -
431   - if (!$this->em_branco) {
432   - if ($det_curso['falta_ch_globalizada']) {
433   - $obj_falta = new clsPmieducarFaltas();
434   - $obj_falta->setOrderby("sequencial asc");
435   - $det_falta = $obj_falta->lista($matricula['ref_cod_matricula'],
436   - NULL, NULL, NULL, NULL, NULL);
437   -
438   - if(is_array($det_falta)) {
439   - $total_faltas = 0;
440   - foreach ($det_falta as $key => $value) {
441   - $total_faltas += $det_falta[$key]['faltas'] = $value['falta'];
442   - }
443   -
444   - $det_falta['total'] = $total_faltas;
445   - }
446   -
447   - if(count($det_nota) < count($this->array_modulos) || !$det_nota) {
448   - if (!$det_falta) {
449   - $det_falta = array();
450   - }
451   -
452   - for ($ct = count($det_nota); $ct <= count($this->array_modulos); $ct++) {
453   - $det_falta[$ct] = array('');
454   - $det_falta[$ct]['faltas'] = '0';
455   - }
456   - }
457   - }
458   - else {
459   - $obj_falta = new clsPmieducarFaltaAluno();
460   - $obj_falta->setOrderby("cod_falta_aluno asc");
461   -
462   - if($det_curso['padrao_ano_escolar'] == 1) {
463   - $det_falta = $obj_falta->lista(NULL, NULL, NULL, $this->ref_cod_serie,
464   - $this->ref_cod_escola, $disciplina['ref_cod_disciplina'],
465   - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL, NULL, 1);
466   - }
467   - else {
468   - $det_falta = $obj_falta->lista(NULL, NULL, NULL, $this->ref_cod_serie,
469   - $this->ref_cod_escola, NULL, $matricula['ref_cod_matricula'],
470   - NULL, NULL, NULL, NULL, NULL, 1, NULL, $disciplina['ref_cod_disciplina']);
471   - }
472   -
473   - $total_faltas = 0;
474   -
475   - if (is_array($det_falta)) {
476   - foreach ($det_falta as $key => $value) {
477   - $total_faltas += $det_falta[$key]['faltas'];
478   - }
479   - }
480   -
481   - $det_falta['total'] = $total_faltas;
482   - }
483   - }
484   -
485   - if ($det_nota){
486   - $soma_notas = 0;
487   - $notas_primeiro_regular = array();
488   -
489   - foreach ($det_nota as $key => $nota) {
490   - $obj_tipo_av_val = new clsPmieducarTipoAvaliacaoValores(
491   - $nota['ref_ref_cod_tipo_avaliacao'], $nota['ref_sequencial'],
492   - NULL, NULL, NULL, NULL);
493   -
494   - $det_tipo_av_val = $obj_tipo_av_val->detalhe();
495   -
496   - if (dbBool($det_serie['ultima_nota_define'])) {
497   - $soma_notas = $det_tipo_av_val['valor'];
498   - }
499   - else {
500   - $soma_notas += $det_tipo_av_val['valor'];
501   - }
502   -
503   - if ( count($this->array_modulos) == count($det_nota) ) {
504   - $frequencia_minima = $det_curso['frequencia_minima'];
505   - $hora_falta = $det_curso['hora_falta'];
506   - $carga_horaria_curso = $det_curso['carga_horaria'];
507   - }
508   -
509   - if ($det_tipo_av_val['conceitual']) {
510   - // situacao definida pelo professor
511   - $aprovado = $this->aprovado;
512   - }
513   - elseif ((count($this->array_modulos) <= $nota['modulo']) &&
514   - ($aprovado == 3) && !$det_tipo_av_val['conceitual']) {
515   -
516   - // aluno aprovado
517   - $aprovado = 1;
518   - }
519   -
520   - if ($key < (count($this->array_modulos))) {
521   - /**
522   - * variavel de controle para verificacao de media
523   - */
524   - $media_sem_exame = TRUE;
525   -
526   - if ($det_tipo_av_val['valor']) {
527   - $nota = sprintf('%01.1f', $det_tipo_av_val['valor']);
528   - }
529   - else {
530   - $nota = '-';
531   - }
532   -
533   - if ($this->em_branco) {
534   - $nota = '';
535   - }
536   -
537   - $nota = $dispensas[$key] ? 'D' : str_replace('.', ',', $nota);
538   -
539   - $this->pdf->escreve_relativo($nota, $anos_x + 10, $this->page_y + 2,
540   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
541   -
542   - if ($det_curso['falta_ch_globalizada']) {
543   - $falta = ' - ';
544   - }
545   - else {
546   - if ($det_falta[$key]['faltas']) {
547   - $falta = $det_falta[$key]['faltas'];
548   - }
549   - else {
550   - $falta = '0';
551   - }
552   - }
553   -
554   - if ($this->em_branco) {
555   - $falta = '';
556   - }
557   -
558   - $falta = $dispensas[$key] ? 'D' : $falta;
559   - $this->pdf->escreve_relativo($falta, $anos_x + ($incremental / 2) + 10,
560   - $this->page_y + 2, ($incremental / 3), $altura, $fonte, 9,
561   - $corTexto, 'center');
562   -
563   - if (count($this->array_modulos) == count($det_nota) &&
564   - $key == count($det_nota) - 1) {
565   - $this->pdf->escreve_relativo($this->em_branco ? '' : '-',
566   - $anos_x + $incremental / 3 + $incremental, $this->page_y + 2,
567   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
568   - }
569   - }
570   - else {
571   - /**
572   - * variavel de controle para verificacao de media
573   - */
574   - $media_sem_exame = FALSE;
575   -
576   - if (
577   - $this->curso_com_exame &&
578   - ($det_matricula['aprovado'] == 1 || $det_matricula['aprovado'] == 2)
579   - ) {
580   - $nota = sprintf('%01.2f', $det_nota[$key]['nota']);
581   - $nota = str_replace('.', ',', $nota);
582   - $nota = $dispensas[$key] ? 'D' : $nota;
583   - $this->pdf->escreve_relativo($nota, $anos_x + $incremental / 3,
584   - $this->page_y + 2, ($incremental / 3), $altura, $fonte, 9,
585   - $corTexto, 'center');
586   -
587   - $nota_exame = TRUE;
588   - $exame_nota = $det_nota[$key]["nota"];
589   - }
590   - }
591   -
592   - $anos_x += $incremental;
593   - $reta_ano_x += $incremental;
594   - }
595   -
596   - if (!dbBool($det_serie['ultima_nota_define'])) {
597   - if (!$nota_exame) {
598   - // soh esta parte eh do codigo original
599   - $media = $soma_notas / count($det_nota);
600   - $media_ = $media;
601   - }
602   - else {
603   - $media = ($soma_notas + $exame_nota * 2) / (count($det_nota) + 1);
604   - }
605   - }
606   - else {
607   - $media = $soma_notas;
608   - }
609   -
610   - $det_media = array();
611   -
612   - if ($media >= $det_curso['media'] || $nota_exame) {
613   - $obj_media = new clsPmieducarTipoAvaliacaoValores();
614   - $det_media = $obj_media->lista($det_curso['ref_cod_tipo_avaliacao'],
615   - $det_curso['ref_sequencial'], NULL, NULL, $media, $media);
616   - }
617   -
618   - $nota_exame = FALSE;
619   -
620   - if ($det_media && is_array($det_media)) {
621   - $det_media = array_shift($det_media);
622   - $media = $det_media['valor'];
623   - $media = sprintf('%01.1f', $media);
624   - $media = str_replace('.', ',', $media);
625   - }
626   - elseif (dbBool($det_serie['ultima_nota_define'])) {
627   - $media = sprintf('%01.1f', $media);
628   - $media = str_replace('.', ',', $media);
629   - }
630   -
631   - if (count($det_nota) <= count($this->array_modulos) && $this->curso_com_exame) {
632   - $anos_x += $incremental;
633   - $reta_ano_x += $incremental;
634   - }
635   -
636   - if (
637   - count($det_nota) == 4 &&
638   - (
639   - $det_matricula['aprovado'] == 1 || $det_matricula['aprovado'] == 2 ||
640   - !(
641   - (
642   - $det_matricula['aprovado'] == 7 ||
643   - (str_replace(",",".",$media) < $media_curso_ && !$nota_exame)
644   - )
645   - )
646   - )
647   - ) {
648   - if ($dispensas[$key]) {
649   - $this->pdf->escreve_relativo("D", $anos_x + 5, $this->page_y + 2,
650   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
651   - }
652   - else {
653   - $this->pdf->escreve_relativo($media, $anos_x + 5, $this->page_y + 2,
654   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
655   - }
656   - }
657   - else {
658   - $this->pdf->escreve_relativo('-', $anos_x + 5, $this->page_y + 2,
659   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
660   - }
661   -
662   - if($det_curso['falta_ch_globalizada']) {
663   - $falta = ' - ';
664   - }
665   - else {
666   - if ($det_falta['total']) {
667   - $falta = $det_falta['total'];
668   - }
669   - else {
670   - $falta = '0';
671   - }
672   - }
673   -
674   - if ($this->em_branco) {
675   - $falta = '';
676   - }
677   -
678   - $falta = $dispensas[$key] ? 'D' : $falta;
679   - $this->pdf->escreve_relativo($falta, $anos_x + ($incremental / 2) + 2,
680   - $this->page_y + 2, ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
681   - }
682   -
683   - $anos_x += $incremental;
684   - $reta_ano_x += $incremental;
685   -
686   - $sit = '';
687   -
688   - if ($completo) {
689   - if ($media_sem_exame) {
690   - $media_curso_ = $det_curso['media'];
691   - }
692   - else {
693   - $media_curso_ = $det_curso['media_exame'];
694   - }
695   -
696   - $sit = (str_replace(',', '.', $media) >= $media_curso_) ?
697   - 'APROVADO' : 'REPROVADO';
698   -
699   - $sit = ($det_matricula['aprovado'] == 3 && str_replace(',', '.', $media) >= $media_curso_) ?
700   - 'APROVADO' : $sit;
701   -
702   - if ($det_matricula['aprovado'] != 1 && $det_matricula['aprovado'] != 2) {
703   - $sit = ($det_matricula['aprovado'] == 7 || (str_replace(',', '.', $media) < $media_curso_ && !$nota_exame)) ?
704   - 'EM EXAME' : $sit;
705   - }
706   -
707   - if ($this->em_branco) {
708   - $sit = '';
709   - }
710   -
711   - $sit = $dispensas[$key] ? 'D' : $sit;
712   - $this->pdf->escreve_relativo($sit, $anos_x - 12,$this->page_y + 2,
713   - $incremental, $altura, $fonte, 8, $corTexto, 'center');
714   - }
715   -
716   - $this->page_y +=$altura_linha;
  275 + $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5);
  276 + $this->pdf->escreve_relativo_center('Componentes', 30, $this->page_y + 2, 80, 13);
  277 + $this->pdf->linha_relativa(30, $this->page_y, 0, $altura_linha, 0.1);
  278 + $this->pdf->linha_relativa(110, $this->page_y, 0, $altura_linha, 0.1);
717 279  
718   - }
719   - // end foreach
720   -
721   - if ($det_curso['falta_ch_globalizada']) {
722   - $this->pdf->quadrado_relativo(30, $this->page_y , 782, $altura_linha, 0.5);
723   - $fonte_dis = 7;
724   - $this->pdf->escreve_relativo('TOTAL FALTAS' , 80 ,$this->page_y + 2,
725   - 170, 15, $fonte, 8, $corTexto, 'left');
726   -
727   - $reta_ano_x = 209 ;
728   - $anos_x = 209;
729   -
730   - if (is_array($det_falta)) {
731   - $total_faltas = array_pop($det_falta);
732   - }
733   -
734   - if($det_falta) {
735   - foreach ($det_falta as $key => $value) {
736   - $incr = $anos_x + ($incremental / 2)+ 10;
737   - if (count($det_nota) <= count($this->array_modulos) &&
738   - $this->curso_com_exame && (count($det_falta) == $key)) {
739   - $incr = $anos_x +($incremental/3);
740   - }
741   -
742   - $this->pdf->escreve_relativo($det_falta[$key]['faltas'] ? $det_falta[$key]['faltas'] : '0',
743   - $incr, $this->page_y + 2, ($incremental / 3), $altura, $fonte,
744   - 9, $corTexto, 'center');
745   -
746   - $anos_x += $incremental;
747   - $reta_ano_x += $incremental;
748   - }
749   - }
750   -
751   - $reta_ano_x += $incremental;
752   -
753   - if (count($det_nota) >= count($this->array_modulos) && $this->curso_com_exame) {
754   - $anos_x += $incremental;
755   - $reta_ano_x += $incremental;
756   - }
757   -
758   - $this->page_y +=$altura_linha;
759   - }
  280 + foreach ($etapas as $etapa) {
  281 + $this->pdf->escreve_relativo_center('Nota', $x, $this->page_y + 2, $larguraDv, 13);
  282 + $x += $larguraDv;
  283 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
760 284  
761   - $this->desenhaLinhasVertical();
762   - $sit = '';
763   -
764   - if ($completo) {
765   - if ($det_matricula['aprovado'] == 1) {
766   - $sit = 'APROVADO';
767   - }
768   - elseif ($det_matricula['aprovado'] == 2) {
769   - $sit = 'REPROVADO';
770   - }
771   - elseif ($det_matricula['aprovado'] == 7) {
772   - $sit = 'EM EXAME';
773   - }
774   - }
  285 + if ($faltaPorComponente) {
  286 + $this->pdf->escreve_relativo_center('Falta', $x, $this->page_y + 2, $larguraDv, 13);
  287 + $x += $larguraDv;
  288 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  289 + }
  290 + }
775 291  
776   - if ($sit) {
777   - $this->pdf->escreve_relativo('ALUNO ' . $sit , 150, $this->page_y + 30,
778   - 530, $altura, $fonte, 9, $corTexto, 'center');
779   - }
  292 + for ($i = 0; $i < 3; $i++) {
  293 + $x += 60;
  294 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  295 + }
780 296  
781   - $this->rodape();
  297 + $yNotas = $this->page_y;
782 298  
783   - $this->page_y += 50;
  299 + // Imprime as notas dos componentes
  300 + foreach ($componentes as $id => $componente) {
  301 + $this->page_y += 15;
  302 + $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5);
  303 + $this->pdf->escreve_relativo_center($componente, 30, $this->page_y + 2, 80, 13);
  304 + $this->pdf->linha_relativa(110, $this->page_y, 0, $altura_linha, 0.1);
784 305  
785   - $this->pdf->linha_relativa(30,$this->page_y - 15, 785, 0, 0.1);
  306 + $x = 110;
786 307  
787   - if (!$flag_tamanho) {
788   - $tamanho = $this->page_y - $tamanho;
789   - }
  308 + foreach ($etapas as $etapa) {
  309 + if (!$this->em_branco) {
  310 + $this->pdf->escreve_relativo_center($notas[$id][$etapa]->notaArredondada, $x, $this->page_y + 2, $larguraDv, 13);
790 311 }
791   - }
792   - /**
793   - * conceitual
794   - */
795   - else {
796   - $this->pdf = new clsPDF('Alunos Matriculados - ' . $this->ano,
797   - 'Alunos Matriculados - Sintético', 'A4', '', FALSE, FALSE);
  312 + $x += $larguraDv;
  313 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
798 314  
799   - foreach ($lista_matricula as $matricula) {
  315 + if ($faltaPorComponente) {
800 316 if (!$this->em_branco) {
801   - $obj_matricula = new clsPmieducarMatricula($matricula['ref_cod_matricula']);
802   - $det_matricula = $obj_matricula->detalhe();
803   -
804   - $this->ref_cod_matricula = $matricula['ref_cod_matricula'];
805   - $this->nm_aluno = $matricula['nome_aluno'];
806   - }
807   -
808   - $page_open = FALSE;
809   -
810   - if ($lst_disc_serie) {
811   - foreach ($lst_disc_serie as $disciplina) {
812   - if (!$page_open) {
813   - $x_quadrado = 30;
814   - $this->page_y = 95;
815   - $altura_caixa = 85;
816   -
817   - $this->pdf->OpenPage();
818   - $this->addCabecalhoc();
819   - $this->addCabecalhoc2();
820   -
821   - $page_open = TRUE;
822   - }
823   -
824   - $altura_caixa = 15 + (int) ((strlen($disciplina['nm_disciplina']) / 60 ) * 7);
825   -
826   - $this->pdf->quadrado_relativo(30, $this->page_y, 535, $altura_caixa);
827   -
828   - $this->pdf->linha_relativa(440, $this->page_y, 0, $altura_caixa, '0.1');
829   -
830   - $this->pdf->escreve_relativo($disciplina['nm_disciplina'], 35,
831   - $this->page_y + 5, 400, 120, 'arial', '8', '#000000', 'justify');
832   -
833   - if (!$this->em_branco) {
834   - $obj_nota = new clsPmieducarNotaAluno();
835   - $obj_nota->setOrderby('cod_nota_aluno asc');
836   -
837   - if ($det_curso['padrao_ano_escolar'] == 1) {
838   - $det_nota = $obj_nota->lista(NULL, NULL, NULL, $this->ref_cod_serie,
839   - $this->ref_cod_escola, $disciplina['ref_cod_disciplina'],
840   - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL, NULL,
841   - NULL, 1, NULL);
842   - }
843   - else {
844   - $det_nota = $obj_nota->lista(NULL, NULL, NULL, $this->ref_cod_serie,
845   - $this->ref_cod_escola, $disciplina['ref_cod_disciplina'],
846   - $matricula['ref_cod_matricula'], NULL, NULL, NULL, NULL,
847   - NULL, NULL, 1, NULL, NULL);
848   - }
849   - }
850   -
851   - $x_bim = 440 + 31;
852   -
853   - for ($i = 1; $i <= 4; $i++) {
854   - if(is_array($det_nota)) {
855   - $nota = array_shift($det_nota);
856   - $obj_tipo_av_val = new clsPmieducarTipoAvaliacaoValores(
857   - $nota['ref_ref_cod_tipo_avaliacao'], $nota['ref_sequencial'],
858   - NULL, NULL, NULL, NULL);
859   -
860   - $det_tipo_av_val = $obj_tipo_av_val->detalhe();
861   - }
862   - else {
863   - $det_tipo_av_val = NULL;
864   - }
865   -
866   - if ($i<=3) {
867   - $this->pdf->linha_relativa($x_bim, $this->page_y, 0,
868   - $altura_caixa, '0.1');
869   - }
870   -
871   - $this->pdf->escreve_relativo($det_tipo_av_val['nome'],
872   - $x_bim - 31, $this->page_y + ($altura_caixa / 3), 31, 120,
873   - 'arial', '10', '#000000', 'center');
874   -
875   - $x_bim += 31;
876   - }
877   -
878   - $this->page_y += $altura_caixa;
879   - }
880   - }
881   - else {
882   - $x_quadrado = 30;
883   - $altura_caixa = 85;
884   - $this->page_y = 95;
885   -
886   - $this->pdf->OpenPage();
887   - $this->addCabecalhoc();
888   - $this->addCabecalhoc2();
889   -
890   - $page_open = TRUE;
891   - }
892   -
893   - $this->pdf->quadrado_relativo(30, $this->page_y, 535, 15);
894   - $this->pdf->linha_relativa(440, $this->page_y, 0, 15, '0.1');
895   - $this->pdf->escreve_relativo('TOTAL DE FALTAS', 35, $this->page_y + 2,
896   - 400, 120, 'arial', '8', '#000000', 'justify');
897   -
898   - if ($det_curso['falta_ch_globalizada']) {
899   - if (!$this->em_branco) {
900   - $obj_falta = new clsPmieducarFaltas();
901   - $obj_falta->setOrderby('sequencial asc');
902   - $det_falta = $obj_falta->lista($matricula['ref_cod_matricula'],
903   - NULL, NULL, NULL, NULL, NULL);
904   - }
905   -
906   - if (is_array($det_falta)) {
907   - $total_faltas = 0;
908   - foreach ($det_falta as $key => $value) {
909   - $total_faltas += $det_falta[$key]['faltas'] = $value['falta'];
910   - }
911   -
912   - $det_falta['total'] = $total_faltas;
913   - }
914   - }
915   -
916   - $x_bim = 440 + 31;
917   -
918   - for ($i = 1; $i <= 4; $i++) {
919   - if (is_array($det_falta)) {
920   - $falta = array_shift($det_falta);
921   - $falta = $falta['faltas'];
922   - }
923   - else {
924   - $falta = NULL;
925   - }
926   -
927   - if ($i<=3) {
928   - $this->pdf->linha_relativa($x_bim, $this->page_y, 0, 15, '0.1');
929   - }
930   -
931   - $this->pdf->escreve_relativo($falta, $x_bim - 31, $this->page_y + 2,
932   - 31, 120, 'arial', '10', '#000000', 'center');
933   - $x_bim += 31;
934   - }
935   -
936   - $obj_matricula_situacao = new clsPmieducarMatricula($matricula['ref_cod_matricula']);
937   - $obj_matricula_situacao->setCamposLista('aprovado');
938   - $det_matricula_situacao = $obj_matricula_situacao->detalhe();
939   -
940   - if ($det_matricula_situacao['aprovado'] == 1) {
941   - $situacao = 'APROVADO';
942   - }
943   - elseif ($det_matricula_situacao['aprovado'] == 2) {
944   - $situacao = 'REPROVADO';
  317 + $this->pdf->escreve_relativo_center($faltas[$id][$etapa]->quantidade, $x, $this->page_y + 2, $larguraDv, 13);
945 318 }
946   - else {
947   - $situacao = 'EM ANDAMENTO';
948   - }
949   -
950   - $this->pdf->quadrado_relativo(30, $this->page_y + 15, 535, 15);
  319 + $x += $larguraDv;
  320 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  321 + }
  322 + }
951 323  
952   - $this->pdf->linha_relativa(440, $this->page_y + 15, 0, 15, '0.1');
  324 + if ($faltaPorComponente) {
  325 + $porcentagemPresenca = sprintf('%.2f', $situacao->falta->componentesCurriculares[$id]->porcentagemPresenca);
  326 + }
  327 + else {
  328 + $porcentagemPresenca = '-';
  329 + }
953 330  
954   - $this->pdf->escreve_relativo('SITUAÇÃO', 35, $this->page_y + 15 + 2,
955   - 400, 120, 'arial', '8', '#000000', 'justify');
  331 + // Média, presenção e situação
  332 + $data = array();
  333 + $data['media'] = $medias[$id][0]->mediaArredondada;
956 334  
957   - $this->pdf->escreve_relativo($situacao, 440, $this->page_y + 15 + 2,
958   - 120, 120, 'arial', '10', '#000000', 'center');
  335 + if ($situacao->recuperacao) {
  336 + $notaExame = $notas[$id][$etapa + 1];
  337 + $data['rc'] = $notaExame->etapa == 'Rc' ? $notaExame->notaArredondada : '-';
  338 + }
959 339  
960   - $this->page_y += 35; // original é 25
  340 + $data['presenca'] = $porcentagemPresenca;
  341 + $data['situacao'] = $matriculaSituacao->getValue($situacao->nota->componentesCurriculares[$id]->situacao);
961 342  
962   - $legenda = "LEGENDA:\n
963   - D = Desenvolvida
964   - PD = Parcialmente Desenvolvida
965   - ID = Iniciando o Desenvolvimento
966   - ND = Não Desenvolvida
967   - CNA = Competência Não Avaliada";
  343 + foreach ($data as $key => $value) {
  344 + $largura = ($key == 'situacao') ? 120 : 60;
968 345  
969   - $this->pdf->escreve_relativo($legenda, 36,$this->page_y, 200, 50, $fonte,
970   - 7, $corTexto, 'left' );
  346 + if (!$this->em_branco) {
  347 + $this->pdf->escreve_relativo_center($value, $x, $this->page_y + 2, $largura, 13);
  348 + }
  349 + $x += $largura;
  350 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  351 + }
  352 + }
971 353  
972   - $this->page_y += 75;
973   - $altura_obs = 60;
  354 + // Imprime a porcentagem total de presença e a situação
  355 + $this->page_y += 15;
  356 + $this->pdf->quadrado_relativo(30, $this->page_y, 782, $altura_linha, 0.5);
  357 + $this->pdf->escreve_relativo_center('Faltas', 30, $this->page_y + 2, 80, 13);
  358 + $this->pdf->linha_relativa(110, $this->page_y, 0, $altura_linha, 0.1);
974 359  
975   - $this->pdf->quadrado_relativo(30, $this->page_y, 535, $altura_obs, 0.1,
976   - '#000000', '#FFFFFF');
977   - $this->pdf->escreve_relativo('OBS: ' , 33, $this->page_y + 3 , 545, 60,
978   - $fonte, 8, $corTexto, 'justify');
  360 + if (!$faltaPorComponente) {
  361 + $x = 80 + 30;
979 362  
980   - $this->pdf->ClosePage();
981   - }
  363 + foreach ($etapas as $etapa) {
  364 + $this->pdf->escreve_relativo_center($faltas[$etapa + 1]->quantidade, $x, $this->page_y + 2, $larguraDv, 13);
  365 + $x += $larguraDv;
  366 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
982 367 }
  368 +
  369 + $x = $x + 60 * ($situacao->recuperacao ? 2 : 1);
983 370 }
984 371 else {
985   - echo '
986   - <script>
987   - alert("Turma não possui matrículas no ano selecionado");
988   - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
989   - </script>';
990   -
991   - return;
  372 + $x = $x - (120 + 60);
992 373 }
993 374  
994   - $this->pdf->CloseFile();
995   - $this->get_link = $this->pdf->GetLink();
  375 + if (!$this->em_branco) {
  376 + $this->pdf->escreve_relativo_center(sprintf('%.2f', $situacao->falta->porcentagemPresenca),
  377 + $x, $this->page_y + 2, 60, 13);
996 378  
997   - echo sprintf('
998   - <script>
999   - window.onload = function()
1000   - {
1001   - parent.EscondeDiv("LoadImprimir");
1002   - window.location="download.php?filename=%s"
1003   - }
1004   - </script>', $this->get_link);
  379 + $this->pdf->escreve_relativo_center($matriculaSituacao->getValue($situacao->falta->situacao),
  380 + $x + 60, $this->page_y + 2, 120, 13);
  381 + }
1005 382  
1006   - echo sprintf('
1007   - <html>
1008   - <center>
1009   - 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>
1010   - <span style="font-size: 10px;">Para visualizar os arquivos PDF, é necessário instalar o Adobe Acrobat Reader.<br>
1011   - Clique na Imagem para Baixar o instalador<br><br>
1012   - <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>
1013   - </span>
1014   - </center>
1015   - </html>', $this->get_link);
  383 + for ($i = 0; $i < 3; $i++) {
  384 + $this->pdf->linha_relativa($x, $this->page_y, 0, $altura_linha, 0.1);
  385 + $x += 60;
  386 + }
1016 387 }
1017 388  
1018   - function addCabecalho()
  389 + function addCabecalho($instituicao, $escola, $codMatricula, $nomeAluno, $curso, $turma, $serie)
1019 390 {
1020 391 /**
1021 392 * Variável global com objetos do CoreExt.
... ... @@ -1044,12 +415,12 @@ class indice extends clsCadastro
1044 415 $this->page_y + 2, 782, 80, $fonte, 18, $corTexto, 'center');
1045 416  
1046 417 // Dados escola
1047   - $this->pdf->escreve_relativo('Instituição: ' . $this->nm_instituicao, 110,
  418 + $this->pdf->escreve_relativo('Instituição: ' . $instituicao, 110,
1048 419 $this->page_y + 27, 400, 80, $fonte, 10, $corTexto, 'left');
1049 420  
1050   - $this->nm_escola || $this->em_branco? $this->pdf->escreve_relativo(
1051   - 'Escola: ' . $this->nm_escola, 127, $this->page_y + 43, 300, 80, $fonte,
1052   - 10, $corTexto, 'left') : NULL;
  421 + $this->pdf->escreve_relativo(
  422 + 'Escola: ' . $escola, 127, $this->page_y + 43, 300, 80, $fonte,
  423 + 10, $corTexto, 'left');
1053 424 $dif = 0;
1054 425  
1055 426 if ($this->nm_professor) {
... ... @@ -1064,75 +435,34 @@ class indice extends clsCadastro
1064 435  
1065 436 $this->pdf->quadrado_relativo(30, $this->page_y + 83, 782, 12, $espessura_linha);
1066 437  
1067   - $this->pdf->escreve_relativo('Aluno: ' . $this->nm_aluno, 37, $this->page_y + 70,
  438 + $this->pdf->escreve_relativo('Aluno: ' . $nomeAluno, 37, $this->page_y + 70,
1068 439 200, 80, $fonte, 7, $corTexto, 'left');
1069 440  
1070   - $this->pdf->escreve_relativo('Matricula: ' . str2upper($this->ref_cod_matricula),
  441 + $this->pdf->escreve_relativo('Matricula: ' . $codMatricula,
1071 442 222, $this->page_y + 70, 300, 80, $fonte, 7, $corTexto, 'left');
1072 443  
1073   - $this->pdf->escreve_relativo('Turma: ' . str2upper($this->nm_turma), 300,
  444 + $this->pdf->escreve_relativo('Turma: ' . $turma, 300,
1074 445 $this->page_y + 70, 300, 80, $fonte, 7, $corTexto, 'left');
1075 446  
1076   - $this->pdf->escreve_relativo('Curso: ' . $this->nm_curso, 37, $this->page_y + 85,
  447 + $this->pdf->escreve_relativo('Curso: ' . $curso, 37, $this->page_y + 85,
1077 448 300, 80, $fonte, 7, $corTexto, 'left');
1078 449  
1079 450 $this->pdf->escreve_relativo('Ano/Série/Etapa: ' .
1080   - ($this->nm_serie ? str2upper($this->nm_serie) : $this->ano),
  451 + ($serie ? $serie : $this->ano),
1081 452 200, $this->page_y + 85, 300, 80, $fonte, 7, $corTexto, 'left');
1082 453  
1083 454 // Título
1084 455 $this->pdf->escreve_relativo('Boletim Escolar - ' . $this->ano, 30,
1085 456 $this->page_y + 30, 782, 80, $fonte, 12, $corTexto, 'center');
1086 457  
1087   - $obj_modulo = new clsPmieducarModulo($this->ref_cod_modulo);
1088   -
1089   - $det_modulo = $obj_modulo->detalhe();
1090   -
1091 458 // Data
1092 459 $this->pdf->escreve_relativo('Data de Emissão: ' . date('d/m/Y'), 700,
1093 460 $this->page_y + 50, 535, 80, $fonte, 8, $corTexto, 'left');
1094 461  
1095   - $this->page_y +=100;
1096   - $this->novoCabecalho();
  462 + $this->page_y += 100;
1097 463 }
1098 464  
1099   -
1100   - function desenhaLinhasVertical()
1101   - {
1102   - $espessura_linha = 0.5;
1103   - $largura_anos = 620;
1104   -
1105   - if (count($this->array_modulos) + $this->curso_com_exame >= 1) {
1106   - $incremental = floor($largura_anos / (count($this->array_modulos) + $this->curso_com_exame + 2));
1107   - }
1108   - else {
1109   - $incremental = 1;
1110   - }
1111   -
1112   - $reta_ano_x = 209 ;
1113   -
1114   - $resto = $largura_anos - ($incremental * (count($this->array_modulos) + $this->curso_com_exame + 1));
1115   -
1116   - for ($linha = 0;$linha <count($this->array_modulos) + $this->curso_com_exame + 2 ;$linha++) {
1117   - $this->pdf->linha_relativa($reta_ano_x,$this->inicio_y,0,$this->page_y - $this->inicio_y ,$espessura_linha);
1118   -
1119   - if (
1120   - ($this->curso_com_exame && $linha != count($this->array_modulos) && $linha != count($this->array_modulos) + 2) ||
1121   - (!$this->curso_com_exame && $linha != count($this->array_modulos) + 1)
1122   - ) {
1123   - $this->pdf->linha_relativa($reta_ano_x + ($incremental / 2),
1124   - $this->inicio_y + 12, 0, $this->page_y - $this->inicio_y - 12,
1125   - $espessura_linha);
1126   - }
1127   -
1128   - $reta_ano_x += $incremental;
1129   - }
1130   -
1131   - $this->pdf->linha_relativa(812, $this->inicio_y, 0,
1132   - $this->page_y - $this->inicio_y,$espessura_linha);
1133   - }
1134   -
1135   - function rodape()
  465 + function rodape($codMatricula, $nomeAluno, $situacao)
1136 466 {
1137 467 $corTexto = '#000000';
1138 468 $fonte = 'arial';
... ... @@ -1143,8 +473,29 @@ class indice extends clsCadastro
1143 473  
1144 474 if (!$this->em_branco) {
1145 475 $this->pdf->escreve_relativo('Estou ciente do aproveitamento de ' .
1146   - str2upper($this->nm_aluno) . ', matrícula nº: ' . $this->ref_cod_matricula . '.',
  476 + $nomeAluno . ', matrícula nº: ' . $codMatricula . '.',
1147 477 68, $this->page_y + 12, 600, 50, $fonte, 9, $corTexto, 'left');
  478 +
  479 + /* if ($situacao->aprovado) {
  480 + $situacao = App_Model_MatriculaSituacao::APROVADO;
  481 + }
  482 + elseif ($situacao->andamento) {
  483 + $situacao = App_Model_MatriculaSituacao::EM_ANDAMENTO;
  484 + }
  485 + elseif ($situacao->recuperacao) {
  486 + $situacao = App_Model_MatriculaSituacao::EM_EXAME;
  487 + }
  488 + elseif ($situacao->retidoFalta) {
  489 + $situacao = App_Model_MatriculaSituacao::RETIDO_FALTA;
  490 + }
  491 + else {
  492 + $situacao = App_Model_MatriculaSituacao::EM_ANDAMENTO;
  493 + }*/
  494 +
  495 + $situacao = strtoupper(App_Model_MatriculaSituacao::getInstance()->getValue($situacao));
  496 +
  497 + $this->pdf->escreve_relativo('Aluno ' . $situacao,
  498 + 68, $this->page_y + 62, 600, 50, $fonte, 9, $corTexto, 'center');
1148 499 }
1149 500  
1150 501 $this->pdf->escreve_relativo('Assinatura do Responsável(a)', 677,
... ... @@ -1162,191 +513,6 @@ class indice extends clsCadastro
1162 513 {
1163 514 return FALSE;
1164 515 }
1165   -
1166   - public function novoCabecalho()
1167   - {
1168   - $altura2 = 300;
1169   - $altura = 50;
1170   - $espessura_linha = 0.5;
1171   - $expande = 24;
1172   -
1173   - $fonte = 'arial';
1174   - $corTexto = '#000000';
1175   -
1176   - $inicio_escrita_y = $this->page_y;
1177   -
1178   - $this->pdf->linha_relativa(30, $this->page_y, 782, 0, $espessura_linha);
1179   -
1180   - $this->pdf->escreve_relativo('Disciplina', 110, $this->page_y, 50, $altura,
1181   - $fonte, 9, $corTexto, 'left');
1182   -
1183   - $this->pdf->linha_relativa(30, $this->page_y, 0, 25, $espessura_linha);
1184   -
1185   - $largura_anos = 605;
1186   -
1187   - if (sizeof($this->array_modulos) + $this->curso_com_exame + 2 >= 1) {
1188   - $incremental = (int) ceil($largura_anos / (sizeof($this->array_modulos) + $this->curso_com_exame + 2));
1189   - }
1190   - else {
1191   - $incremental = 1;
1192   - }
1193   -
1194   - $reta_ano_x = 209 ;
1195   - $anos_x = 209;
1196   -
1197   - $ct = 0;
1198   -
1199   - $num_modulo = 1;
1200   -
1201   - foreach ($this->array_modulos as $key => $modulo) {
1202   - $this->pdf->escreve_relativo($num_modulo++ . 'º ' . $modulo['nm_tipo'],
1203   - $anos_x ,$inicio_escrita_y + 1, $incremental, $altura, $fonte, 9,
1204   - $corTexto, 'center');
1205   -
1206   - // Médias
1207   - $this->pdf->escreve_relativo('Nota', $anos_x + 8, $inicio_escrita_y + 12,
1208   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
1209   -
1210   - $this->pdf->escreve_relativo('Faltas', $anos_x +($incremental / 2) + 8,
1211   - $inicio_escrita_y + 12, ($incremental / 3), $altura, $fonte, 9,
1212   - $corTexto, 'center');
1213   -
1214   - $anos_x += $incremental;
1215   - $reta_ano_x += $incremental;
1216   -
1217   - $ct++;
1218   - }
1219   -
1220   - if ($this->curso_com_exame) {
1221   - $this->pdf->escreve_relativo('Exame Final', $anos_x + 5,
1222   - $inicio_escrita_y + 4, $incremental, $altura, $fonte, 9, $corTexto, 'center');
1223   -
1224   - $anos_x += $incremental;
1225   - $reta_ano_x += $incremental;
1226   - }
1227   -
1228   - $this->pdf->escreve_relativo('Resultado Final', $anos_x + 2,
1229   - $inicio_escrita_y + 1, $incremental, $altura, $fonte, 9, $corTexto, 'center');
1230   -
1231   - // Médias
1232   - $this->pdf->escreve_relativo('Nota', $anos_x + 15, $inicio_escrita_y + 12,
1233   - ($incremental / 3), $altura, $fonte, 9, $corTexto, 'center');
1234   -
1235   - $this->pdf->escreve_relativo('Faltas', $anos_x + ($incremental / 2) + 15,
1236   - $inicio_escrita_y + 12, ($incremental / 3), $altura, $fonte, 9,
1237   - $corTexto, 'center');
1238   -
1239   - $this->pdf->escreve_relativo('Situação', $anos_x + $incremental + 5,
1240   - $inicio_escrita_y + 4, $incremental, $altura, $fonte, 9, $corTexto, 'center');
1241   -
1242   - $this->page_y +=25;
1243   - }
1244   -
1245   -
1246   - public function addCabecalhoc()
1247   - {
1248   - /**
1249   - * Variável global com objetos do CoreExt.
1250   - * @see includes/bootstrap.php
1251   - */
1252   - global $coreExt;
1253   -
1254   - // Namespace de configuração do template PDF
1255   - $config = $coreExt['Config']->app->template->pdf;
1256   -
1257   - // Variável que controla a altura atual das caixas
1258   - $altura = 30;
1259   - $fonte = 'arial';
1260   - $corTexto = '#000000';
1261   -
1262   - // Cabeçalho
1263   - $logo = $config->get($config->logo, 'imagens/brasao.gif');
1264   -
1265   - $this->pdf->quadrado_relativo(30, $altura, 535, 85);
1266   - $this->pdf->insertImageScaled('gif', $logo, 50, 95, 41);
1267   -
1268   - // Título principal
1269   - $titulo = $config->get($config->titulo, 'i-Educar');
1270   - $this->pdf->escreve_relativo($titulo, 30, 30, 535, 80, $fonte, 18,
1271   - $corTexto, 'center');
1272   -
1273   - // Dados escola
1274   - $this->pdf->escreve_relativo('Instituição: ' . str2upper($this->nm_instituicao),
1275   - 120, 50, 300, 80, $fonte, 10, $corTexto, 'left');
1276   -
1277   - $this->pdf->escreve_relativo('Escola: ' . str2upper($this->nm_escola), 136, 62,
1278   - 380, 80, $fonte, 10, $corTexto, 'left');
1279   -
1280   - $this->pdf->escreve_relativo('Curso: ' . str2upper($this->nm_curso) .
1281   - ' Turma: ' . str2upper($this->nm_turma),
1282   - 136, 74, 500, 80, $fonte, 10, $corTexto, 'left');
1283   -
1284   - $this->pdf->escreve_relativo('Aluno: ' . str2upper($this->nm_aluno), 136, 86,
1285   - 300, 80, $fonte, 10, $corTexto, 'left');
1286   -
1287   - // Título
1288   - $this->pdf->escreve_relativo('B O L E T I M E S C O L A R', 30, 98, 535,
1289   - 80, $fonte, 14, $corTexto, 'center');
1290   -
1291   - // Data
1292   - $mes = date('n');
1293   - }
1294   -
1295   - function addCabecalhoc2()
1296   - {
1297   - $fonte = 'arial';
1298   - $corTexto = '#000000';
1299   - $x_quadrado = 30;
1300   - $altura_caixa = 20;
1301   -
1302   - $this->page_y += $altura_caixa;
1303   -
1304   - $this->pdf->quadrado_relativo($x_quadrado, $this->page_y + 10, 535, $altura_caixa);
1305   -
1306   - $this->pdf->escreve_relativo('COMPETÊNCIAS', 30, $this->page_y + 15, 405,
1307   - $altura_caixa, $fonte, 9, $corTexto, 'center');
1308   -
1309   - $this->pdf->linha_relativa(440, $this->page_y + 10, 0, $altura_caixa, '0.1');
1310   -
1311   - if ($this->segue_padrao_escolar) {
1312   - $x_bim = 440 + 31;
1313   -
1314   - for ($i=1;$i <= 4;$i++) {
1315   - if ($i <= 3) {
1316   - $this->pdf->linha_relativa($x_bim, $this->page_y + 10, 0, $altura_caixa, '0.1');
1317   - }
1318   -
1319   - $this->pdf->escreve_relativo($i . 'ºBIM', $x_bim - 31, $this->page_y + 15,
1320   - 31, 120, 'arial', '10', '#000000', 'center');
1321   -
1322   - $x_bim += 31;
1323   - }
1324   -
1325   - $this->page_y += $altura_caixa + 10;
1326   - }
1327   - else {
1328   - $x_bim = 440 + 31;
1329   - for ($i = 1; $i <= 4; $i++) {
1330   - if($i <= 3) {
1331   - $this->pdf->linha_relativa($x_bim, $this->page_y + 10, 0, $altura_caixa, '0.1');
1332   - }
1333   -
1334   - $this->pdf->escreve_relativo($this->mostra_cabecalho_modulo[$i-1],
1335   - $x_bim - 31, $this->page_y + 15, 31, 120, 'arial', '10', '#000000', 'center');
1336   -
1337   - $x_bim += 31;
1338   - }
1339   -
1340   - $this->page_y += $altura_caixa + 10;
1341   - }
1342   -
1343   - $this->page_y += $altura_caixa + 10;
1344   - }
1345   -}
1346   -
1347   -function cmp($a, $b)
1348   -{
1349   - return $a['modulo'] > $b['modulo'];
1350 516 }
1351 517  
1352 518 // Instancia objeto de página
... ...