From fa78499b246a429b7fd63d06237e798ed08ef29e Mon Sep 17 00:00:00 2001 From: Lucas D'Avila Date: Thu, 31 Jan 2013 20:40:01 -0200 Subject: [PATCH] Melhorado listagem, detalhe e implementado novo cadastro de alunos --- ieducar/intranet/educar_aluno_det.php | 308 ++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ieducar/intranet/educar_aluno_lst.php | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------------------------------------------------- ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js | 254 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css | 9 +++++++++ ieducar/modules/Cadastro/Views/AlunoController.php | 223 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 735 insertions(+), 348 deletions(-) create mode 100644 ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js create mode 100644 ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js create mode 100644 ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css create mode 100644 ieducar/modules/Cadastro/Views/AlunoController.php diff --git a/ieducar/intranet/educar_aluno_det.php b/ieducar/intranet/educar_aluno_det.php index c48f0f9..a3f09d2 100644 --- a/ieducar/intranet/educar_aluno_det.php +++ b/ieducar/intranet/educar_aluno_det.php @@ -37,6 +37,8 @@ require_once 'App/Model/ZonaLocalizacao.php'; require_once 'Educacenso/Model/AlunoDataMapper.php'; require_once 'Transporte/Model/AlunoDataMapper.php'; +require_once 'Portabilis/View/Helper/Application.php'; + /** * clsIndexBase class. * @@ -93,6 +95,11 @@ class indice extends clsDetalhe $this->pessoa_logada = $_SESSION['id_pessoa']; session_write_close(); + // Verificação de permissão para cadastro. + $this->obj_permissao = new clsPermissoes(); + + $this->nivel_usuario = $this->obj_permissao->nivel_acesso($this->pessoa_logada); + $this->titulo = 'Aluno - Detalhe'; $this->addBanner('imagens/nvp_top_intranet.jpg', 'imagens/nvp_vert_intranet.jpg', 'Intranet'); @@ -128,7 +135,7 @@ class indice extends clsDetalhe $det_raca = $obj_raca->detalhe(); } - $registro['nome_aluno'] = $det_pessoa_fj['nome']; + $registro['nome_aluno'] = strtoupper($det_pessoa_fj['nome']); $registro['cpf'] = int2IdFederal($det_fisica['cpf']); $registro['data_nasc'] = dataToBrasil($det_fisica['data_nasc']); $registro['sexo'] = $det_fisica['sexo'] == 'F' ? 'Feminino' : 'Masculino'; @@ -161,8 +168,8 @@ class indice extends clsDetalhe $this->idpes_pai = $det_fisica['idpes_pai']; $this->idpes_mae = $det_fisica['idpes_mae']; - $this->nm_pai = $detalhe_aluno['nm_pai']; - $this->nm_mae = $detalhe_aluno['nm_mae']; + $this->nm_pai = $registro['nm_pai']; + $this->nm_mae = $registro['nm_mae']; if ($this->idpes_pai) { $obj_pessoa_pai = new clsPessoaFj($this->idpes_pai); @@ -343,6 +350,31 @@ class indice extends clsDetalhe $this->addDetalhe(array('Código Aluno', $registro['cod_aluno'])); } + // código inep + + $alunoMapper = new Educacenso_Model_AlunoDataMapper(); + $alunoInep = NULL; + try { + $alunoInep = $alunoMapper->find(array('aluno' => $this->cod_aluno)); + $this->addDetalhe(array('Código inep', $alunoInep->alunoInep)); + } + catch(Exception $e) { + } + + // código estado + + $this->addDetalhe(array('Código estado', $registro['aluno_estado_id'])); + + if ($registro['caminho_foto']) { + $this->addDetalhe(array( + 'Foto', + sprintf( + '', + $registro['caminho_foto'] + ) + )); + } + if ($registro['nome_aluno']) { $this->addDetalhe(array('Nome Aluno', $registro['nome_aluno'])); } @@ -602,16 +634,6 @@ class indice extends clsDetalhe $this->addDetalhe(array('Seção', $registro['secao_tit_eleitor'])); } - if ($registro['caminho_foto']) { - $this->addDetalhe(array( - 'Foto', - sprintf( - '', - $registro['caminho_foto'] - ) - )); - } - // Transporte escolar. $transporteMapper = new Transporte_Model_AlunoDataMapper(); $transporteAluno = NULL; @@ -626,260 +648,34 @@ class indice extends clsDetalhe $this->addDetalhe(array('Responsável transporte', $transporteAluno->responsavel)); } - // Adiciona uma aba com dados do Inep/Educacenso caso aluno tenha código Inep. - if (isset($this->cod_aluno)) { - $alunoMapper = new Educacenso_Model_AlunoDataMapper(); - - $alunoInep = NULL; - try { - $alunoInep = $alunoMapper->find(array('aluno' => $this->cod_aluno)); - } - catch(Exception $e) { - } - - if ($alunoInep) { - $this->addDetalhe(array('Código do aluno no Educacenso/Inep', $alunoInep->alunoInep)); - - if (isset($alunoInep->nomeInep)) { - $this->addDetalhe(array('Nome do aluno no Educacenso/Inep', $alunoInep->nomeInep)); - } - } - } - - $this->addDetalhe(array('Matrícula', $this->montaTabelaMatricula())); - - // Verificação de permissão para cadastro. - $obj_permissao = new clsPermissoes(); - if ($obj_permissao->permissao_cadastra(578, $this->pessoa_logada, 7)) { - $this->url_novo = 'educar_aluno_cad.php'; - $this->url_editar = 'educar_aluno_cad.php?cod_aluno=' . $registro['cod_aluno']; + if ($this->obj_permissao->permissao_cadastra(578, $this->pessoa_logada, 7)) { + $this->url_novo = '/module/Cadastro/aluno'; + $this->url_editar = '/module/Cadastro/aluno?id=' . $registro['cod_aluno']; - $this->array_botao = array('Matrícula', 'Atualizar Histórico', 'Ficha do Aluno'); + $this->array_botao = array('Nova matrícula', 'Atualizar Histórico'); $this->array_botao_url_script = array( - sprintf('go("educar_matricula_lst.php?ref_cod_aluno=%d");', $registro['cod_aluno']), - sprintf('go("educar_historico_escolar_lst.php?ref_cod_aluno=%d");', $registro['cod_aluno']), - sprintf('showExpansivelImprimir(400, 200, "educar_relatorio_aluno_dados.php?ref_cod_aluno=%d", [], "Relatório i-Educar")', $registro['cod_aluno']) + sprintf('go("educar_matricula_cad.php?ref_cod_aluno=%d");', $registro['cod_aluno']), + sprintf('go("educar_historico_escolar_lst.php?ref_cod_aluno=%d");', $registro['cod_aluno']) ); } $this->url_cancelar = 'educar_aluno_lst.php'; $this->largura = '100%'; - } - - function montaTabelaMatricula() - { - $sql = sprintf('SELECT - cod_matricula - FROM - pmieducar.matricula - WHERE - ref_cod_aluno = %d - AND ativo = 1 - ORDER BY - cod_matricula DESC', $this->cod_aluno); - - $db = new clsBanco(); - $db->Consulta($sql); - - if ($db->Num_Linhas()) { - while ($db->ProximoRegistro()) { - list($ref_cod_matricula) = $db->Tupla(); - - if (is_numeric($ref_cod_matricula)) { - $obj_matricula = new clsPmieducarMatricula(); - $obj_matricula->setOrderby('ano ASC'); - $lst_matricula = $obj_matricula->lista($ref_cod_matricula); - - if ($lst_matricula) { - $registro = array_shift($lst_matricula); - } - - $table .= sprintf( - ' - - - ', - $registro['ano'] - ); - - $obj_ref_cod_curso = new clsPmieducarCurso($registro['ref_cod_curso']); - $det_ref_cod_curso = $obj_ref_cod_curso->detalhe(); - $nm_curso = $det_ref_cod_curso['nm_curso']; - $obj_serie = new clsPmieducarSerie($registro['ref_ref_cod_serie']); - $det_serie = $obj_serie->detalhe(); - $nm_serie = $det_serie['nm_serie']; + $this->addDetalhe(""); + $this->addDetalhe(""); - $obj_cod_instituicao = new clsPmieducarInstituicao($registro['ref_cod_instituicao']); - $obj_cod_instituicao_det = $obj_cod_instituicao->detalhe(); - $nm_instituicao = $obj_cod_instituicao_det['nm_instituicao']; - - $obj_ref_cod_escola = new clsPmieducarEscola($registro['ref_ref_cod_escola']); - $det_ref_cod_escola = $obj_ref_cod_escola->detalhe(); - $nm_escola = $det_ref_cod_escola['nome']; - - $obj_mat_turma = new clsPmieducarMatriculaTurma(); - $det_mat_turma = $obj_mat_turma->lista($ref_cod_matricula, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, 1); - - if ($det_mat_turma) { - $det_mat_turma = array_shift($det_mat_turma); - - $obj_turma = new clsPmieducarTurma($det_mat_turma['ref_cod_turma']); - $det_turma = $obj_turma->detalhe(); - $nm_turma = $det_turma['nm_turma']; - } - else { - $nm_turma = ''; - } - - $transferencias = array(); - - if ($registro['aprovado'] == 1) { - $aprovado = 'Aprovado'; - } - elseif ($registro['aprovado'] == 2) { - $aprovado = 'Reprovado'; - } - elseif ($registro['aprovado'] == 3) { - $aprovado = 'Em Andamento'; - } - elseif ($registro['aprovado'] == 4) { - if (is_numeric($registro['cod_matricula'])) { - $aprovado = 'Transferido'; - - $sql = sprintf('SELECT - ref_cod_matricula_entrada, - ref_cod_matricula_saida, - to_char(data_transferencia, \'DD/MM/YYYY\') AS dt_transferencia - FROM - pmieducar.transferencia_solicitacao - WHERE - (ref_cod_matricula_entrada = %d - OR ref_cod_matricula_saida = %d) - AND ativo = 1', - $registro['cod_matricula'], $registro['cod_matricula'] - ); - - $db2 = new clsBanco(); - $db2->Consulta($sql); - - if ($db2->Num_Linhas()) { - while ($db2->ProximoRegistro()) { - list($ref_cod_matricula_entrada, $ref_cod_matricula_saida, - $dt_transferencia) = $db2->Tupla(); - - if ($ref_cod_matricula_saida == $registro['cod_matricula']) { - $transferencias[] = array( - 'data_trans' => $dt_transferencia, - 'desc' => 'Data Transferência Saída' - ); - } - elseif ($ref_cod_matricula_entrada == $registro['cod_matricula']) { - $transferencias[] = array( - 'data_trans' => $dt_transferencia, - 'desc' => 'Data Transferência Admissão' - ); - } - } - } - } - } - elseif ($registro['aprovado'] == 5) { - $aprovado = 'Reclassificado'; - } - elseif ($registro['aprovado'] == 6) { - $aprovado = 'Abandono'; - } - elseif ($registro['aprovado'] == 7) { - $aprovado = 'Em Exame'; - } + // js - $formando = $registro['formando'] == 0 ? 'Não' : 'Sim'; + Portabilis_View_Helper_Application::loadJQueryLib($this); - $table .= sprintf( - '', - $registro['cod_matricula'] - ); - - $table .= sprintf( - '', - $nm_instituicao - ); - - $table .= sprintf( - '', - $nm_escola - ); - - $table .= sprintf( - '', - $nm_serie - ); - - $table .= sprintf( - '', - $nm_turma - ); - - $table .= sprintf( - '', - $aprovado - ); - - $class = 'formmdtd'; - - if (is_array($transferencias)) { - asort($transferencias); - - foreach ($transferencias as $trans) { - $table .= sprintf( - '', - $class, $trans['desc'], $trans['data_trans'] - ); - - $class = $class == 'formmdtd' ? 'formlttd' : 'formmdtd'; - } - } - - if ($registro['aprovado'] < 4) { - if (is_numeric($registro["cod_matricula"])) { - $sql = sprintf('SELECT - to_char(data_transferencia, \'DD/MM/YYYY\') - FROM - pmieducar.transferencia_solicitacao - WHERE - ref_cod_matricula_entrada = %d - AND ativo = 1', $registro['cod_matricula']); - - $db2 = new clsBanco(); - $data_transferencia = $db2->CampoUnico($sql); - - if ($data_transferencia) { - $table .= sprintf(' - - - - ', - $class, $data_transferencia); - - $class = $class == 'formmdtd' ? 'formlttd' : 'formmdtd'; - } - } - } - - $table .= sprintf('', - $class == 'formmdtd' ? 'formlttd' : 'formmdtd', $formando); - - $table .= '
Matrícula - Ano %d
Número da Matrícula%s
Instituição%s
Escola%s
Série%s
Turma%s
Situação%s
%s%s
Data Transferência Admissão%s
Formando%s
'; - } - } - } - else { - return 'O aluno não está matriculado em nenhuma escola'; - } + $scripts = array( + '/modules/Portabilis/Assets/Javascripts/Utils.js', + '/modules/Portabilis/Assets/Javascripts/ClientApi.js', + '/modules/Cadastro/Assets/Javascripts/AlunoShow.js' + ); - return $table; + Portabilis_View_Helper_Application::loadJavascript($this, $scripts); } } @@ -893,4 +689,4 @@ $miolo = new indice(); $pagina->addForm($miolo); // Gera o HTML -$pagina->MakeAll(); \ No newline at end of file +$pagina->MakeAll(); diff --git a/ieducar/intranet/educar_aluno_lst.php b/ieducar/intranet/educar_aluno_lst.php index b7e72e4..605ef50 100644 --- a/ieducar/intranet/educar_aluno_lst.php +++ b/ieducar/intranet/educar_aluno_lst.php @@ -24,10 +24,11 @@ * 02111-1307, USA. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -require_once ("include/clsBase.inc.php"); -require_once ("include/clsListagem.inc.php"); -require_once ("include/clsBanco.inc.php"); -require_once( "include/pmieducar/geral.inc.php" ); +require_once 'include/clsBase.inc.php'; +require_once 'include/clsListagem.inc.php'; +require_once 'include/clsBanco.inc.php'; +require_once 'include/pmieducar/geral.inc.php'; +require_once 'Educacenso/Model/AlunoDataMapper.php'; class clsIndexBase extends clsBase { @@ -85,11 +86,11 @@ class indice extends clsListagem var $inativado; var $nome_responsavel; var $cpf_responsavel; - + var $nome_pai; var $nome_mae; var $data_nascimento; - + function Gerar() { @session_start(); @@ -104,13 +105,12 @@ class indice extends clsListagem $this->addBanner( "imagens/nvp_top_intranet.jpg", "imagens/nvp_vert_intranet.jpg", "Intranet" ); $this->campoNumero("cod_aluno","Código Aluno",$this->cod_aluno,20,255,false); - $this->campoTexto("nome_aluno","Nome do aluno",$this->nome_aluno,50,255,false); -// if ($this->pessoa_logada == 184580) { - $this->campoData("data_nascimento", "Data de Nascimento", $this->data_nascimento); - $this->campoTexto("nome_pai", "Nome do Pai", $this->nome_pai, 50, 255); - $this->campoTexto("nome_mae", "Nome da Mãe", $this->nome_mae, 50, 255); - $this->campoTexto("nome_responsavel", "Nome do Responsável", $this->nome_responsavel, 50, 255); -// } + $this->campoNumero("cod_inep","Código INEP",$this->cod_inep,20,255,false); + $this->campoTexto("nome_aluno","Nome do aluno", $this->nome_aluno,50,255,false); + $this->campoData("data_nascimento", "Data de Nascimento", $this->data_nascimento); + $this->campoTexto("nome_pai", "Nome do Pai", $this->nome_pai, 50, 255); + $this->campoTexto("nome_mae", "Nome da Mãe", $this->nome_mae, 50, 255); + $this->campoTexto("nome_responsavel", "Nome do Responsável", $this->nome_responsavel, 50, 255); $obj_permissoes = new clsPermissoes(); $cod_escola = $obj_permissoes->getEscola( $this->pessoa_logada ); @@ -131,7 +131,9 @@ class indice extends clsListagem $this->addCabecalhos( array( "Código Aluno", + "Código INEP", "Nome do Aluno", + "Nome da Mãe", "Nome do Responsável", "CPF Responsável", ) ); @@ -141,85 +143,40 @@ class indice extends clsListagem $this->offset = ( $_GET["pagina_{$this->nome}"] ) ? $_GET["pagina_{$this->nome}"]*$this->limite-$this->limite: 0; $obj_aluno = new clsPmieducarAluno(); -// $obj_aluno->setOrderby( "cod_aluno DESC" ); $obj_aluno->setLimite( $this->limite, $this->offset ); - /*$lista = $obj_aluno->lista( - $this->cod_aluno, - null, - null, - null, - null, - null, - null, - null, - null, - null, - 1, - null, - $this->nome_aluno, - $this->nome_responsavel, - idFederal2int($this->cpf_responsavel), - null, - $this->nome_pai, - $this->nome_mae, - $ref_cod_escola - );*/ -// if ($this->pessoa_logada == 184580) { - $lista = $obj_aluno->lista2( - $this->cod_aluno, - null, - null, - null, - null, - null, - null, - null, - null, - null, - 1, - null, - $this->nome_aluno, - null, - idFederal2int($this->cpf_responsavel), - null, - null, - null, - $ref_cod_escola, - null, - $this->data_nascimento, - $this->nome_pai, - $this->nome_mae, - $this->nome_responsavel - ); - /*} else { - $lista = $obj_aluno->lista( - $this->cod_aluno, - null, - null, - null, - null, - null, - null, - null, - null, - null, - 1, - null, - $this->nome_aluno, - null, - idFederal2int($this->cpf_responsavel), - null, - null, - null, - $ref_cod_escola - ); - }*/ - + $lista = $obj_aluno->lista2( + $this->cod_aluno, + null, + null, + null, + null, + null, + null, + null, + null, + null, + 1, + null, + $this->nome_aluno, + null, + idFederal2int($this->cpf_responsavel), + null, + null, + null, + $ref_cod_escola, + null, + $this->data_nascimento, + $this->nome_pai, + $this->nome_mae, + $this->nome_responsavel, + $this->cod_inep + ); + $total = $obj_aluno->_total; // monta a lista - if( is_array( $lista ) && count( $lista ) ) + if( is_array( $lista ) && count( $lista ) ) { foreach ( $lista AS $registro ) { @@ -304,27 +261,47 @@ class indice extends clsListagem } } + $inepMapper = new Educacenso_Model_AlunoDataMapper(); + $alunoInep = NULL; + + try { + $alunoInep = $inepMapper->find(array('cod_aluno' => $registro["cod_aluno"])); + } + catch(Exception $e) { + } + + if (empty($alunoInep->alunoInep)){ + $registro['cod_inep'] = '-'; + } else { + $registro['cod_inep'] = $alunoInep->alunoInep; + } + + $registro["nome_aluno"] = strtoupper($registro["nome_aluno"]); + $registro["nm_mae"] = strtoupper($registro["nm_mae"]); + $registro["nome_responsavel"] = strtoupper($registro["nome_responsavel"]); $this->addLinhas( array( "{$registro["cod_aluno"]}", + "{$registro["cod_inep"]}", "{$registro["nome_aluno"]}", + "{$registro["nm_mae"]}", "{$registro["nome_responsavel"]}", "{$registro["cpf_responsavel"]}" ) ); } } - + $this->addPaginador2( "educar_aluno_lst.php", $total, $_GET, $this->nome, $this->limite ); //** Verificacao de permissao para cadastro if($obj_permissoes->permissao_cadastra(578, $this->pessoa_logada,7)) { - $this->acao = "go(\"educar_aluno_cad.php\")"; + $this->acao = "go(\"/module/Cadastro/aluno\")"; $this->nome_acao = "Novo"; - $this->array_botao = array("Ficha do Aluno (em branco)"); - $this->array_botao_script = array( "showExpansivelImprimir(400, 200, \"educar_relatorio_aluno_dados.php\",\"\", \"Relatório i-Educar\" )" ); + /*$this->array_botao = array("Ficha do Aluno (em branco)"); + $this->array_botao_script = array( "showExpansivelImprimir(400, 200, \"educar_relatorio_aluno_dados.php\",\"\", \"Relatório i-Educar\" )" );*/ } //** $this->largura = "100%"; @@ -338,4 +315,4 @@ $miolo = new indice(); $pagina->addForm( $miolo ); // gera o html $pagina->MakeAll(); -?> \ No newline at end of file +?> diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js b/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js new file mode 100644 index 0000000..01a132e --- /dev/null +++ b/ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js @@ -0,0 +1,254 @@ +// before page is ready + +var $idField = $j('#id'); +var $nomeField = $j('#pessoa_nome'); + +var $resourceNotice = $j('').html('') + .addClass('error resource-notice') + .hide() + .width($nomeField.outerWidth() - 12) + .insertBefore($idField.parent()); + +var $pessoaNotice = $resourceNotice.clone() + .appendTo($nomeField.parent()); + +// ajax + +resourceOptions.handlePost = function(dataResponse) { + $nomeField.attr('disabled', 'disabled'); + $j('.pessoa-links .cadastrar-pessoa').hide(); + + if (! dataResponse.any_error_msg) + window.setTimeout(function() { document.location = '/intranet/educar_aluno_det.php?cod_aluno=' + resource.id(); }, 500); +} + +resourceOptions.handlePut = function(dataResponse) { + if (! dataResponse.any_error_msg) + window.setTimeout(function() { document.location = '/intranet/educar_aluno_det.php?cod_aluno=' + resource.id(); }, 500); +} + +resourceOptions.handleGet = function(dataResponse) { + handleMessages(dataResponse.msgs); + $resourceNotice.hide(); + + if (dataResponse.id && ! dataResponse.ativo) { + $submitButton.attr('disabled', 'disabled').hide(); + $deleteButton.attr('disabled', 'disabled').hide(); + + var msg = "Este cadastro foi desativado em "+ dataResponse.destroyed_at + + "
pelo usuário " + dataResponse.destroyed_by + ", "; + + $resourceNotice.html(stringUtils.toUtf8(msg)).slideDown('fast'); + + $j('').addClass('decorated') + .attr('href', '#') + .click(resourceOptions.enable) + .html('reativar cadastro.') + .appendTo($resourceNotice); + } + else + $deleteButton.removeAttr('disabled').show(); + + if (dataResponse.pessoa_id) + getPersonDetails(dataResponse.pessoa_id); + + $idField.val(dataResponse.id); + $j('#aluno_inep_id').val(dataResponse.aluno_inep_id); + $j('#aluno_estado_id').val(dataResponse.aluno_estado_id); + $j('#tipo_responsavel').val(dataResponse.tipo_responsavel).change(); + $j('#religiao_id').val(dataResponse.religiao_id); + $j('#beneficio_id').val(dataResponse.beneficio_id); + $j('#tipo_transporte').val(dataResponse.tipo_transporte); + $j('#alfabetizado').attr('checked', dataResponse.alfabetizado); +}; + +var handleGetPersonDetails = function(dataResponse) { + handleMessages(dataResponse.msgs); + $pessoaNotice.hide(); + + var alunoId = dataResponse.aluno_id; + + if (alunoId && alunoId != resource.id()) { + $submitButton.attr('disabled', 'disabled').hide(); + + $pessoaNotice.html(stringUtils.toUtf8('Esta pessoa já possui o aluno código '+ alunoId +' cadastrado, ' )) + .slideDown('fast'); + + $j('').addClass('decorated') + .attr('href', resource.url(alunoId)) + .attr('target', '_blank') + .html('acessar cadastro.') + .appendTo($pessoaNotice); + } + + else { + $j('.pessoa-links .editar-pessoa').attr('href', '/intranet/atendidos_cad.php?cod_pessoa_fj=' + dataResponse.id) + .show(); + + $submitButton.removeAttr('disabled').show(); + } + + $j('#pessoa_id').val(dataResponse.id); + $nomeField.val(dataResponse.id + ' - ' + dataResponse.nome); + + var nomePai = dataResponse.nome_pai; + var nomeMae = dataResponse.nome_mae; + var nomeResponsavel = dataResponse.nome_responsavel; + + if (dataResponse.pai_id) + nomePai = dataResponse.pai_id + ' - ' + nomePai; + + if (dataResponse.mae_id) + nomeMae = dataResponse.mae_id + ' - ' + nomeMae; + + if (dataResponse.responsavel_id) + nomeResponsavel = dataResponse.responsavel_id + ' - ' + nomeResponsavel; + + //$j('#rg').val(dataResponse.rg); + //$j('#cpf').val(dataResponse.cpf); + + $j('#pai').val(nomePai); + $j('#mae').val(nomeMae); + $j('#responsavel_nome').val(nomeResponsavel); + $j('#responsavel_id').val(dataResponse.responsavel_id); + + // deficiencias + + $deficiencias = $j('#deficiencias'); + + $j.each(dataResponse.deficiencias, function(id, nome) { + $deficiencias.children("[value=" + id + "]").attr('selected', ''); + }); + + $deficiencias.trigger('liszt:updated'); + + // # TODO show aluno photo + //$j('#aluno_foto').val(dataResponse.url_foto); +} + +var getPersonDetails = function(personId) { + var additionalVars = { + id : personId + }; + + var options = { + url : getResourceUrlBuilder.buildUrl('/module/Api/pessoa', 'pessoa', additionalVars), + dataType : 'json', + data : {}, + success : handleGetPersonDetails + }; + + getResource(options); +} + +var updatePersonDetails = function() { + if ($j('#pessoa_nome').val() && $j('#pessoa_id').val()) + getPersonDetails($j('#pessoa_id').val()); + else + clearPersonDetails(); +} + +var clearPersonDetails = function() { + $j('#pessoa_id').val(''); + $j('#pai').val(''); + $j('#mae').val(''); + $j('.pessoa-links .editar-pessoa').hide(); +} + +// simple search options + +var simpleSearchPessoaOptions = { + autocompleteOptions : { close : updatePersonDetails /*, change : updatePersonDetails*/ } +}; + + +// children callbacks + +function afterChangePessoa(targetWindow, pessoaId) { + targetWindow.close(); + + // timeout para usuario perceber mudança + window.setTimeout(function() { + messageUtils.success('Pessoa alterada com sucesso', $nomeField); + + $j('#pessoa_id').val(pessoaId); + getPersonDetails(pessoaId); + + window.setTimeout(function() { $nomeField.removeClass('success'); }, 10000); + $nomeField.focus(); + + }, 500); +} + + +// when page is ready + +(function($) { + $(document).ready(function() { + + // pessoa + + var $pessoaActionBar = $j('').html('') + .addClass('pessoa-links') + .width($nomeField.outerWidth() - 12) + .appendTo($nomeField.parent()); + + $j('').hide() + .addClass('cadastrar-pessoa decorated') + .attr('href', '/intranet/atendidos_cad.php') + .attr('target', '_blank') + .html('Cadastrar pessoa') + .appendTo($pessoaActionBar); + + $j('').hide() + .addClass('editar-pessoa decorated') + .attr('href', '#') + .attr('target', '_blank') + .html('Editar pessoa') + .appendTo($pessoaActionBar); + + if (resource.isNew()) { + $nomeField.focus(); + $j('.pessoa-links .cadastrar-pessoa').show(); + } + else + $nomeField.attr('disabled', 'disabled'); + + // responsavel + + var checkTipoResponsavel = function(){ + if ($j('#tipo_responsavel').val() == 'outra_pessoa') + $j('#responsavel_nome').show(); + else + $j('#responsavel_nome').hide(); + } + + checkTipoResponsavel(); + $j('#tipo_responsavel').change(checkTipoResponsavel); + + + // back to old version + + var backToOldVersion = function() { + var $this = $j(this); + var url = '/intranet/educar_aluno_cad.php'; + + if(resource.id()) + url += '?cod_aluno=' + resource.id(); + + $this.attr('href', url); + } + + $j('

