Last active
August 29, 2015 14:11
-
-
Save jonasporto/82897341df80288766c3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function altera_cpf(){ | |
| $pfs = $this->PessoasFisica->find('all',array('fields'=>array('cod_pessoa_fisica','cpf'),'recursive'=>-1)); | |
| //select * from pessoas_fisicas pf,pessoas_fisicas pfi where sem_pontuacao(pf.cpf) = sem_pontuacao(pfi.cpf) and pf.cod_pessoa_fisica != pfi.cod_pessoa_fisica; | |
| foreach($pfs as $k => $pf){ | |
| if(strlen($pf['PessoasFisica']['cpf']) < 14){ | |
| $pfs[$k]['PessoasFisica']['cpf'] = $this->mask(str_replace(array('.','-'),'',$pf['PessoasFisica']['cpf']),'###.###.###-##'); | |
| $this->PessoasFisica->create(); | |
| $this->PessoasFisica->save($pfs[$k]); | |
| } | |
| } | |
| die; | |
| } | |
| function mask($val, $mask) | |
| { | |
| $maskared = ''; | |
| $k = 0; | |
| for($i = 0; $i<=strlen($mask)-1; $i++) | |
| { | |
| if($mask[$i] == '#') | |
| { | |
| if(isset($val[$k])) | |
| $maskared .= $val[$k++]; | |
| } | |
| else | |
| { | |
| if(isset($mask[$i])) | |
| $maskared .= $mask[$i]; | |
| } | |
| } | |
| return $maskared; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment