Commit 1c037ff0e9847fe740fd861732458d2bac577858
1 parent
8add19a0
Exists in
master
#27 Alterando componentes do formulário para validar somente números, evitando erros de banco
Showing
2 changed files
with
66 additions
and
31 deletions
Show diff stats
ieducar/intranet/empresas_cad.php
@@ -243,14 +243,11 @@ class indice extends clsCadastro | @@ -243,14 +243,11 @@ class indice extends clsCadastro | ||
243 | 243 | ||
244 | // Telefones | 244 | // Telefones |
245 | 245 | ||
246 | - $this->campoTexto( "ddd_telefone_1", "DDD Telefone 1", $this->ddd_telefone_1, "3", "2", false ); | ||
247 | - $this->campoTexto( "telefone_1", "Telefone 1", $this->telefone_1, "10", "15", false ); | ||
248 | - $this->campoTexto( "ddd_telefone_2", "DDD Telefone 2", $this->ddd_telefone_2, "3", "2", false ); | ||
249 | - $this->campoTexto( "telefone_2", "Telefone", $this->telefone_2, "10", "15", false ); | ||
250 | - $this->campoTexto( "ddd_telefone_mov", "DDD Celular", $this->ddd_telefone_mov, "3", "2", false ); | ||
251 | - $this->campoTexto( "telefone_mov", "Celular", $this->telefone_mov, "10", "15", false ); | ||
252 | - $this->campoTexto( "ddd_telefone_fax", "DDD Fax", $this->ddd_telefone_fax, "3", "2", false ); | ||
253 | - $this->campoTexto( "telefone_fax", "Fax", $this->telefone_fax, "10", "15", false ); | 246 | + |
247 | + $this->inputTelefone('1', 'Telefone 1'); | ||
248 | + $this->inputTelefone('2', 'Telefone 2'); | ||
249 | + $this->inputTelefone('mov', 'Celular'); | ||
250 | + $this->inputTelefone('fax', 'Fax'); | ||
254 | 251 | ||
255 | // Dados da Empresa | 252 | // Dados da Empresa |
256 | 253 | ||
@@ -437,6 +434,31 @@ class indice extends clsCadastro | @@ -437,6 +434,31 @@ class indice extends clsCadastro | ||
437 | return true; | 434 | return true; |
438 | } | 435 | } |
439 | 436 | ||
437 | + protected function inputTelefone($type, $typeLabel = '') { | ||
438 | + if (! $typeLabel) | ||
439 | + $typeLabel = "Telefone {$type}"; | ||
440 | + // ddd | ||
441 | + $options = array( | ||
442 | + 'required' => false, | ||
443 | + 'label' => "(ddd) / {$typeLabel}", | ||
444 | + 'placeholder' => 'ddd', | ||
445 | + 'value' => $this->{"ddd_telefone_{$type}"}, | ||
446 | + 'max_length' => 3, | ||
447 | + 'size' => 3, | ||
448 | + 'inline' => true | ||
449 | + ); | ||
450 | + $this->inputsHelper()->integer("ddd_telefone_{$type}", $options); | ||
451 | + // telefone | ||
452 | + $options = array( | ||
453 | + 'required' => false, | ||
454 | + 'label' => '', | ||
455 | + 'placeholder' => $typeLabel, | ||
456 | + 'value' => $this->{"telefone_{$type}"}, | ||
457 | + 'max_length' => 11 | ||
458 | + ); | ||
459 | + $this->inputsHelper()->integer("telefone_{$type}", $options); | ||
460 | + } | ||
461 | + | ||
440 | } | 462 | } |
441 | 463 | ||
442 | 464 |
ieducar/intranet/meusdados.php
@@ -276,29 +276,10 @@ class indice extends clsCadastro | @@ -276,29 +276,10 @@ class indice extends clsCadastro | ||
276 | $this->campoTexto("andar", "Andar", $this->andar, "2","2", FALSE); | 276 | $this->campoTexto("andar", "Andar", $this->andar, "2","2", FALSE); |
277 | } | 277 | } |
278 | 278 | ||
279 | - $this->campoTexto("p_ddd_telefone_1", "DDD Telefone 1", | ||
280 | - $this->p_ddd_telefone_1, "2", "2", FALSE); | ||
281 | - | ||
282 | - $this->campoTexto("p_telefone_1", "Telefone 1", $this->p_telefone_1, | ||
283 | - "10", "15", FALSE); | ||
284 | - | ||
285 | - $this->campoTexto("p_ddd_telefone_2", "DDD Telefone 2", | ||
286 | - $this->p_ddd_telefone_2, "2", "2", FALSE); | ||
287 | - | ||
288 | - $this->campoTexto("p_telefone_2", "Telefone", $this->p_telefone_2, "10", | ||
289 | - "15", FALSE); | ||
290 | - | ||
291 | - $this->campoTexto("p_ddd_telefone_mov", "DDD Celular", $this->p_ddd_telefone_mov, | ||
292 | - "2", "2", FALSE); | ||
293 | - | ||
294 | - $this->campoTexto("p_telefone_mov", "Celular", $this->p_telefone_mov, "10", | ||
295 | - "15", FALSE); | ||
296 | - | ||
297 | - $this->campoTexto("p_ddd_telefone_fax", "DDD Fax", $this->p_ddd_telefone_fax, | ||
298 | - "2", "2", FALSE); | ||
299 | - | ||
300 | - $this->campoTexto("p_telefone_fax", "Fax", $this->p_telefone_fax, "10", "15", | ||
301 | - FALSE); | 279 | + $this->inputTelefone('1', 'Telefone 1'); |
280 | + $this->inputTelefone('2', 'Telefone 2'); | ||
281 | + $this->inputTelefone('mov', 'Celular'); | ||
282 | + $this->inputTelefone('fax', 'Fax'); | ||
302 | 283 | ||
303 | $this->campoTexto("p_http", "Site", $this->p_http, "50", "255", FALSE); | 284 | $this->campoTexto("p_http", "Site", $this->p_http, "50", "255", FALSE); |
304 | 285 | ||
@@ -433,6 +414,38 @@ class indice extends clsCadastro | @@ -433,6 +414,38 @@ class indice extends clsCadastro | ||
433 | 414 | ||
434 | header('Location: index.php'); | 415 | header('Location: index.php'); |
435 | } | 416 | } |
417 | + | ||
418 | + protected function inputTelefone($type, $typeLabel = '') { | ||
419 | + if (! $typeLabel) | ||
420 | + $typeLabel = "Telefone {$type}"; | ||
421 | + | ||
422 | + // ddd | ||
423 | + | ||
424 | + $options = array( | ||
425 | + 'required' => false, | ||
426 | + 'label' => "(ddd) / {$typeLabel}", | ||
427 | + 'placeholder' => 'ddd', | ||
428 | + 'value' => $this->{"p_ddd_telefone_{$type}"}, | ||
429 | + 'max_length' => 3, | ||
430 | + 'size' => 3, | ||
431 | + 'inline' => true | ||
432 | + ); | ||
433 | + | ||
434 | + $this->inputsHelper()->integer("p_ddd_telefone_{$type}", $options); | ||
435 | + | ||
436 | + | ||
437 | + // telefone | ||
438 | + | ||
439 | + $options = array( | ||
440 | + 'required' => false, | ||
441 | + 'label' => '', | ||
442 | + 'placeholder' => $typeLabel, | ||
443 | + 'value' => $this->{"p_telefone_{$type}"}, | ||
444 | + 'max_length' => 11 | ||
445 | + ); | ||
446 | + | ||
447 | + $this->inputsHelper()->integer("p_telefone_{$type}", $options); | ||
448 | + } | ||
436 | } | 449 | } |
437 | 450 | ||
438 | 451 |