').addClass('back-to-old-version right-top-notice notice') + .html(stringUtils.toUtf8('Você está acessando o novo cadastro de alunos,
')) + .appendTo($j('#id').closest('td')); + + $j('
').attr('href', '#') + .attr('target', '_blank') + .click(backToOldVersion) + .addClass('decorated') + .html(stringUtils.toUtf8('acessar versão antiga.')) + .appendTo($j('.back-to-old-version')); + + }); // ready +})(jQuery); \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js b/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js new file mode 100644 index 0000000..aacb5ee --- /dev/null +++ b/ieducar/modules/Cadastro/Assets/Javascripts/AlunoShow.js @@ -0,0 +1,128 @@ +function fixupTabelaMatriculas() { + var $parentTd = $j('.botaolistagem[value=" Voltar "]').closest('tr').next().children().first(); + $parentTd.empty().removeAttr('bgcolor').removeAttr('style'); + + $j('

').html(stringUtils.toUtf8('Matrículas:')).appendTo($parentTd); + + var $table = $j('').attr('id', 'matriculas').addClass('styled horizontal-expand').hide(); + var $tr = $j(''); + + $j(''); + + if (matricula.user_can_access) { + var linkToMatricula = $j('').attr('href', 'educar_matricula_det.php?cod_matricula=' + matricula.id) + .html('Visualizar') + .addClass('decorated'); + + } + else + var linkToMatricula = ''; + + $j('
').html('').appendTo($tr); + $j('').html('Ano').appendTo($tr); + $j('').html(stringUtils.toUtf8('Situação')).appendTo($tr); + $j('').html('Turma').appendTo($tr); + $j('').html(stringUtils.toUtf8('Série')).appendTo($tr); + $j('').html('Curso').appendTo($tr); + $j('').html('Escola').appendTo($tr); + $j('').html('Entrada').appendTo($tr); + $j('').html(stringUtils.toUtf8('Saída')).appendTo($tr); + + $tr.appendTo($table); + $table.appendTo($parentTd); +} + +fixupTabelaMatriculas(); + + +// api client + +var handleGetMatriculas = function(dataResponse) { + try{ + handleMessages(dataResponse.msgs); + + var $matriculasTable = $j('#matriculas'); + var transferenciaEmAberto = false; + + $j.each(dataResponse.matriculas, function(index, matricula) { + var $tr = $j('
').html(linkToMatricula).appendTo($tr).addClass('center'); + $j('').html(matricula.ano).appendTo($tr); + $j('').html(matricula.situacao).appendTo($tr); + $j('').html(matricula.turma_nome).appendTo($tr); + $j('').html(matricula.serie_nome).appendTo($tr); + $j('').html(matricula.curso_nome).appendTo($tr); + $j('').html(matricula.escola_nome).appendTo($tr); + $j('').html(matricula.data_entrada).appendTo($tr); + $j('').html(matricula.data_saida).appendTo($tr); + + if (matricula.transferencia_em_aberto) { + transferenciaEmAberto = true; + $tr.addClass('notice'); + } + + $tr.appendTo($matriculasTable); + }); + + + if(dataResponse.matriculas.length < 1) { + var $p = $j('

