Commit 65ae5dd8f42b46e7e59285456b41d3f7afbffeb1

Authored by Matheus Nicoski
Committed by GitHub
2 parents d7c57e88 c38e8f05
Exists in 2.9 and in 7 other branches 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8

Merge pull request #6298 from portabilis/issue-6176

Ajusta mascara do código RA
ieducar/intranet/include/clsCampos.inc.php
@@ -428,7 +428,7 @@ class clsCampos extends Core_Controller_Page_Abstract @@ -428,7 +428,7 @@ class clsCampos extends Core_Controller_Page_Abstract
428 $valor, 428 $valor,
429 13, 429 13,
430 13, 430 13,
431 - 'nnn.nnn.nnn-n', 431 + 'nnn.nnn.nnn-n ou nnn.nnn.nnn',
432 $descricao, 432 $descricao,
433 $disabled 433 $disabled
434 ]; 434 ];
ieducar/modules/Api/Views/AlunoController.php
@@ -579,10 +579,19 @@ class AlunoController extends ApiCoreController @@ -579,10 +579,19 @@ class AlunoController extends ApiCoreController
579 $aluno = new clsPmieducarAluno(); 579 $aluno = new clsPmieducarAluno();
580 $aluno->cod_aluno = $id; 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 $alunoEstadoId = str_replace('.', '', $alunoEstadoId); 583 $alunoEstadoId = str_replace('.', '', $alunoEstadoId);
584 $alunoEstadoId = str_replace('-', '', $alunoEstadoId); 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 $aluno->aluno_estado_id = $alunoEstadoId; 595 $aluno->aluno_estado_id = $alunoEstadoId;
587 596
588 $aluno->codigo_sistema = Portabilis_String_Utils::toLatin1($this->getRequest()->codigo_sistema); 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,8 +220,8 @@ var newSubmitForm = function (event) {
220 } 220 }
221 221
222 // Valida se o tamanho do campo aluno_estado_id é igual à 13 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 return false; 225 return false;
226 } 226 }
227 227