コード例 #1
0
ファイル: educar_turma_cad.php プロジェクト: krlsdu/ieducar
 function Gerar()
 {
     if ($_POST) {
         foreach ($_POST as $campo => $val) {
             $this->{$campo} = $this->{$campo} ? $this->{$campo} : $val;
         }
     }
     $this->campoOculto('cod_turma', $this->cod_turma);
     // foreign keys
     $obrigatorio = FALSE;
     $instituicao_obrigatorio = TRUE;
     $escola_curso_obrigatorio = TRUE;
     $curso_obrigatorio = TRUE;
     $get_escola = TRUE;
     $get_escola_curso_serie = FALSE;
     $sem_padrao = TRUE;
     $get_curso = TRUE;
     $bloqueia = false;
     $anoVisivel = false;
     if (isset($this->ano) || !is_numeric($this->cod_turma)) {
         $anoVisivel = true;
     }
     if (!isset($this->cod_turma)) {
         $bloqueia = false;
     } else {
         if (is_numeric($this->cod_turma)) {
             $obj_matriculas_turma = new clsPmieducarMatriculaTurma();
             $obj_matriculas_turma->setOrderby('nome_aluno');
             $lst_matriculas_turma = $obj_matriculas_turma->lista(NULL, $this->cod_turma, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, array(1, 2, 3), NULL, NULL, NULL, NULL, TRUE, NULL, 1, TRUE);
             if (is_array($lst_matriculas_turma) && count($lst_matriculas_turma) > 0) {
                 $bloqueia = true;
             }
         }
     }
     $desabilitado = $bloqueia;
     include 'include/pmieducar/educar_campo_lista.php';
     if ($this->ref_cod_escola) {
         $this->ref_ref_cod_escola = $this->ref_cod_escola;
     }
     $opcoes_serie = array('' => 'Selecione');
     // Editar
     if ($this->ref_cod_curso) {
         $obj_serie = new clsPmieducarSerie();
         $obj_serie->setOrderby('nm_serie ASC');
         $lst_serie = $obj_serie->lista(NULL, NULL, NULL, $this->ref_cod_curso, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
         if (is_array($lst_serie) && count($lst_serie)) {
             foreach ($lst_serie as $serie) {
                 $opcoes_serie[$serie['cod_serie']] = $serie['nm_serie'];
             }
         }
     }
     if ($bloqueia) {
         $this->campoOculto('serie_param', $this->serie_param = $this->ref_ref_cod_serie);
         $this->campoOculto('escola_param', $this->escola_param = $this->ref_cod_escola);
     }
     $this->campoLista('ref_ref_cod_serie', 'Série', $opcoes_serie, $this->ref_ref_cod_serie, '', FALSE, '', NULL, $bloqueia);
     // o campo ano somente é exibido para turmas novas  ou cadastradas após inclusão deste campo.
     if ($anoVisivel) {
         $this->inputsHelper()->dynamic('anoLetivo', array('disabled' => $bloqueia));
         if ($bloqueia) {
             $this->inputsHelper()->hidden('ano_hidden', array('value' => $this->ano));
         }
     }
     // Infra prédio cômodo
     $opcoes = array('' => 'Selecione');
     // Editar
     if ($this->ref_ref_cod_escola) {
         $obj_infra_predio = new clsPmieducarInfraPredio();
         $obj_infra_predio->setOrderby('nm_predio ASC');
         $lst_infra_predio = $obj_infra_predio->lista(NULL, NULL, NULL, $this->ref_ref_cod_escola, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
         if (is_array($lst_infra_predio) && count($lst_infra_predio)) {
             foreach ($lst_infra_predio as $predio) {
                 $obj_infra_predio_comodo = new clsPmieducarInfraPredioComodo();
                 $lst_infra_predio_comodo = $obj_infra_predio_comodo->lista(NULL, NULL, NULL, NULL, $predio['cod_infra_predio'], NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
                 if (is_array($lst_infra_predio_comodo) && count($lst_infra_predio_comodo)) {
                     foreach ($lst_infra_predio_comodo as $comodo) {
                         $opcoes[$comodo['cod_infra_predio_comodo']] = $comodo['nm_comodo'];
                     }
                 }
             }
         }
     }
     $this->campoLista('ref_cod_infra_predio_comodo', 'Sala', $opcoes, $this->ref_cod_infra_predio_comodo, NULL, NULL, NULL, NULL, NULL, FALSE);
     $array_servidor = array('' => 'Selecione um servidor');
     if ($this->ref_cod_regente) {
         $obj_pessoa = new clsPessoa_($this->ref_cod_regente);
         $det = $obj_pessoa->detalhe();
         $array_servidor[$this->ref_cod_regente] = $det['nome'];
     }
     $this->campoListaPesq('ref_cod_regente', 'Professor/Regente', $array_servidor, $this->ref_cod_regente, '', '', FALSE, '', '', NULL, NULL, '', TRUE, FALSE, FALSE);
     // Turma tipo
     $opcoes = array('' => 'Selecione');
     // Editar
     if ($this->ref_cod_instituicao) {
         $objTemp = new clsPmieducarTurmaTipo();
         $objTemp->setOrderby('nm_tipo ASC');
         $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
         if (is_array($lista) && count($lista)) {
             foreach ($lista as $registro) {
                 $opcoes[$registro['cod_turma_tipo']] = $registro['nm_tipo'];
             }
         }
     }
     $this->campoLista('ref_cod_turma_tipo', 'Tipo de Turma', $opcoes, $this->ref_cod_turma_tipo, '', FALSE, '', NULL);
     $this->campoTexto('nm_turma', 'Turma', $this->nm_turma, 30, 255, TRUE);
     $this->campoTexto('sgl_turma', 'Sigla', $this->sgl_turma, 15, 15, FALSE);
     $this->campoNumero('max_aluno', 'Máximo de Alunos', $this->max_aluno, 3, 3, TRUE);
     $this->inputsHelper()->date('data_fechamento', array('required' => false, 'label' => 'Data de fechamento', 'value' => Portabilis_Date_Utils::pgSQLToBr($this->data_fechamento)));
     $ativo = isset($this->cod_turma) ? dbBool($this->visivel) : true;
     $this->campoCheck('visivel', 'Ativo', $ativo);
     $this->campoCheck('multiseriada', 'Multi-Seriada', $this->multiseriada, '', FALSE, FALSE);
     $this->campoLista('ref_ref_cod_serie_mult', 'Série', array('' => 'Selecione'), '', '', FALSE, '', '', '', FALSE);
     $this->campoOculto('ref_ref_cod_serie_mult_', $this->ref_ref_cod_serie_mult);
     $this->campoQuebra2();
     // hora
     $this->campoHora('hora_inicial', 'Hora Inicial', $this->hora_inicial, FALSE);
     $this->campoHora('hora_final', 'Hora Final', $this->hora_final, FALSE);
     $this->campoHora('hora_inicio_intervalo', Portabilis_String_Utils::toLatin1('Hora Início Intervalo'), $this->hora_inicio_intervalo, FALSE);
     $this->campoHora('hora_fim_intervalo', 'Hora Fim Intervalo', $this->hora_fim_intervalo, FALSE);
     $this->inputsHelper()->turmaTurno();
     // modelos boletim
     require_once 'Portabilis/Model/Report/TipoBoletim.php';
     require_once 'Portabilis/Array/Utils.php';
     $tiposBoletim = Portabilis_Model_Report_TipoBoletim::getInstance()->getEnums();
     $tiposBoletim = Portabilis_Array_Utils::insertIn(null, "Selecione um modelo", $tiposBoletim);
     $this->campoLista('tipo_boletim', Portabilis_String_Utils::toLatin1('Modelo relatório boletim'), $tiposBoletim, $this->tipo_boletim);
     $this->campoQuebra2();
     if ($this->ref_ref_cod_serie) {
         require_once 'ComponenteCurricular/Model/ComponenteDataMapper.php';
         require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php';
         require_once 'ComponenteCurricular/Model/TurmaDataMapper.php';
         $disciplinas = '';
         $conteudo = '';
         // Instancia o mapper de componente curricular
         $mapper = new ComponenteCurricular_Model_ComponenteDataMapper();
         // Instancia o mapper de ano escolar
         $anoEscolar = new ComponenteCurricular_Model_AnoEscolarDataMapper();
         $lista = $anoEscolar->findComponentePorSerie($this->ref_ref_cod_serie);
         // Instancia o mapper de turma
         $componenteTurmaMapper = new ComponenteCurricular_Model_TurmaDataMapper();
         $componentesTurma = array();
         if (isset($this->cod_turma) && is_numeric($this->cod_turma)) {
             $componentesTurma = $componenteTurmaMapper->findAll(array(), array('turma' => $this->cod_turma));
         }
         $componentes = array();
         foreach ($componentesTurma as $componenteTurma) {
             $componentes[$componenteTurma->get('componenteCurricular')] = $componenteTurma;
         }
         unset($componentesTurma);
         $this->escola_serie_disciplina = array();
         if (is_array($lista) && count($lista)) {
             $conteudo .= '<div style="margin-bottom: 10px;">';
             $conteudo .= '  <span style="display: block; float: left; width: 250px;">Nome</span>';
             $conteudo .= '  <span style="display: block; float: left; width: 100px;">' . Portabilis_String_Utils::toLatin1('Carga horária') . '</span>';
             $conteudo .= '  <span style="display: block; float: left">' . Portabilis_String_Utils::toLatin1('Usar padrão do componente?') . '</span>';
             $conteudo .= '</div>';
             $conteudo .= '<br style="clear: left" />';
             foreach ($lista as $registro) {
                 $checked = '';
                 $usarComponente = FALSE;
                 if (isset($componentes[$registro->id])) {
                     $checked = 'checked="checked"';
                 }
                 if (is_null($componentes[$registro->id]->cargaHoraria) || 0 == $componentes[$registro->id]->cargaHoraria) {
                     $usarComponente = TRUE;
                 } else {
                     $cargaHoraria = $componentes[$registro->id]->cargaHoraria;
                 }
                 $cargaComponente = $registro->cargaHoraria;
                 $conteudo .= '<div style="margin-bottom: 10px; float: left">';
                 $conteudo .= "  <label style='display: block; float: left; width: 250px'><input type=\"checkbox\" {$checked} name=\"disciplinas[{$registro->id}]\" id=\"disciplinas[]\" value=\"{$registro->id}\">{$registro}</label>";
                 $conteudo .= "  <label style='display: block; float: left; width: 100px;'><input type='text' name='carga_horaria[{$registro->id}]' value='{$cargaHoraria}' size='5' maxlength='7'></label>";
                 $conteudo .= "  <label style='display: block; float: left'><input type='checkbox' name='usar_componente[{$registro->id}]' value='1' " . ($usarComponente == TRUE ? $checked : '') . ">({$cargaComponente} h)</label>";
                 $conteudo .= '</div>';
                 $conteudo .= '<br style="clear: left" />';
                 $cargaHoraria = '';
             }
             $disciplinas = '<table cellspacing="0" cellpadding="0" border="0">';
             $disciplinas .= sprintf('<tr align="left"><td>%s</td></tr>', $conteudo);
             $disciplinas .= '</table>';
         } else {
             $disciplinas = Portabilis_String_Utils::toLatin1('A série/ano escolar não possui componentes curriculares cadastrados.');
         }
     }
     $componentes = $help = array();
     try {
         $componentes = App_Model_IedFinder::getEscolaSerieDisciplina($this->ref_ref_cod_serie, $this->ref_cod_escola);
     } catch (Exception $e) {
     }
     foreach ($componentes as $componente) {
         $help[] = sprintf('%s (%.0f h)', $componente->nome, $componente->cargaHoraria);
     }
     if (count($componentes)) {
         $help = '<ul><li>' . implode('</li><li>', $help) . '</li></ul>';
     } else {
         $help = '';
     }
     $label = 'Componentes curriculares:<br />' . '<strong>Observa&ccedil;&atilde;o:</strong> caso n&atilde;o defina os componentes<br />' . 'curriculares para a turma, esta usar&aacute; a defini&ccedil;&atilde;o<br />' . 'da s&eacute;rie/ano escolar da escola:' . '<span id="_escola_serie_componentes">%s</span>';
     $label = sprintf($label, $help);
     $this->campoRotulo('disciplinas_', $label, "<div id='disciplinas'>{$disciplinas}</div>");
     $this->campoQuebra2();
     if ($_POST['turma_modulo']) {
         $this->turma_modulo = unserialize(urldecode($_POST['turma_modulo']));
     }
     $qtd_modulo = count($this->turma_modulo) == 0 ? 1 : count($this->turma_modulo) + 1;
     if (is_numeric($this->cod_turma) && !$_POST) {
         $obj = new clsPmieducarTurmaModulo();
         $registros = $obj->lista($this->cod_turma);
         if ($registros) {
             foreach ($registros as $campo) {
                 $this->turma_modulo[$campo[$qtd_modulo]]['sequencial_'] = $campo['sequencial'];
                 $this->turma_modulo[$campo[$qtd_modulo]]['ref_cod_modulo_'] = $campo['ref_cod_modulo'];
                 $this->turma_modulo[$campo[$qtd_modulo]]['data_inicio_'] = dataFromPgToBr($campo['data_inicio']);
                 $this->turma_modulo[$campo[$qtd_modulo]]['data_fim_'] = dataFromPgToBr($campo['data_fim']);
                 $qtd_modulo++;
             }
         }
     }
     if ($_POST["ref_cod_modulo"] && $_POST["data_inicio"] && $_POST["data_fim"]) {
         $this->turma_modulo[$qtd_modulo]["sequencial_"] = $qtd_modulo;
         $this->turma_modulo[$qtd_modulo]["ref_cod_modulo_"] = $_POST["ref_cod_modulo"];
         $this->turma_modulo[$qtd_modulo]["data_inicio_"] = $_POST["data_inicio"];
         $this->turma_modulo[$qtd_modulo]["data_fim_"] = $_POST["data_fim"];
         $qtd_modulo++;
         unset($this->ref_cod_modulo);
         unset($this->data_inicio);
         unset($this->data_fim);
     }
     $this->campoOculto("excluir_modulo", "");
     $qtd_modulo = 1;
     unset($aux);
     if ($this->turma_modulo) {
         foreach ($this->turma_modulo as $campo) {
             if ($this->excluir_modulo == $campo['sequencial_']) {
                 $this->turma_modulo[$campo['sequencial']] = NULL;
                 $this->excluir_modulo = NULL;
             } else {
                 $obj_modulo = new clsPmieducarModulo($campo['ref_cod_modulo_']);
                 $det_modulo = $obj_modulo->detalhe();
                 $nm_tipo_modulo = $det_modulo['nm_tipo'];
                 $this->campoTextoInv('ref_cod_modulo_' . $campo['sequencial_'], '', $nm_tipo_modulo, 30, 255, FALSE, FALSE, TRUE, '', '', '', '', 'ref_cod_modulo');
                 $this->campoTextoInv('data_inicio_' . $campo['sequencial_'], '', $campo['data_inicio_'], 10, 10, FALSE, FALSE, TRUE, '', '', '', '', '');
                 $this->campoTextoInv('data_fim_' . $campo['sequencial_'], '', $campo['data_fim_'], 10, 10, FALSE, FALSE, FALSE, '', "<a href='#' onclick=\"document.getElementById('excluir_modulo').value = '{$campo["sequencial_"]}'; document.getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>", '', '', '');
                 $aux[$qtd_modulo]['sequencial_'] = $qtd_modulo;
                 $aux[$qtd_modulo]['ref_cod_modulo_'] = $campo['ref_cod_modulo_'];
                 $aux[$qtd_modulo]['data_inicio_'] = $campo['data_inicio_'];
                 $aux[$qtd_modulo]['data_fim_'] = $campo['data_fim_'];
                 $qtd_modulo++;
             }
         }
         unset($this->turma_modulo);
         $this->turma_modulo = $aux;
     }
     $this->campoOculto('turma_modulo', serialize($this->turma_modulo));
     // Módulo
     // foreign keys
     $opcoes = array('' => 'Selecione');
     // Editar
     if ($this->ref_cod_instituicao) {
         $objTemp = new clsPmieducarModulo();
         $objTemp->setOrderby('nm_tipo ASC');
         $lista = $objTemp->lista(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
         if (is_array($lista) && count($lista)) {
             foreach ($lista as $registro) {
                 $opcoes[$registro['cod_modulo']] = $registro['nm_tipo'];
             }
         }
     }
     $this->campoLista('ref_cod_modulo', Portabilis_String_utils::toLatin1('Módulo'), $opcoes, $this->ref_cod_modulo, NULL, NULL, NULL, NULL, NULL, FALSE);
     $this->campoData('data_inicio', Portabilis_String_utils::toLatin1('Data Início'), $this->data_inicio, FALSE);
     $this->campoData('data_fim', 'Data Fim', $this->data_fim, FALSE);
     $this->campoOculto('incluir_modulo', '');
     $this->campoRotulo('bt_incluir_modulo', Portabilis_String_utils::toLatin1('Módulo'), "<a href='#' onclick=\"document.getElementById('incluir_modulo').value = 'S'; document.getElementById('tipoacao').value = ''; acao();\"><img src='imagens/nvp_bot_adiciona.gif' alt='adicionar' title='Incluir' border=0></a>");
     $this->campoQuebra2();
     if ($_POST['turma_dia_semana']) {
         $this->turma_dia_semana = unserialize(urldecode($_POST['turma_dia_semana']));
     }
     if (is_numeric($this->cod_turma) && !$_POST) {
         $obj = new clsPmieducarTurmaDiaSemana();
         $registros = $obj->lista(NULL, $this->cod_turma);
         if ($registros) {
             foreach ($registros as $campo) {
                 $aux['dia_semana_'] = $campo['dia_semana'];
                 $aux['hora_inicial_'] = $campo['hora_inicial'];
                 $aux['hora_final_'] = $campo['hora_final'];
                 $this->turma_dia_semana[] = $aux;
             }
         }
     }
     unset($aux);
     if ($_POST['dia_semana'] && $_POST['ds_hora_inicial'] && $_POST['ds_hora_final']) {
         $aux['dia_semana_'] = $_POST['dia_semana'];
         $aux['hora_inicial_'] = $_POST['ds_hora_inicial'];
         $aux['hora_final_'] = $_POST['ds_hora_final'];
         $this->turma_dia_semana[] = $aux;
         unset($this->dia_semana);
         unset($this->ds_hora_inicial);
         unset($this->ds_hora_final);
     }
     $this->campoOculto('excluir_dia_semana', '');
     unset($aux);
     if ($this->turma_dia_semana) {
         foreach ($this->turma_dia_semana as $key => $dias_semana) {
             if ($this->excluir_dia_semana == $dias_semana['dia_semana_']) {
                 unset($this->turma_dia_semana[$key]);
                 unset($this->excluir_dia_semana);
             } else {
                 $nm_dia_semana = $this->dias_da_semana[$dias_semana['dia_semana_']];
                 $this->campoTextoInv('dia_semana_' . $dias_semana['dia_semana_'], '', $nm_dia_semana, 8, 8, FALSE, FALSE, TRUE, '', '', '', '', 'dia_semana');
                 $this->campoTextoInv('hora_inicial_' . $dias_semana['dia_semana_'], '', $dias_semana['hora_inicial_'], 5, 5, FALSE, FALSE, TRUE, '', '', '', '', 'ds_hora_inicial_');
                 $this->campoTextoInv('hora_final_' . $dias_semana['dia_semana_'], '', $dias_semana['hora_final_'], 5, 5, FALSE, FALSE, FALSE, '', "<a href='#' onclick=\"document.getElementById('excluir_dia_semana').value = '{$dias_semana["dia_semana_"]}'; document.getElementById('tipoacao').value = ''; {$this->__nome}.submit();\"><img src='imagens/nvp_bola_xis.gif' title='Excluir' border=0></a>", '', '', 'ds_hora_final_');
                 $aux['dia_semana_'] = $dias_semana['dia_semana_'];
                 $aux['hora_inicial_'] = $dias_semana['hora_inicial_'];
                 $aux['hora_final_'] = $dias_semana['hora_final_'];
             }
         }
     }
     $this->campoOculto('turma_dia_semana', serialize($this->turma_dia_semana));
     if (class_exists('clsPmieducarTurmaDiaSemana')) {
         $opcoes = $this->dias_da_semana;
     } else {
         echo '<!--\\nErro\\nClasse clsPmieducarTurmaDiaSemana não encontrada\\n-->';
         $opcoes = array('' => Portabilis_String_utils::toLatin1('Erro na geração'));
     }
     $this->campoLista('dia_semana', 'Dia Semana', $opcoes, $this->dia_semana, NULL, false, '', '', false, false);
     $this->campoHora('ds_hora_inicial', 'Hora Inicial', $this->ds_hora_inicial, FALSE);
     $this->campoHora('ds_hora_final', 'Hora Final', $this->ds_hora_final, FALSE);
     $this->campoOculto('incluir_dia_semana', '');
     $this->campoRotulo('bt_incluir_dia_semana', 'Dia Semana', "<a href='#' onclick=\"document.getElementById('incluir_dia_semana').value = 'S'; document.getElementById('tipoacao').value = ''; acao();\"><img src='imagens/nvp_bot_adiciona.gif' alt='adicionar' title='Incluir' border=0></a>");
     $this->campoOculto('padrao_ano_escolar', $this->padrao_ano_escolar);
     $this->acao_enviar = 'valida()';
 }
 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;
     }
     if ($this->ref_cod_escola) {
         $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_calendario = new clsPmieducarEscolaAnoLetivo();
     $lista_calendario = $obj_calendario->lista($this->ref_cod_escola, $this->ano, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL);
     $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'];
     $obj_pessoa = new clsPessoa_($det_turma['ref_cod_regente']);
     $det = $obj_pessoa->detalhe();
     $this->nm_professor = $det['nome'];
     if (!$lista_calendario) {
         echo '
     <script>
       alert("Escola não possui calendário definido para este ano");
       window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
     </script>';
         return TRUE;
     }
     $titulo = 'Diário de Classe - ' . $this->ano;
     $prox_mes = $this->mes + 1;
     $this->pdf = new clsPDF($titulo, $titulo, 'A4', '', FALSE, FALSE);
     $altura_linha = 15;
     $inicio_escrita_y = 175;
     $altura_pagina = 760;
     $obj = new clsPmieducarSerie();
     $obj->setOrderby('cod_serie, etapa_curso');
     $lista_serie_curso = $obj->lista(NULL, NULL, NULL, $this->ref_cod_curso, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
     $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);
     $det_curso = $obj_curso->detalhe();
     $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);
     $det_curso = $obj_curso->detalhe();
     // Recupera a lista de componentes curriculares da escola/série
     $componentes = App_Model_IedFinder::getEscolaSerieDisciplina($this->ref_cod_serie, $this->ref_cod_escola);
     if (0 == count($componentes)) {
         echo '
     <script>
       alert("Turma não possui matriculas");
       window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
     </script>';
         return;
     } else {
         foreach ($componentes as $id => $componente) {
             $this->nm_disciplina = $componente->nome;
             $this->page_y = 139;
             // Número de semanas dos meses
             $obj_quadro = new clsPmieducarQuadroHorario();
             $obj_quadro->setCamposLista('cod_quadro_horario');
             $quadro_horario = $obj_quadro->lista(NULL, NULL, NULL, $this->ref_cod_turma, NULL, NULL, NULL, NULL, 1);
             if (!$quadro_horario && $det_curso['avaliacao_globalizada'] == 't') {
                 echo '
         <script>
           alert("Turma não possui quadro de horários");
           window.location = "educar_relatorio_diario_classe.php";
         </script>';
                 break;
             }
             $obj_quadro_horarios = new clsPmieducarQuadroHorarioHorarios();
             $obj_quadro_horarios->setCamposLista('dia_semana');
             $obj_quadro_horarios->setOrderby('1 asc');
             $lista_quadro_horarios = $obj_quadro_horarios->lista($quadro_horario, $this->ref_cod_serie, $this->ref_cod_escola, $disciplina, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
             if (!$this->em_branco) {
                 $obj_matricula_turma = new clsPmieducarMatriculaTurma();
                 $obj_matricula_turma->setOrderby('nome_ascii');
                 $lista_matricula = $obj_matricula_turma->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);
             }
             $num_aluno = 1;
             if ($lista_matricula || $this->em_branco) {
                 $this->pdf->OpenPage();
                 $this->addCabecalho();
                 if ($this->em_branco) {
                     $lista_matricula = array();
                     $this->numero_registros = $this->numero_registros ? $this->numero_registros : 20;
                     for ($i = 0; $i < $this->numero_registros; $i++) {
                         $lista_matricula[] = '';
                     }
                 }
                 foreach ($lista_matricula as $matricula) {
                     if ($this->page_y > $altura_pagina) {
                         $this->desenhaLinhasVertical();
                         $this->pdf->ClosePage();
                         $this->pdf->OpenPage();
                         $this->page_y = 139;
                         $this->addCabecalho();
                     }
                     $this->pdf->quadrado_relativo(30, $this->page_y, 540, $altura_linha);
                     $this->pdf->escreve_relativo($num_aluno, 38, $this->page_y + 4, 30, 15, $fonte, 7, $corTexto, 'left');
                     $this->pdf->escreve_relativo($matricula['nome_aluno'], 55, $this->page_y + 4, 160, 15, $fonte, 7, $corTexto, 'left');
                     $num_aluno++;
                     $this->page_y += $altura_linha;
                 }
                 $this->desenhaLinhasVertical();
                 $this->rodape();
                 $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);
 }
コード例 #3
0
    function Gerar()
    {
        @session_start();
        $this->pessoa_logada = $_SESSION['id_pessoa'];
        session_write_close();
        $this->titulo = 'Escola S&eacute;rie - Detalhe';
        $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet');
        $this->ref_cod_serie = $_GET['ref_cod_serie'];
        $this->ref_cod_escola = $_GET['ref_cod_escola'];
        $tmp_obj = new clsPmieducarEscolaSerie();
        $lst_obj = $tmp_obj->lista($this->ref_cod_escola, $this->ref_cod_serie);
        $registro = array_shift($lst_obj);
        if (!$registro) {
            header('Location: educar_escola_serie_lst.php');
            die;
        }
        $obj_ref_cod_instituicao = new clsPmieducarInstituicao($registro['ref_cod_instituicao']);
        $det_ref_cod_instituicao = $obj_ref_cod_instituicao->detalhe();
        $registro['ref_cod_instituicao'] = $det_ref_cod_instituicao['nm_instituicao'];
        $obj_ref_cod_escola = new clsPmieducarEscola($registro['ref_cod_escola']);
        $det_ref_cod_escola = $obj_ref_cod_escola->detalhe();
        $nm_escola = $det_ref_cod_escola['nome'];
        $obj_ref_cod_serie = new clsPmieducarSerie($registro['ref_cod_serie']);
        $det_ref_cod_serie = $obj_ref_cod_serie->detalhe();
        $nm_serie = $det_ref_cod_serie['nm_serie'];
        $obj_curso = new clsPmieducarCurso($registro['ref_cod_curso']);
        $det_curso = $obj_curso->detalhe();
        $registro['ref_cod_curso'] = $det_curso['nm_curso'];
        $obj_permissao = new clsPermissoes();
        $nivel_usuario = $obj_permissao->nivel_acesso($this->pessoa_logada);
        if ($nivel_usuario == 1) {
            if ($registro["ref_cod_instituicao"]) {
                $this->addDetalhe(array('Institui&ccedil;&atilde;o', $registro['ref_cod_instituicao']));
            }
        }
        if ($nivel_usuario == 1 || $nivel_usuario == 2) {
            if ($nm_escola) {
                $this->addDetalhe(array('Escola', $nm_escola));
            }
        }
        if ($registro['ref_cod_curso']) {
            $this->addDetalhe(array('Curso', $registro['ref_cod_curso']));
        }
        if ($nm_serie) {
            $this->addDetalhe(array('S&eacute;rie', $nm_serie));
        }
        if ($registro['hora_inicial']) {
            $registro['hora_inicial'] = date('H:i', strtotime($registro['hora_inicial']));
            $this->addDetalhe(array('Hora Inicial', $registro['hora_inicial']));
        }
        if ($registro['hora_final']) {
            $registro['hora_final'] = date('H:i', strtotime($registro['hora_final']));
            $this->addDetalhe(array('Hora Final', $registro['hora_final']));
        }
        if ($registro['hora_inicio_intervalo']) {
            $registro['hora_inicio_intervalo'] = date('H:i', strtotime($registro['hora_inicio_intervalo']));
            $this->addDetalhe(array('Hora In&iacute;cio Intervalo', $registro['hora_inicio_intervalo']));
        }
        if ($registro['hora_fim_intervalo']) {
            $registro['hora_fim_intervalo'] = date('H:i', strtotime($registro['hora_fim_intervalo']));
            $this->addDetalhe(array('Hora Fim Intervalo', $registro['hora_fim_intervalo']));
        }
        // Componentes da escola-série
        $componentes = array();
        try {
            $componentes = App_Model_IedFinder::getEscolaSerieDisciplina($this->ref_cod_serie, $this->ref_cod_escola);
        } catch (Exception $e) {
        }
        if (0 < count($componentes)) {
            $tabela = '
<table>
  <tr align="center">
    <td bgcolor="#A1B3BD"><b>Nome</b></td>
    <td bgcolor="#A1B3BD"><b>Carga horária</b></td>
  </tr>';
            $cont = 0;
            foreach ($componentes as $componente) {
                if ($cont % 2 == 0) {
                    $color = ' bgcolor="#E4E9ED" ';
                } else {
                    $color = ' bgcolor="#FFFFFF" ';
                }
                $tabela .= sprintf('
          <tr>
            <td %s align="left">%s</td>
            <td %s align="center">%.0f h</td>
          </tr>', $color, $componente, $color, $componente->cargaHoraria);
                $cont++;
            }
            $tabela .= '</table>';
        }
        if (isset($tabela)) {
            $this->addDetalhe(array('Componentes curriculares', $tabela));
        }
        if ($obj_permissao->permissao_cadastra(585, $this->pessoa_logada, 7)) {
            $this->url_novo = "educar_escola_serie_cad.php";
            $this->url_editar = "educar_escola_serie_cad.php?ref_cod_escola={$registro["ref_cod_escola"]}&ref_cod_serie={$registro["ref_cod_serie"]}";
        }
        $this->url_cancelar = "educar_escola_serie_lst.php";
        $this->largura = "100%";
    }
コード例 #4
0
 * @author    Prefeitura Municipal de Itajaí <*****@*****.**>
 * @category  i-Educar
 * @license   @@license@@
 * @package   iEd_Pmieducar
 * @since     Arquivo disponível desde a versão 1.0.0
 * @version   $Id$
 */
header('Content-type: text/xml; charset=ISO-8859-1');
require_once 'include/clsBanco.inc.php';
require_once 'include/funcoes.inc.php';
echo "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n<query xmlns=\"sugestoes\">\n";
$componentes = array();
// Seleciona os componentes de um curso ou série
if (is_numeric($_GET['cur']) || is_numeric($_GET['ser'])) {
    require_once 'ComponenteCurricular/Model/AnoEscolarDataMapper.php';
    $mapper = new ComponenteCurricular_Model_AnoEscolarDataMapper();
    if (is_numeric($_GET['cur'])) {
        $componentes = $mapper->findComponentePorCurso($_GET['cur']);
    } elseif (is_numeric($_GET['ser'])) {
        $componentes = $mapper->findComponentePorSerie($_GET['ser']);
    }
}
// Seleciona os componentes de uma escola-série
if (is_numeric($_GET['esc']) && is_numeric($_GET['ser'])) {
    require_once 'App/Model/IedFinder.php';
    $componentes = App_Model_IedFinder::getEscolaSerieDisciplina($_GET['ser'], $_GET['esc']);
}
foreach ($componentes as $componente) {
    print sprintf(' <disciplina cod_disciplina="%d" carga_horaria="%d">%s</disciplina>%s', $componente->id, $componente->cargaHoraria, $componente, PHP_EOL);
}
echo "</query>";
コード例 #5
0
 function renderHTML()
 {
     global $coreExt;
     if ($_POST) {
         foreach ($_POST as $key => $value) {
             $this->{$key} = $value;
         }
     }
     $this->temporario = isset($_POST['temporario']) ? TRUE : FALSE;
     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;
     }
     $modulo_sequencial = explode('-', $this->ref_cod_modulo);
     $this->ref_cod_modulo = $modulo_sequencial[0];
     $this->sequencial = $modulo_sequencial[1];
     if ($this->ref_cod_escola) {
         $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_calendario = new clsPmieducarEscolaAnoLetivo();
     $lista_calendario = $obj_calendario->lista($this->ref_cod_escola, $this->ano, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL);
     $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'];
     $regraId = $det_serie['regra_avaliacao_id'];
     $obj_pessoa = new clsPessoa_($det_turma['ref_cod_regente']);
     $det = $obj_pessoa->detalhe();
     $this->nm_professor = $det['nome'];
     if (!$lista_calendario) {
         echo '
     <script>
       alert("Escola não possui calendário definido para este ano");
       window.parent.fechaExpansivel(\'div_dinamico_\' + (window.parent.DOM_divs.length - 1));
     </script>';
         return TRUE;
     }
     $altura_linha = 23;
     $inicio_escrita_y = 175;
     $obj = new clsPmieducarSerie();
     $obj->setOrderby('cod_serie, etapa_curso');
     $lista_serie_curso = $obj->lista(NULL, NULL, NULL, $this->ref_cod_curso, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, $this->ref_cod_instituicao);
     $obj_curso = new clsPmieducarCurso($this->ref_cod_curso);
     $det_curso = $obj_curso->detalhe();
     // Seleciona a regra para verificar se a presença é geral
     $regraMapper = new RegraAvaliacao_Model_RegraDataMapper();
     $regra = $regraMapper->find($regraId);
     $presencaGeral = $regra->get('tipoPresenca') == RegraAvaliacao_Model_TipoPresenca::GERAL;
     // Seleciona o curso para ver se é padrão e decidir qual ano letivo pesquisar
     $db = new clsBanco();
     $consulta = sprintf('SELECT padrao_ano_escolar FROM pmieducar.curso WHERE cod_curso = \'%d\'', $this->ref_cod_curso);
     $padrao_ano_escolar = $db->CampoUnico($consulta);
     $total_semanas = 0;
     if ($padrao_ano_escolar) {
         // Seleciona o módulo do ano letivo da escola
         $data = $this->getDatasModulo($this->ref_cod_modulo, $this->sequencial, $this->ano, $this->ref_cod_escola);
     } else {
         // Seleciona o módulo do ano letivo da turma
         $data = $this->getDatasModulo($this->ref_cod_modulo, $this->sequencial, $this->ano, NULL, $this->ref_cod_turma);
     }
     $meses = $data['meses'];
     $dias = $data['dias'];
     if (!$this->data_ini) {
         $this->data_ini = $data['dataInicial'];
     }
     if (!$this->data_fim) {
         $this->data_fim = $data['dataFinal'];
     }
     $total_semanas = 0;
     for ($mes = $meses[0]; $mes <= $meses[1]; $mes++) {
         $mes_final = FALSE;
         if ($mes == $meses[0]) {
             $dia = $dias[0];
         } elseif ($mes == $meses[1]) {
             $dia = $dias[1];
             $mes_final = TRUE;
         } else {
             $dia = 1;
         }
         $total_semanas += $this->getNumeroDiasMes($this->ref_cod_turma, $dia, $mes, $this->ano, $mes_final);
         $total_semanas += $ndm;
     }
     $this->pdf = new clsPDF('Diário de Classe - ' . $this->ano, sprintf('Diário de Classe - %s até %s de %s', $this->data_ini, $this->data_fim, $this->ano), 'A4', '', FALSE, FALSE);
     $this->mes_inicial = (int) $meses[0];
     $this->mes_final = (int) $meses[1];
     $this->pdf->largura = 842.0;
     $this->pdf->altura = 595.0;
     $this->total = $total_semanas;
     if (!$this->em_branco) {
         $obj_matricula_turma = new clsPmieducarMatriculaTurma();
         $obj_matricula_turma->setOrderby('nome_ascii');
         $matriculaSituacao = array(App_Model_MatriculaSituacao::APROVADO, App_Model_MatriculaSituacao::REPROVADO, App_Model_MatriculaSituacao::EM_ANDAMENTO);
         $lista_matricula = $obj_matricula_turma->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, $matriculaSituacao, NULL, NULL, $this->ano, NULL, TRUE, NULL, NULL, TRUE);
     }
     if ($this->em_branco) {
         $lista_matricula = array();
         $this->numero_registros = $this->numero_registros ? $this->numero_registros : 20;
         for ($i = 0; $i < $this->numero_registros; $i++) {
             $lista_matricula[] = '';
         }
     }
     // Seleciona os componentes da escola/série
     $componentes = App_Model_IedFinder::getEscolaSerieDisciplina($this->ref_cod_serie, $this->ref_cod_escola);
     if (0 < count($componentes) && FALSE == $presencaGeral) {
         $this->total = $total_semanas = 0;
         foreach ($componentes as $componente) {
             $this->nm_disciplina = $componente->nome;
             $this->page_y = 125;
             if (FALSE == $presencaGeral) {
                 // Número de semanas dos meses
                 $obj_quadro = new clsPmieducarQuadroHorario();
                 $obj_quadro->setCamposLista('cod_quadro_horario');
                 $quadro_horario = $obj_quadro->lista(NULL, NULL, NULL, $this->ref_cod_turma, NULL, NULL, NULL, NULL, 1);
                 $total_semanas = 0;
                 $this->indefinido = FALSE;
                 if (!$quadro_horario) {
                     echo '
           <script>
             alert(\'Turma não possui quadro de horários\');
             window.parent.fechaExpansivel(\'div_dinamico_\'+(window.parent.DOM_divs.length-1));
           </script>';
                     die;
                 }
                 $obj_quadro_horarios = new clsPmieducarQuadroHorarioHorarios();
                 $obj_quadro_horarios->setCamposLista('dia_semana');
                 $obj_quadro_horarios->setOrderby('1 asc');
                 $lista_quadro_horarios = $obj_quadro_horarios->lista($quadro_horario[0], $this->ref_cod_serie, $this->ref_cod_escola, $componente->id, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1);
                 // Se não for retornado horário e o diário não for temporário, gera
                 // a lista para o próximo componente
                 if (FALSE == $lista_quadro_horarios && FALSE == $this->temporario) {
                     continue;
                 }
                 // Caso o diário seja temporário, gera lista de alunos para 30 dias
                 // por padrão
                 if (FALSE == $lista_quadro_horarios && TRUE == $this->temporario) {
                     $this->indefinido = TRUE;
                     $total_semanas = $coreExt['Config']->get($coreExt['Config']->report->diario_classe->dias_temporarios, 30);
                 }
                 for ($mes_ = $meses[0]; $mes_ <= $meses[1] && FALSE != $lista_quadro_horarios; $mes_++) {
                     $mes_final = FALSE;
                     foreach ($lista_quadro_horarios as $dia_semana) {
                         if ($mes_ == $meses[0]) {
                             $dia = $dias[0];
                         } elseif ($mes_ == $meses[1]) {
                             $dia = $dias[1];
                             $mes_final = TRUE;
                         } else {
                             $dia = 1;
                         }
                         $total_semanas += $this->getDiasSemanaMes($this->ref_cod_turma, $dia, $mes_, $this->ano, $dia_semana, $mes_final);
                     }
                 }
                 $this->total = $total_semanas;
             }
             if (!$this->total) {
                 continue;
             }
             $this->gerarListaAlunos($lista_matricula);
         }
     } else {
         $this->gerarListaAlunos($lista_matricula);
     }
     if ($this->total) {
         $this->pdf->CloseFile();
         $this->get_link = $this->pdf->GetLink();
     } else {
         $this->mensagem = 'Não existem dias letivos cadastrados para esta turma';
         return;
     }
     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);
 }
コード例 #6
0
 public function testGetEscolaSerieDisciplina()
 {
     $returnAnoEscolar = array(1 => new ComponenteCurricular_Model_Componente(array('id' => 1, 'nome' => 'Matemática', 'cargaHoraria' => 100)), 2 => new ComponenteCurricular_Model_Componente(array('id' => 2, 'nome' => 'Português', 'cargaHoraria' => 100)), 3 => new ComponenteCurricular_Model_Componente(array('id' => 3, 'nome' => 'Ciências', 'cargaHoraria' => 60)), 4 => new ComponenteCurricular_Model_Componente(array('id' => 4, 'nome' => 'Física', 'cargaHoraria' => 60)));
     $expected = $returnAnoEscolar;
     $anoEscolarMock = $this->getCleanMock('ComponenteCurricular_Model_ComponenteDataMapper');
     $anoEscolarMock->expects($this->exactly(4))->method('findComponenteCurricularAnoEscolar')->will($this->onConsecutiveCalls($returnAnoEscolar[1], $returnAnoEscolar[2], $returnAnoEscolar[3], $returnAnoEscolar[4]));
     // Retorna para clsPmieducarEscolaSerieDisciplina
     $returnEscolaSerieDisciplina = array(array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 1, 'carga_horaria' => 80), array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 2, 'carga_horaria' => NULL), array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 3, 'carga_horaria' => NULL), array('ref_cod_serie' => 1, 'ref_cod_disciplina' => 4, 'carga_horaria' => NULL));
     // Mock para clsPmieducarEscolaSerieDisciplina
     $escolaMock = $this->getCleanMock('clsPmieducarEscolaSerieDisciplina');
     $escolaMock->expects($this->any())->method('lista')->with(1, 1, NULL, 1)->will($this->returnValue($returnEscolaSerieDisciplina));
     App_Model_IedFinder::addClassToStorage('clsPmieducarEscolaSerieDisciplina', $escolaMock, NULL, TRUE);
     // O primeiro componente tem uma carga horária definida em escola-série.
     $expected[1] = clone $returnAnoEscolar[1];
     $expected[1]->cargaHoraria = 80;
     $componentes = App_Model_IedFinder::getEscolaSerieDisciplina(1, 1, $anoEscolarMock);
     $this->assertEquals($expected, $componentes, '::getEscolaSerieDisciplina() retorna os componentes de um escola-série.');
 }