').html(stringUtils.toUtf8('Aluno sem matrículas, ')).addClass('notice simple-block'); + + $j('').attr('href', 'educar_matricula_cad.php?ref_cod_aluno=' + $j('#aluno_id').val()) + .html('matricular aluno.') + .addClass('decorated') + .appendTo($p); + + $p.appendTo($matriculasTable.parent()); + } + else if (transferenciaEmAberto) { + var $p = $j('

').html(stringUtils.toUtf8('* Matrícula com solicitação de transferência interna em aberto, ')) + .addClass('notice simple-block'); + + $j('').attr('href', 'educar_matricula_cad.php?ref_cod_aluno=' + $j('#aluno_id').val()) + .html('matricular aluno.') + .addClass('decorated') + .appendTo($p); + + $p.appendTo($matriculasTable.parent()); + } + + $matriculasTable.fadeIn('slow'); + $j('body').animate({scrollTop: $j('#matriculas').offset().top }, 900); + + $matriculasTable.find('tr:even').addClass('even'); + } + catch(error) { + alert('Erro ao carregar matriculas, detalhes:\n\n' + error); + + safeLog('Error details:'); + safeLog(error); + + safeLog('dataResponse details:'); + safeLog(dataResponse); + + throw error; + } +} + +var getMatriculas = function() { + var data = { + aluno_id : $j('#aluno_id').val() + }; + + var options = { + url : getResourceUrlBuilder.buildUrl('/module/Api/aluno', 'matriculas'), + dataType : 'json', + data : data, + success : handleGetMatriculas + }; + + getResource(options); +} + +// when page is ready + +$j(document).ready(function() { + + getMatriculas(); + +}); // ready \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css b/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css new file mode 100644 index 0000000..2892d9c --- /dev/null +++ b/ieducar/modules/Cadastro/Assets/Stylesheets/Aluno.css @@ -0,0 +1,9 @@ +.pessoa-links { + display: block; + padding: 5px; + margin: 2px; +} + +.pessoa-links a { + margin-right: 5px; +} \ No newline at end of file diff --git a/ieducar/modules/Cadastro/Views/AlunoController.php b/ieducar/modules/Cadastro/Views/AlunoController.php new file mode 100644 index 0000000..3769508 --- /dev/null +++ b/ieducar/modules/Cadastro/Views/AlunoController.php @@ -0,0 +1,223 @@ + + * + * Este programa é software livre; você pode redistribuí-lo e/ou modificá-lo + * sob os termos da Licença Pública Geral GNU conforme publicada pela Free + * Software Foundation; tanto a versão 2 da Licença, como (a seu critério) + * qualquer versão posterior. + * + * Este programa é distribuí­do na expectativa de que seja útil, porém, SEM + * NENHUMA GARANTIA; nem mesmo a garantia implí­cita de COMERCIABILIDADE OU + * ADEQUAÇÃO A UMA FINALIDADE ESPECÃFICA. Consulte a Licença Pública Geral + * do GNU para mais detalhes. + * + * Você deve ter recebido uma cópia da Licença Pública Geral do GNU junto + * com este programa; se não, escreva para a Free Software Foundation, Inc., no + * endereço 59 Temple Street, Suite 330, Boston, MA 02111-1307 USA. + * + * @author Lucas D'Avila + * @category i-Educar + * @license @@license@@ + * @package Avaliacao + * @subpackage Modules + * @since Arquivo disponível desde a versão ? + * @version $Id$ + */ + +require_once 'lib/Portabilis/Controller/Page/EditController.php'; +require_once 'Usuario/Model/FuncionarioDataMapper.php'; + +class AlunoController extends Portabilis_Controller_Page_EditController +{ + protected $_dataMapper = 'Usuario_Model_FuncionarioDataMapper'; + protected $_titulo = 'Cadastro de aluno'; + + protected $_nivelAcessoOption = App_Model_NivelAcesso::SOMENTE_ESCOLA; + protected $_processoAp = 578; + protected $_deleteOption = true; + + protected $_formMap = array( + 'pessoa' => array( + 'label' => 'Pessoa', + 'help' => '', + ), + + 'rg' => array( + 'label' => 'Documento de identidade (rg)', + 'help' => '', + ), + + 'cpf' => array( + 'label' => 'CPF', + 'help' => '', + ), + + 'pai' => array( + 'label' => 'Pai', + 'help' => '', + ), + + 'mae' => array( + 'label' => 'Mãe', + 'help' => '', + ), + + 'responsavel' => array( + 'label' => 'Responsável', + 'help' => '', + ), + + 'alfabetizado' => array( + 'label' => 'Alfabetizado', + 'help' => '', + ), + + 'transporte' => array( + 'label' => 'Transporte público', + 'help' => '', + ), + + 'id' => array( + 'label' => 'Código aluno', + 'help' => '', + ), + + 'aluno_inep_id' => array( + 'label' => 'Código inep', + 'help' => '', + ), + + 'aluno_estado_id' => array( + 'label' => 'Código rede estadual', + 'help' => '', + ), + + 'deficiencias' => array( + 'label' => 'Deficiências / habilidades especiais', + 'help' => '', + ) + ); + + + protected function _preConstruct() + { + } + + + protected function _initNovo() { + return false; + } + + + protected function _initEditar() { + return false; + } + + + public function Gerar() + { + $this->url_cancelar = '/intranet/educar_aluno_lst.php'; + + // código rede de ensino municipal + $options = array('label' => $this->_getLabel('id'), 'disabled' => true, + 'required' => false, 'size' => 25); + $this->inputsHelper()->text('id', $options); + + + // código aluno inep + $options = array('label' => $this->_getLabel('aluno_inep_id'), 'required' => false, 'size' => 25); + $this->inputsHelper()->text('aluno_inep_id', $options); + + // código aluno rede estadual + $options = array('label' => $this->_getLabel('aluno_estado_id'), 'required' => false, 'size' => 25); + $this->inputsHelper()->text('aluno_estado_id', $options); + + // nome + $options = array('label' => $this->_getLabel('pessoa'), 'size' => 68); + $this->inputsHelper()->simpleSearchPessoa('nome', $options); + + // rg + //$options = array('label' => $this->_getLabel('rg'), 'disabled' => true, 'required' => false); + //$this->inputsHelper()->text('aluno', 'rg', $options); + + // cpf + //$options = array('label' => $this->_getLabel('cpf'), 'disabled' => true, 'required' => false); + //$this->inputsHelper()->text('aluno', 'cpf', $options); + + // pai + $options = array('label' => $this->_getLabel('pai'), 'disabled' => true, 'required' => false, 'size' => 68); + $this->inputsHelper()->text('pai', $options); + + + // mãe + $options = array('label' => $this->_getLabel('mae'), 'disabled' => true, 'required' => false, 'size' => 68); + $this->inputsHelper()->text('mae', $options); + + + // responsável + + // tipo + $tiposResponsavel = array(null => 'Selecione', + 'pai' => 'Pai', + 'mae' => 'Mãe', + 'outra_pessoa' => 'Outra pessoa'); + + $options = array('label' => $this->_getLabel('responsavel'), + 'resources' => $tiposResponsavel, + 'required' => true, + 'inline' => true); + + $this->inputsHelper()->select('tipo_responsavel', $options); + + + // nome + $helperOptions = array('objectName' => 'responsavel'); + $options = array('label' => '', 'size' => 50, 'required' => true); + + $this->inputsHelper()->simpleSearchPessoa('nome', $options, $helperOptions); + + + // transporte publico + $tiposTransporte = array(null => 'Selecione', + 'nenhum' => 'Não utiliza', + 'municipal' => 'Municipal', + 'estadual' => 'Estadual'); + + $options = array('label' => $this->_getLabel('transporte'), + 'resources' => $tiposTransporte, + 'required' => true); + + $this->inputsHelper()->select('tipo_transporte', $options); + + + // religião + $this->inputsHelper()->religiao(array('required' => false)); + + // beneficio + $this->inputsHelper()->beneficio(array('required' => false)); + + + // Deficiências / habilidades especiais + $helperOptions = array('objectName' => 'deficiencias'); + $options = array('label' => $this->_getLabel('deficiencias'), 'size' => 50, 'required' => false, + 'options' => array('value' => null)); + + $this->inputsHelper()->multipleSearchDeficiencias('', $options, $helperOptions); + + + // alfabetizado + $options = array('label' => $this->_getLabel('alfabetizado'), 'value' => 'checked'); + $this->inputsHelper()->checkbox('alfabetizado', $options); + + + $this->loadResourceAssets($this->getDispatcher()); + } +} +?> \ No newline at end of file -- libgit2 0.21.2