Commit ecfe8fccef2dd925692fdfad6776fcb09338364a
1 parent
7ffc598d
Exists in
master
Atualizado relatório '''Diário de Frequência''' para usar componentes {{{Compone…
…nteCurricular}}} e {{{RegraAvaliacao}}}
Showing
1 changed file
with
266 additions
and
378 deletions
Show diff stats
ieducar/intranet/educar_relatorio_diario_classe_proc.php
@@ -34,6 +34,10 @@ require_once 'include/clsBanco.inc.php'; | @@ -34,6 +34,10 @@ require_once 'include/clsBanco.inc.php'; | ||
34 | require_once 'include/pmieducar/geral.inc.php'; | 34 | require_once 'include/pmieducar/geral.inc.php'; |
35 | require_once 'include/clsPDF.inc.php'; | 35 | require_once 'include/clsPDF.inc.php'; |
36 | 36 | ||
37 | +require_once 'App/Model/IedFinder.php'; | ||
38 | +require_once 'App/Model/MatriculaSituacao.php'; | ||
39 | +require_once 'RegraAvaliacao/Model/RegraDataMapper.php'; | ||
40 | + | ||
37 | /** | 41 | /** |
38 | * clsIndexBase class. | 42 | * clsIndexBase class. |
39 | * | 43 | * |
@@ -174,6 +178,7 @@ class indice extends clsCadastro | @@ -174,6 +178,7 @@ class indice extends clsCadastro | ||
174 | $obj_serie = new clsPmieducarSerie($this->ref_cod_serie); | 178 | $obj_serie = new clsPmieducarSerie($this->ref_cod_serie); |
175 | $det_serie = $obj_serie->detalhe(); | 179 | $det_serie = $obj_serie->detalhe(); |
176 | $this->nm_serie = $det_serie['nm_serie']; | 180 | $this->nm_serie = $det_serie['nm_serie']; |
181 | + $regraId = $det_serie['regra_avaliacao_id']; | ||
177 | 182 | ||
178 | $obj_pessoa = new clsPessoa_($det_turma['ref_cod_regente']); | 183 | $obj_pessoa = new clsPessoa_($det_turma['ref_cod_regente']); |
179 | $det = $obj_pessoa->detalhe(); | 184 | $det = $obj_pessoa->detalhe(); |
@@ -200,216 +205,111 @@ class indice extends clsCadastro | @@ -200,216 +205,111 @@ class indice extends clsCadastro | ||
200 | $obj_curso = new clsPmieducarCurso($this->ref_cod_curso); | 205 | $obj_curso = new clsPmieducarCurso($this->ref_cod_curso); |
201 | $det_curso = $obj_curso->detalhe(); | 206 | $det_curso = $obj_curso->detalhe(); |
202 | 207 | ||
203 | - if ($det_curso['falta_ch_globalizada']) { | ||
204 | - // Números de semanas no mês | ||
205 | - $db = new clsBanco(); | ||
206 | - $consulta = sprintf("SELECT padrao_ano_escolar FROM pmieducar.curso WHERE cod_curso = '%d'", $this->ref_cod_curso); | ||
207 | - $padrao_ano_escolar = $db->CampoUnico($consulta); | ||
208 | - $total_semanas = 0; | ||
209 | - | ||
210 | - if ($padrao_ano_escolar) { | ||
211 | - $meses = $db->CampoUnico(sprintf(" | ||
212 | - SELECT | ||
213 | - to_char(data_inicio, 'dd/mm') || '-' || to_char(data_fim, 'dd/mm') | ||
214 | - FROM | ||
215 | - pmieducar.ano_letivo_modulo, | ||
216 | - pmieducar.modulo | ||
217 | - WHERE | ||
218 | - modulo.cod_modulo = ano_letivo_modulo.ref_cod_modulo | ||
219 | - AND modulo.ativo = 1 | ||
220 | - AND ano_letivo_modulo.ref_cod_modulo = '%d' | ||
221 | - AND ano_letivo_modulo.sequencial = '%d' | ||
222 | - AND ref_ano = '%d' | ||
223 | - AND ref_ref_cod_escola = '%d' | ||
224 | - ORDER BY | ||
225 | - data_inicio,data_fim ASC | ||
226 | - ", $this->ref_cod_modulo, $this->sequencial, $this->ano, $this->ref_cod_escola)); | ||
227 | - | ||
228 | - $data = explode('-', $meses); | ||
229 | - | ||
230 | - if (!$this->data_ini) { | ||
231 | - $this->data_ini = $data[0]; | ||
232 | - } | ||
233 | - | ||
234 | - if (!$this->data_fim) { | ||
235 | - $this->data_fim = $data[1]; | ||
236 | - } | ||
237 | - | ||
238 | - $data_ini = explode('/', $data[0]); | ||
239 | - $data_fim = explode('/', $data[1]); | ||
240 | - | ||
241 | - $meses = array($data_ini[1],$data_fim[1]); | ||
242 | - $dias = array($data_ini[0],$data_fim[0]); | 208 | + // Seleciona a regra para verificar se a presença é geral |
209 | + $regraMapper = new RegraAvaliacao_Model_RegraDataMapper(); | ||
210 | + $regra = $regraMapper->find($regraId); | ||
211 | + $presencaGeral = $regra->get('tipoPresenca') == RegraAvaliacao_Model_TipoPresenca::GERAL; | ||
243 | 212 | ||
244 | - $total_semanas = 0; | 213 | + // Seleciona o curso para ver se é padrão e decidir qual ano letivo pesquisar |
214 | + $db = new clsBanco(); | ||
215 | + $consulta = sprintf('SELECT padrao_ano_escolar FROM pmieducar.curso WHERE cod_curso = \'%d\'', $this->ref_cod_curso); | ||
216 | + $padrao_ano_escolar = $db->CampoUnico($consulta); | ||
245 | 217 | ||
246 | - for ($mes = (int) $meses[0]; $mes <= (int) $meses[1]; $mes++) { | ||
247 | - $mes_final = FALSE; | 218 | + $total_semanas = 0; |
248 | 219 | ||
249 | - if ($mes == (int) $meses[0]) { | ||
250 | - $dia = $dias[0]; | ||
251 | - } | ||
252 | - elseif ($mes == (int)$meses[1]) { | ||
253 | - $dia = $dias[1]; | ||
254 | - $mes_final = TRUE; | ||
255 | - } | ||
256 | - else { | ||
257 | - $dia = 1; | ||
258 | - } | ||
259 | - | ||
260 | - $total_semanas += $this->getNumeroDiasMes($dia, $mes, $this->ano, $mes_final); | ||
261 | - } | ||
262 | - } | ||
263 | - else { | ||
264 | - $meses = $db->CampoUnico(sprintf(" | ||
265 | - SELECT | ||
266 | - to_char(data_inicio, 'dd/mm') || '-' || to_char(data_fim, 'dd/mm') | ||
267 | - FROM | ||
268 | - pmieducar.turma_modulo, | ||
269 | - pmieducar.modulo | ||
270 | - WHERE | ||
271 | - modulo.cod_modulo = turma_modulo.ref_cod_modulo | ||
272 | - AND ref_cod_turma = '%d' | ||
273 | - AND turma_modulo.ref_cod_modulo = '%d' | ||
274 | - AND turma_modulo.sequencial = '%d' | ||
275 | - AND to_char(data_inicio,'yyyy') = '%d' | ||
276 | - ORDER BY | ||
277 | - data_inicio,data_fim ASC | ||
278 | - ", $this->ref_cod_turma, $this->ref_cod_modulo, $this->sequencial, $this->ano)); | ||
279 | - | ||
280 | - $total_semanas = 0; | ||
281 | - | ||
282 | - $data = explode('-', $meses); | ||
283 | - | ||
284 | - if (!$this->data_ini) { | ||
285 | - $this->data_ini = $data[0]; | ||
286 | - } | 220 | + if ($padrao_ano_escolar) { |
221 | + // Seleciona o módulo do ano letivo da escola | ||
222 | + $data = $this->getDatasModulo($this->ref_cod_modulo, $this->sequencial, | ||
223 | + $this->ano, $this->ref_cod_escola); | ||
224 | + } | ||
225 | + else { | ||
226 | + // Seleciona o módulo do ano letivo da turma | ||
227 | + $data = $this->getDatasModulo($this->ref_cod_modulo, $this->sequencial, | ||
228 | + $this->ano, NULL, $this->ref_cod_turma); | ||
229 | + } | ||
287 | 230 | ||
288 | - if (!$this->data_fim) { | ||
289 | - $this->data_fim = $data[1]; | ||
290 | - } | 231 | + $meses = $data['meses']; |
232 | + $dias = $data['dias']; | ||
291 | 233 | ||
292 | - $data_ini = explode('/', $data[0]); | ||
293 | - $data_fim = explode('/', $data[1]); | 234 | + if (!$this->data_ini) { |
235 | + $this->data_ini = $data['dataInicial']; | ||
236 | + } | ||
294 | 237 | ||
295 | - $meses = array($data_ini[1],$data_fim[1]); | ||
296 | - $dias = array($data_ini[0],$data_fim[0]); | 238 | + if (!$this->data_fim) { |
239 | + $this->data_fim = $data['dataFinal']; | ||
240 | + } | ||
297 | 241 | ||
298 | - $total_semanas = 0; | 242 | + $total_semanas = 0; |
299 | 243 | ||
300 | - for ($mes = $meses[0]; $mes <= $meses[1]; $mes++) { | ||
301 | - $mes_final = FALSE; | 244 | + for ($mes = $meses[0]; $mes <= $meses[1]; $mes++) { |
245 | + $mes_final = FALSE; | ||
302 | 246 | ||
303 | - if ($mes == $meses[0]) { | ||
304 | - $dia = $dias[0]; | ||
305 | - } | ||
306 | - elseif ($mes == $meses[1]) { | ||
307 | - $dia = 1; | ||
308 | - $mes_final = TRUE; | ||
309 | - } | ||
310 | - else { | ||
311 | - $dia = 1; | ||
312 | - } | ||
313 | - | ||
314 | - $total_semanas += $this->getNumeroDiasMes($dia, $mes, $this->ano, $mes_final); | ||
315 | - } | 247 | + if ($mes == $meses[0]) { |
248 | + $dia = $dias[0]; | ||
316 | } | 249 | } |
317 | - | ||
318 | - $this->pdf = new clsPDF('Diário de Classe - ' . $this->ano, | ||
319 | - sprintf('Diário de Classe - %s até %s de %s', $data[0], $data[1], $this->ano), | ||
320 | - 'A4', '', FALSE, FALSE | ||
321 | - ); | ||
322 | - | ||
323 | - $this->mes_inicial = (int) $meses[0]; | ||
324 | - $this->mes_final = (int) $meses[1]; | ||
325 | - $this->pdf->largura = 842.0; | ||
326 | - $this->pdf->altura = 595.0; | ||
327 | - | ||
328 | - $this->total = $total_semanas; | ||
329 | - | ||
330 | - if (!$this->em_branco) { | ||
331 | - $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | ||
332 | - $obj_matricula_turma->setOrderby('nome_ascii'); | ||
333 | - $lista_matricula = $obj_matricula_turma->lista(NULL, $this->ref_cod_turma, | ||
334 | - NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, | ||
335 | - $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao, | ||
336 | - NULL, NULL, array(1, 2, 3), NULL, NULL, $this->ano, NULL, TRUE, NULL, | ||
337 | - NULL, TRUE); | 250 | + elseif ($mes == $meses[1]) { |
251 | + $dia = $dias[1]; | ||
252 | + $mes_final = TRUE; | ||
253 | + } | ||
254 | + else { | ||
255 | + $dia = 1; | ||
338 | } | 256 | } |
339 | 257 | ||
340 | - if ($lista_matricula || $this->em_branco) { | ||
341 | - $this->pdf->OpenPage(); | ||
342 | - $this->addCabecalho(); | ||
343 | - | ||
344 | - if ($this->em_branco) { | ||
345 | - $lista_matricula = array(); | ||
346 | - $this->numero_registros = $this->numero_registros ? | ||
347 | - $this->numero_registros : 20; | 258 | + $total_semanas += $this->getNumeroDiasMes($dia, $mes, $this->ano, $mes_final); |
259 | + } | ||
348 | 260 | ||
349 | - for ($i = 0 ; $i < $this->numero_registros; $i++) { | ||
350 | - $lista_matricula[] = ''; | ||
351 | - } | ||
352 | - } | 261 | + $this->pdf = new clsPDF('Diário de Classe - ' . $this->ano, |
262 | + sprintf('Diário de Classe - %s até %s de %s', $this->data_ini, $this->data_fim, $this->ano), | ||
263 | + 'A4', '', FALSE, FALSE | ||
264 | + ); | ||
353 | 265 | ||
354 | - $num = 0; | ||
355 | - foreach ($lista_matricula as $matricula) { | ||
356 | - $num++; | 266 | + $this->mes_inicial = (int) $meses[0]; |
267 | + $this->mes_final = (int) $meses[1]; | ||
268 | + $this->pdf->largura = 842.0; | ||
269 | + $this->pdf->altura = 595.0; | ||
357 | 270 | ||
358 | - if ($this->page_y > 500) { | ||
359 | - $this->desenhaLinhasVertical(); | ||
360 | - $this->pdf->ClosePage(); | ||
361 | - $this->pdf->OpenPage(); | ||
362 | - $this->page_y = 125; | ||
363 | - $this->addCabecalho(); | ||
364 | - } | 271 | + $this->total = $total_semanas; |
365 | 272 | ||
366 | - $this->pdf->quadrado_relativo(30, $this->page_y , 782, 19); | ||
367 | - $this->pdf->escreve_relativo($matricula['nome_aluno'] , 33, | ||
368 | - $this->page_y + 4, 160, 15, $fonte, 7, $corTexto, 'left'); | 273 | + if (!$this->em_branco) { |
274 | + $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | ||
275 | + $obj_matricula_turma->setOrderby('nome_ascii'); | ||
369 | 276 | ||
370 | - $this->pdf->escreve_relativo(sprintf('%02d', $num), 757, | ||
371 | - $this->page_y + 4, 30, 30, $fonte, 7, $corTexto, 'left'); | 277 | + $matriculaSituacao = array( |
278 | + App_Model_MatriculaSituacao::APROVADO, | ||
279 | + App_Model_MatriculaSituacao::REPROVADO, | ||
280 | + App_Model_MatriculaSituacao::EM_ANDAMENTO | ||
281 | + ); | ||
372 | 282 | ||
373 | - $this->page_y +=19; | ||
374 | - } | 283 | + $lista_matricula = $obj_matricula_turma->lista(NULL, $this->ref_cod_turma, |
284 | + NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, | ||
285 | + $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao, | ||
286 | + NULL, NULL, $matriculaSituacao, NULL, NULL, $this->ano, NULL, TRUE, NULL, | ||
287 | + NULL, TRUE | ||
288 | + ); | ||
289 | + } | ||
375 | 290 | ||
376 | - $this->desenhaLinhasVertical(); | 291 | + if ($this->em_branco) { |
292 | + $lista_matricula = array(); | ||
293 | + $this->numero_registros = $this->numero_registros ? $this->numero_registros : 20; | ||
377 | 294 | ||
378 | - $this->rodape(); | ||
379 | - $this->pdf->ClosePage(); | 295 | + for ($i = 0 ; $i < $this->numero_registros; $i++) { |
296 | + $lista_matricula[] = ''; | ||
380 | } | 297 | } |
381 | - else { | ||
382 | - echo ' | ||
383 | - <script> | ||
384 | - alert("Turma não possui matriculas"); | ||
385 | - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1)); | ||
386 | - </script>'; | 298 | + } |
387 | 299 | ||
388 | - return; | ||
389 | - } | 300 | + // Seleciona os componentes da escola/série |
301 | + $componentes = App_Model_IedFinder::getEscolaSerieDisciplina( | ||
302 | + $this->ref_cod_serie, $this->ref_cod_escola, TRUE | ||
303 | + ); | ||
390 | 304 | ||
391 | - $this->pdf->CloseFile(); | ||
392 | - $this->get_link = $this->pdf->GetLink(); | ||
393 | - } | ||
394 | - else { | ||
395 | - // Carga horária não globalizada gera relatório com uma disciplina por | ||
396 | - // página | ||
397 | - $obj_turma_disc = new clsPmieducarDisciplinaSerie(); | ||
398 | - $obj_turma_disc->setCamposLista('ref_cod_disciplina'); | ||
399 | - $lst_turma_disc = $obj_turma_disc->lista(NULL, $this->ref_cod_serie, 1); | ||
400 | - | ||
401 | - if ($lst_turma_disc) { | ||
402 | - $this->pdf = new clsPDF('Diário de Classe - ' . $this->ano, | ||
403 | - sprintf('Diário de Classe - %s até %s de %s', $this->data_ini, $this->data_fim, $this->ano), | ||
404 | - 'A4', '', FALSE, FALSE | ||
405 | - ); | ||
406 | - | ||
407 | - foreach ($lst_turma_disc as $disciplina) { | ||
408 | - $obj_disc = new clsPmieducarDisciplina($disciplina); | ||
409 | - $det_disc = $obj_disc->detalhe(); | ||
410 | - $this->nm_disciplina = $det_disc['nm_disciplina']; | ||
411 | - $this->page_y = 125; | 305 | + if (0 < count($componentes) && FALSE == $presencaGeral) { |
306 | + $this->total = $total_semanas = 0; | ||
412 | 307 | ||
308 | + foreach ($componentes as $componente) { | ||
309 | + $this->nm_disciplina = $componente->nome; | ||
310 | + $this->page_y = 125; | ||
311 | + | ||
312 | + if (FALSE == $presencaGeral) { | ||
413 | // Número de semanas dos meses | 313 | // Número de semanas dos meses |
414 | $obj_quadro = new clsPmieducarQuadroHorario(); | 314 | $obj_quadro = new clsPmieducarQuadroHorario(); |
415 | $obj_quadro->setCamposLista('cod_quadro_horario'); | 315 | $obj_quadro->setCamposLista('cod_quadro_horario'); |
@@ -417,8 +317,12 @@ class indice extends clsCadastro | @@ -417,8 +317,12 @@ class indice extends clsCadastro | ||
417 | NULL, NULL, NULL, NULL, 1); | 317 | NULL, NULL, NULL, NULL, 1); |
418 | 318 | ||
419 | if (!$quadro_horario) { | 319 | if (!$quadro_horario) { |
420 | - echo '<script>alert(\'Turma não possui quadro de horários\'); | ||
421 | - window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));</script>'; | 320 | + echo ' |
321 | + <script> | ||
322 | + alert(\'Turma não possui quadro de horários\'); | ||
323 | + window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1)); | ||
324 | + </script>'; | ||
325 | + | ||
422 | die(); | 326 | die(); |
423 | } | 327 | } |
424 | 328 | ||
@@ -427,190 +331,56 @@ class indice extends clsCadastro | @@ -427,190 +331,56 @@ class indice extends clsCadastro | ||
427 | $obj_quadro_horarios->setOrderby('1 asc'); | 331 | $obj_quadro_horarios->setOrderby('1 asc'); |
428 | 332 | ||
429 | $lista_quadro_horarios = $obj_quadro_horarios->lista($quadro_horario[0], | 333 | $lista_quadro_horarios = $obj_quadro_horarios->lista($quadro_horario[0], |
430 | - $this->ref_cod_serie, $this->ref_cod_escola, $disciplina, NULL, NULL, | 334 | + $this->ref_cod_serie, $this->ref_cod_escola, $componente->id, NULL, NULL, |
431 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); | 335 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1); |
432 | 336 | ||
433 | - $db = new clsBanco(); | ||
434 | - $consulta = sprintf('SELECT padrao_ano_escolar FROM pmieducar.curso WHERE cod_curso = \'%d\'', $this->ref_cod_curso); | ||
435 | - $padrao_ano_escolar = $db->CampoUnico($consulta); | ||
436 | - | ||
437 | - $total_semanas = 0; | ||
438 | - | ||
439 | - if ($padrao_ano_escolar) { | ||
440 | - $meses = $db->CampoUnico(sprintf(" | ||
441 | - SELECT | ||
442 | - to_char(data_inicio, 'dd/mm') || '-' || to_char(data_fim, 'dd/mm') | ||
443 | - FROM | ||
444 | - pmieducar.ano_letivo_modulo, | ||
445 | - pmieducar.modulo | ||
446 | - WHERE | ||
447 | - modulo.cod_modulo = ano_letivo_modulo.ref_cod_modulo | ||
448 | - AND modulo.ativo = 1 | ||
449 | - AND ano_letivo_modulo.ref_cod_modulo = '%d' | ||
450 | - AND ano_letivo_modulo.sequencial = '%d' | ||
451 | - AND ref_ano = '%d' | ||
452 | - AND ref_ref_cod_escola = '%d' | ||
453 | - ORDER BY | ||
454 | - data_inicio,data_fim ASC | ||
455 | - ", $this->ref_cod_modulo, $this->sequencial, $this->ano, $this->ref_cod_escola)); | ||
456 | - | ||
457 | - $data = explode('-', $meses); | ||
458 | - | ||
459 | - if (!$this->data_ini) { | ||
460 | - $this->data_ini = $data[0]; | ||
461 | - } | ||
462 | - | ||
463 | - if (!$this->data_fim) { | ||
464 | - $this->data_fim = $data[1]; | ||
465 | - } | ||
466 | - | ||
467 | - $data_ini = explode('/', $data[0]); | ||
468 | - $data_fim = explode('/', $data[1]); | ||
469 | - | ||
470 | - $meses = array($data_ini[1], $data_fim[1]); | ||
471 | - $dias = array($data_ini[0], $data_fim[0]); | 337 | + if (FALSE == $lista_quadro_horarios) { |
338 | + continue; | ||
472 | } | 339 | } |
473 | - else | ||
474 | - { | ||
475 | - $meses = $db->CampoUnico(sprintf(" | ||
476 | - SELECT | ||
477 | - to_char(data_inicio, 'mm') || '-' || to_char(data_fim, 'mm') | ||
478 | - FROM | ||
479 | - pmieducar.turma_modulo, | ||
480 | - pmieducar.modulo | ||
481 | - WHERE | ||
482 | - modulo.cod_modulo = turma_modulo.ref_cod_modulo | ||
483 | - AND ref_cod_turma = '%d' | ||
484 | - AND turma_modulo.ref_cod_modulo = '%d' | ||
485 | - AND turma_modulo.sequencial = '%d' | ||
486 | - AND to_char(data_inicio,'yyyy') = '%d' | ||
487 | - ORDER BY | ||
488 | - data_inicio, data_fim ASC | ||
489 | - ", $this->ref_cod_turma, $this->ref_cod_modulo, $this->sequencial, $this->ano)); | ||
490 | - | ||
491 | - $data = explode('-', $meses); | ||
492 | - | ||
493 | - if (!$this->data_ini) { | ||
494 | - $this->data_ini = $data[0]; | ||
495 | - } | ||
496 | 340 | ||
497 | - if (!$this->data_fim) { | ||
498 | - $this->data_fim = $data[1]; | ||
499 | - } | 341 | + for ($mes_ = $meses[0]; $mes_ <= $meses[1]; $mes_++) { |
342 | + $mes_final = FALSE; | ||
500 | 343 | ||
501 | - $data_ini = explode('/', $data[0]); | ||
502 | - $data_fim = explode('/', $data[1]); | ||
503 | - | ||
504 | - $meses = array($data_ini[1], $data_fim[1]); | ||
505 | - $dias = array($data_ini[0], $data_fim[0]); | ||
506 | - } | ||
507 | - | ||
508 | - $total_dias_semanas = 0; | ||
509 | - | ||
510 | - if($lista_quadro_horarios) { | ||
511 | - for($mes_ = $meses[0]; $mes_ <= $meses[1]; $mes_++) { | ||
512 | - $mes_final = FALSE; | ||
513 | - | ||
514 | - foreach ($lista_quadro_horarios as $dia_semana) { | ||
515 | - if($mes_ == $meses[0]) { | ||
516 | - $dia = $dias[0]; | ||
517 | - } | ||
518 | - elseif ($mes == $meses[1]) { | ||
519 | - $dia = 1; | ||
520 | - $mes_final = TRUE; | ||
521 | - } | ||
522 | - else { | ||
523 | - $dia = 1; | ||
524 | - } | ||
525 | - | ||
526 | - $total_dias_semanas += $this->getDiasSemanaMes( | ||
527 | - $dia, $mes_,$this->ano,$dia_semana,$mes_final | ||
528 | - ); | 344 | + foreach ($lista_quadro_horarios as $dia_semana) { |
345 | + if($mes_ == $meses[0]) { | ||
346 | + $dia = $dias[0]; | ||
529 | } | 347 | } |
530 | - } | ||
531 | - | ||
532 | - $this->mes_inicial = (int) $meses[0]; | ||
533 | - $this->mes_final = (int) $meses[1]; | ||
534 | - $this->pdf->largura = 842.0; | ||
535 | - $this->pdf->altura = 595.0; | ||
536 | - | ||
537 | - $this->total = $total_dias_semanas; | ||
538 | - | ||
539 | - if (!$this->total) { | ||
540 | - break; | ||
541 | - } | ||
542 | - } | ||
543 | - | ||
544 | - if (!$this->em_branco) { | ||
545 | - $obj_matricula_turma = new clsPmieducarMatriculaTurma(); | ||
546 | - $obj_matricula_turma->setOrderby('nome_ascii'); | ||
547 | - $lista_matricula = $obj_matricula_turma->lista(NULL, $this->ref_cod_turma, | ||
548 | - NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_serie, | ||
549 | - $this->ref_cod_curso, $this->ref_cod_escola, $this->ref_cod_instituicao, | ||
550 | - NULL, NULL, array(1, 2, 3), NULL, NULL, $this->ano, NULL, TRUE, NULL, | ||
551 | - NULL, TRUE | ||
552 | - ); | ||
553 | - } | ||
554 | - | ||
555 | - if ($lista_matricula || $this->em_branco) { | ||
556 | - $this->pdf->OpenPage(); | ||
557 | - $this->addCabecalho(); | ||
558 | - | ||
559 | - if ($this->em_branco) { | ||
560 | - $lista_matricula = array(); | ||
561 | - $this->numero_registros = $this->numero_registros ? $this->numero_registros : 20; | ||
562 | - | ||
563 | - for ($i = 0 ; $i < $this->numero_registros; $i++) { | ||
564 | - $lista_matricula[] = ''; | 348 | + elseif ($mes == $meses[1]) { |
349 | + $dia = 1; | ||
350 | + $mes_final = TRUE; | ||
565 | } | 351 | } |
566 | - } | ||
567 | - | ||
568 | - $num = 0; | ||
569 | - foreach ($lista_matricula as $matricula) { | ||
570 | - $num++; | ||
571 | - | ||
572 | - if ($this->page_y > 500) { | ||
573 | - $this->desenhaLinhasVertical(); | ||
574 | - $this->pdf->ClosePage(); | ||
575 | - $this->pdf->OpenPage(); | ||
576 | - $this->page_y = 125; | ||
577 | - $this->addCabecalho(); | 352 | + else { |
353 | + $dia = 1; | ||
578 | } | 354 | } |
579 | 355 | ||
580 | - $this->pdf->quadrado_relativo(30, $this->page_y, 782, 19); | ||
581 | - | ||
582 | - $this->pdf->escreve_relativo($matricula['nome_aluno'] , 33, | ||
583 | - $this->page_y + 4, 160, 15, $fonte, 7, $corTexto, 'left'); | ||
584 | - | ||
585 | - $this->pdf->escreve_relativo(sprintf('%02d', $num), 757, | ||
586 | - $this->page_y + 4, 30, 30, $fonte, 7, $corTexto, 'left'); | ||
587 | - | ||
588 | - $this->page_y +=19; | 356 | + $total_semanas += $this->getDiasSemanaMes( |
357 | + $dia, $mes_, $this->ano, $dia_semana, $mes_final | ||
358 | + ); | ||
589 | } | 359 | } |
590 | - | ||
591 | - $this->desenhaLinhasVertical(); | ||
592 | - $this->pdf->ClosePage(); | ||
593 | } | 360 | } |
594 | - else { | ||
595 | - echo ' | ||
596 | - <script> | ||
597 | - alert("Turma não possui matrículas"); | ||
598 | - window.parent.fechaExpansivel(\'div_dinamico_\' + (window.parent.DOM_divs.length - 1)); | ||
599 | - </script>'; | ||
600 | 361 | ||
601 | - return; | ||
602 | - } | 362 | + $this->total = $total_semanas; |
603 | } | 363 | } |
604 | - } | ||
605 | 364 | ||
606 | - if ($this->total) { | ||
607 | - $this->pdf->CloseFile(); | ||
608 | - $this->get_link = $this->pdf->GetLink(); | ||
609 | - } | ||
610 | - else { | ||
611 | - $this->mensagem = 'Não existem dias letivos cadastrados para esta turma'; | 365 | + if (!$this->total) { |
366 | + continue; | ||
367 | + } | ||
368 | + | ||
369 | + $this->gerarListaAlunos($lista_matricula); | ||
612 | } | 370 | } |
613 | } | 371 | } |
372 | + else { | ||
373 | + $this->gerarListaAlunos($lista_matricula); | ||
374 | + } | ||
375 | + | ||
376 | + if ($this->total) { | ||
377 | + $this->pdf->CloseFile(); | ||
378 | + $this->get_link = $this->pdf->GetLink(); | ||
379 | + } | ||
380 | + else { | ||
381 | + $this->mensagem = 'Não existem dias letivos cadastrados para esta turma'; | ||
382 | + return; | ||
383 | + } | ||
614 | 384 | ||
615 | echo sprintf(' | 385 | echo sprintf(' |
616 | <script> | 386 | <script> |
@@ -633,8 +403,127 @@ class indice extends clsCadastro | @@ -633,8 +403,127 @@ class indice extends clsCadastro | ||
633 | </html>', $this->get_link); | 403 | </html>', $this->get_link); |
634 | } | 404 | } |
635 | 405 | ||
406 | + /** | ||
407 | + * Retorna a data inicial e final de um módulo do ano letivo de uma escola ou | ||
408 | + * turma. | ||
409 | + * | ||
410 | + * @param int $codModulo | ||
411 | + * @param int $sequencial | ||
412 | + * @param int $ano | ||
413 | + * @param int|NULL $codEscola Opcional. O código da escola para o qual o | ||
414 | + * módulo do ano letivo será selecionado | ||
415 | + * @param int|NULL $codTurma Opcional. O código da turma com o qual o | ||
416 | + * módulo do ano letivo será selecionado | ||
417 | + * @throws App_Model_Exception | ||
418 | + * @return array | ||
419 | + */ | ||
420 | + function getDatasModulo($codModulo, $sequencial, $ano, $codEscola = NULL, $codTurma = NULL) | ||
421 | + { | ||
422 | + if (is_null($codEscola) && is_null($codTurma)) { | ||
423 | + require_once 'App/Model/Exception.php'; | ||
424 | + throw new App_Model_Exception('É necessário informar um código de escola ou de turma.'); | ||
425 | + } | ||
426 | + | ||
427 | + if ($codEscola) { | ||
428 | + $sql = sprintf(" | ||
429 | + SELECT | ||
430 | + to_char(data_inicio, 'dd/mm') || '-' || to_char(data_fim, 'dd/mm') | ||
431 | + FROM | ||
432 | + pmieducar.ano_letivo_modulo, | ||
433 | + pmieducar.modulo | ||
434 | + WHERE | ||
435 | + modulo.cod_modulo = ano_letivo_modulo.ref_cod_modulo | ||
436 | + AND modulo.ativo = 1 | ||
437 | + AND ano_letivo_modulo.ref_cod_modulo = '%d' | ||
438 | + AND ano_letivo_modulo.sequencial = '%d' | ||
439 | + AND ref_ano = '%d' | ||
440 | + AND ref_ref_cod_escola = '%d' | ||
441 | + ORDER BY | ||
442 | + data_inicio,data_fim ASC", $codModulo, $sequencial, $ano, $codEscola); | ||
443 | + } | ||
444 | + else { | ||
445 | + $sql = sprintf(" | ||
446 | + SELECT | ||
447 | + to_char(data_inicio, 'mm') || '-' || to_char(data_fim, 'mm') | ||
448 | + FROM | ||
449 | + pmieducar.turma_modulo, | ||
450 | + pmieducar.modulo | ||
451 | + WHERE | ||
452 | + modulo.cod_modulo = turma_modulo.ref_cod_modulo | ||
453 | + AND ref_cod_turma = '%d' | ||
454 | + AND turma_modulo.ref_cod_modulo = '%d' | ||
455 | + AND turma_modulo.sequencial = '%d' | ||
456 | + AND to_char(data_inicio, 'yyyy') = '%d' | ||
457 | + ORDER BY | ||
458 | + data_inicio, data_fim ASC", $codTurma, $codModulo, $sequencial, $ano); | ||
459 | + } | ||
460 | + | ||
461 | + $db = new clsBanco(); | ||
462 | + $meses = $db->CampoUnico($sql); | ||
463 | + | ||
464 | + $data = explode('-', $meses); | ||
465 | + | ||
466 | + $data_ini = explode('/', $data[0]); | ||
467 | + $data_fim = explode('/', $data[1]); | ||
468 | + | ||
469 | + return array( | ||
470 | + 'dataInicial' => $data[0], | ||
471 | + 'dataFinal' => $data[1], | ||
472 | + 'meses' => array($data_ini[1], $data_fim[1]), | ||
473 | + 'dias' => array($data_ini[0], $data_fim[0]) | ||
474 | + ); | ||
475 | + } | ||
476 | + | ||
477 | + /** | ||
478 | + * Gera a lista de alunos no documento PDF. | ||
479 | + * | ||
480 | + * @param array $lista_matricula | ||
481 | + * @param string $fonte | ||
482 | + * @param string $corTexto | ||
483 | + */ | ||
484 | + function gerarListaAlunos($lista_matricula = NULL, $fonte = 'arial', $corTexto = '#000000') | ||
485 | + { | ||
486 | + if (!$lista_matricula && !$this->em_branco) { | ||
487 | + echo ' | ||
488 | + <script> | ||
489 | + alert("Turma não possui matrículas"); | ||
490 | + window.parent.fechaExpansivel(\'div_dinamico_\' + (window.parent.DOM_divs.length - 1)); | ||
491 | + </script>'; | ||
492 | + | ||
493 | + return; | ||
494 | + } | ||
495 | + | ||
496 | + $this->pdf->OpenPage(); | ||
497 | + $this->addCabecalho(); | ||
498 | + | ||
499 | + $num = 0; | ||
500 | + foreach ($lista_matricula as $matricula) { | ||
501 | + $num++; | ||
636 | 502 | ||
637 | - public function addCabecalho() | 503 | + if ($this->page_y > 500) { |
504 | + $this->desenhaLinhasVertical(); | ||
505 | + $this->pdf->ClosePage(); | ||
506 | + $this->pdf->OpenPage(); | ||
507 | + $this->page_y = 125; | ||
508 | + $this->addCabecalho(); | ||
509 | + } | ||
510 | + | ||
511 | + $this->pdf->quadrado_relativo(30, $this->page_y, 782, 19); | ||
512 | + | ||
513 | + $this->pdf->escreve_relativo($matricula['nome'], 33, | ||
514 | + $this->page_y + 4, 160, 15, $fonte, 7, $corTexto, 'left'); | ||
515 | + | ||
516 | + $this->pdf->escreve_relativo(sprintf('%02d', $num), 757, | ||
517 | + $this->page_y + 4, 30, 30, $fonte, 7, $corTexto, 'left'); | ||
518 | + | ||
519 | + $this->page_y +=19; | ||
520 | + } | ||
521 | + | ||
522 | + $this->desenhaLinhasVertical(); | ||
523 | + $this->pdf->ClosePage(); | ||
524 | + } | ||
525 | + | ||
526 | + function addCabecalho() | ||
638 | { | 527 | { |
639 | /** | 528 | /** |
640 | * Variável global com objetos do CoreExt. | 529 | * Variável global com objetos do CoreExt. |
@@ -711,7 +600,6 @@ class indice extends clsCadastro | @@ -711,7 +600,6 @@ class indice extends clsCadastro | ||
711 | 80, $fonte, 10, $corTexto, 'left'); | 600 | 80, $fonte, 10, $corTexto, 'left'); |
712 | } | 601 | } |
713 | 602 | ||
714 | - | ||
715 | function desenhaLinhasVertical() | 603 | function desenhaLinhasVertical() |
716 | { | 604 | { |
717 | $corTexto = '#000000'; | 605 | $corTexto = '#000000'; |
@@ -778,16 +666,6 @@ class indice extends clsCadastro | @@ -778,16 +666,6 @@ class indice extends clsCadastro | ||
778 | $this->pdf->linha_relativa(660, 517, 130, 0); | 666 | $this->pdf->linha_relativa(660, 517, 130, 0); |
779 | } | 667 | } |
780 | 668 | ||
781 | - function Editar() | ||
782 | - { | ||
783 | - return FALSE; | ||
784 | - } | ||
785 | - | ||
786 | - function Excluir() | ||
787 | - { | ||
788 | - return FALSE; | ||
789 | - } | ||
790 | - | ||
791 | function getNumeroDiasMes($dia, $mes, $ano, $mes_final = FALSE) | 669 | function getNumeroDiasMes($dia, $mes, $ano, $mes_final = FALSE) |
792 | { | 670 | { |
793 | $year = $ano; | 671 | $year = $ano; |
@@ -830,7 +708,7 @@ class indice extends clsCadastro | @@ -830,7 +708,7 @@ class indice extends clsCadastro | ||
830 | $dia_semana_corrente = getdate($date); | 708 | $dia_semana_corrente = getdate($date); |
831 | $dia_semana_corrente = $dia_semana_corrente['wday'] + 1; | 709 | $dia_semana_corrente = $dia_semana_corrente['wday'] + 1; |
832 | 710 | ||
833 | - if (($dia_semana_corrente != 1 && $dia_semana_corrente != 7) && (array_search($day,$dias_nao_letivo) === FALSE)) { | 711 | + if (($dia_semana_corrente != 1 && $dia_semana_corrente != 7) && (array_search($day, $dias_nao_letivo) === FALSE)) { |
834 | $numero_dias++; | 712 | $numero_dias++; |
835 | } | 713 | } |
836 | } | 714 | } |
@@ -845,15 +723,15 @@ class indice extends clsCadastro | @@ -845,15 +723,15 @@ class indice extends clsCadastro | ||
845 | 723 | ||
846 | $date = mktime(1, 1, 1, $month, $dia, $year); | 724 | $date = mktime(1, 1, 1, $month, $dia, $year); |
847 | 725 | ||
848 | - $first_day_of_month = strtotime("-" . (date("d", $date) - 1) . " days", $date); | ||
849 | - $last_day_of_month = strtotime("+" . (date("t", $first_day_of_month) - 1) . " days", $first_day_of_month); | 726 | + $first_day_of_month = strtotime('-' . (date('d', $date) - 1) . ' days', $date); |
727 | + $last_day_of_month = strtotime('+' . (date('t', $first_day_of_month) - 1) . ' days', $first_day_of_month); | ||
850 | 728 | ||
851 | - $last_day_of_month = date("d", $last_day_of_month); | 729 | + $last_day_of_month = date('d', $last_day_of_month); |
852 | 730 | ||
853 | $numero_dias = 0; | 731 | $numero_dias = 0; |
854 | 732 | ||
855 | $obj_calendario = new clsPmieducarCalendarioAnoLetivo(); | 733 | $obj_calendario = new clsPmieducarCalendarioAnoLetivo(); |
856 | - $obj_calendario->setCamposLista("cod_calendario_ano_letivo"); | 734 | + $obj_calendario->setCamposLista('cod_calendario_ano_letivo'); |
857 | $lista_calendario = $obj_calendario->lista(NULL, $this->ref_cod_escola, NULL, | 735 | $lista_calendario = $obj_calendario->lista(NULL, $this->ref_cod_escola, NULL, |
858 | NULL, $this->ano, NULL, NULL, NULL, NULL, 1); | 736 | NULL, $this->ano, NULL, NULL, NULL, NULL, 1); |
859 | 737 | ||
@@ -863,14 +741,14 @@ class indice extends clsCadastro | @@ -863,14 +741,14 @@ class indice extends clsCadastro | ||
863 | 741 | ||
864 | $obj_dia = new clsPmieducarCalendarioDia(); | 742 | $obj_dia = new clsPmieducarCalendarioDia(); |
865 | $obj_dia->setCamposLista('dia'); | 743 | $obj_dia->setCamposLista('dia'); |
866 | - $dias_nao_letivo = $obj_dia->lista($lista_calendario,$mes, NULL, NULL, NULL, | 744 | + $dias_nao_letivo = $obj_dia->lista($lista_calendario, $mes, NULL, NULL, NULL, |
867 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, "'n'"); | 745 | NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, "'n'"); |
868 | 746 | ||
869 | if (!$dias_nao_letivo) { | 747 | if (!$dias_nao_letivo) { |
870 | $dias_nao_letivo = array(); | 748 | $dias_nao_letivo = array(); |
871 | } | 749 | } |
872 | 750 | ||
873 | - if($mes_final) { | 751 | + if ($mes_final) { |
874 | $last_day_of_month = $dia; | 752 | $last_day_of_month = $dia; |
875 | $dia = 1; | 753 | $dia = 1; |
876 | } | 754 | } |
@@ -880,11 +758,11 @@ class indice extends clsCadastro | @@ -880,11 +758,11 @@ class indice extends clsCadastro | ||
880 | $dia_semana_corrente = getdate($date); | 758 | $dia_semana_corrente = getdate($date); |
881 | $dia_semana_corrente = $dia_semana_corrente['wday'] + 1; | 759 | $dia_semana_corrente = $dia_semana_corrente['wday'] + 1; |
882 | 760 | ||
883 | - $data_atual = sprintf("%s/%s/%s", $day, $mes, $ano); | ||
884 | - $data_final = sprintf("%s/%s", $this->data_fim, $ano); | 761 | + $data_atual = sprintf('%s/%s/%s', $day, $mes, $ano); |
762 | + $data_final = sprintf('%s/%s', $this->data_fim, $ano); | ||
885 | 763 | ||
886 | if (($dia_semana == $dia_semana_corrente) && | 764 | if (($dia_semana == $dia_semana_corrente) && |
887 | - (array_search($day,$dias_nao_letivo) === FALSE) && data_maior($data_final, $data_atual) | 765 | + (array_search($day, $dias_nao_letivo) === FALSE) && data_maior($data_final, $data_atual) |
888 | ) { | 766 | ) { |
889 | $numero_dias++; | 767 | $numero_dias++; |
890 | } | 768 | } |
@@ -892,6 +770,16 @@ class indice extends clsCadastro | @@ -892,6 +770,16 @@ class indice extends clsCadastro | ||
892 | 770 | ||
893 | return $numero_dias; | 771 | return $numero_dias; |
894 | } | 772 | } |
773 | + | ||
774 | + function Editar() | ||
775 | + { | ||
776 | + return FALSE; | ||
777 | + } | ||
778 | + | ||
779 | + function Excluir() | ||
780 | + { | ||
781 | + return FALSE; | ||
782 | + } | ||
895 | } | 783 | } |
896 | 784 | ||
897 | // Instancia objeto de página | 785 | // Instancia objeto de página |