Commit 65ae5dd8f42b46e7e59285456b41d3f7afbffeb1
Committed by
GitHub
Exists in
2.9
and in
7 other branches
Merge pull request #6298 from portabilis/issue-6176
Ajusta mascara do código RA
Showing
3 changed files
with
14 additions
and
5 deletions
Show diff stats
ieducar/intranet/include/clsCampos.inc.php
ieducar/modules/Api/Views/AlunoController.php
... | ... | @@ -579,10 +579,19 @@ class AlunoController extends ApiCoreController |
579 | 579 | $aluno = new clsPmieducarAluno(); |
580 | 580 | $aluno->cod_aluno = $id; |
581 | 581 | |
582 | - $alunoEstadoId = strtoupper(Portabilis_String_Utils::toLatin1($this->getRequest()->aluno_estado_id)); | |
582 | + $alunoEstadoId = strtoupper($this->getRequest()->aluno_estado_id); | |
583 | 583 | $alunoEstadoId = str_replace('.', '', $alunoEstadoId); |
584 | 584 | $alunoEstadoId = str_replace('-', '', $alunoEstadoId); |
585 | - $alunoEstadoId = preg_replace('"(.{3})(.{3})(.{3})(.{1})"', '\\1.\\2.\\3-\\4', $alunoEstadoId); | |
585 | + | |
586 | + if (strlen($alunoEstadoId) < 10) { | |
587 | + $mask['pattern'] = '"(.{3})(.{3})(.{3})"'; | |
588 | + $mask['replacement'] = '\\1.\\2.\\3'; | |
589 | + } else { | |
590 | + $mask['pattern'] = '"(.{3})(.{3})(.{3})(.{1})"'; | |
591 | + $mask['replacement'] = '\\1.\\2.\\3-\\4'; | |
592 | + } | |
593 | + | |
594 | + $alunoEstadoId = preg_replace($mask['pattern'], $mask['replacement'], $alunoEstadoId); | |
586 | 595 | $aluno->aluno_estado_id = $alunoEstadoId; |
587 | 596 | |
588 | 597 | $aluno->codigo_sistema = Portabilis_String_Utils::toLatin1($this->getRequest()->codigo_sistema); | ... | ... |
ieducar/modules/Cadastro/Assets/Javascripts/Aluno.js
... | ... | @@ -220,8 +220,8 @@ var newSubmitForm = function (event) { |
220 | 220 | } |
221 | 221 | |
222 | 222 | // Valida se o tamanho do campo aluno_estado_id é igual à 13 |
223 | - if ($j('#aluno_estado_id').val() !== '' && $j('#aluno_estado_id').val().length !== 13) { | |
224 | - messageUtils.error('O campo Código rede estadual (RA) deve conter exatos 13 dígitos.'); | |
223 | + if ($j('#aluno_estado_id').val() !== '' && ! (($j('#aluno_estado_id').val().length === 13) || ($j('#aluno_estado_id').val().length === 11))) { | |
224 | + messageUtils.error('O campo Código rede estadual (RA) deve conter exatos 13 ou 11 dígitos.'); | |
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | ... | ... |