✏️ 正在编辑: CorretorCadastroSiteForm.php
路径:
/srv/systems_dir/yuppiecred/application/Modules/Pessoa/Form/CorretorCadastroSiteForm.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php namespace Modules\Pessoa\Form; use \Core_Combos as Combos; use Modules\Core\Enum\TipoAnexosEnum; use Modules\Financeiro\Enum\TipoContaBancoOptions; class CorretorCadastroSiteForm extends \Core_Form { /** @var string[] */ public const REQUIREDS = [ 'nome', 'email', 'cpf', 'rg', 'orgao_expedidor', 'data_nascimento', 'celular', 'tipo_venda', 'cep', 'endereco', 'bairro', 'cidade', 'numero', 'uf', 'estado_civil', 'nacionalidade', 'profissao', 'grupo_acesso' ]; public function init() { $this->setAttrib('class', 'recaptchaForm') ->addDadosPessoais() ->addDadosEndereco() ->addDadosBancarios() ->addDadosContato() ->addUploads() ->addRecaptcha() ->addButtons(); $this->setRequireds(self::REQUIREDS); } /** * @return $this * @throws \Zend_Form_Exception */ private function addButtons(): self { $this->addElement('submit', 'btn_save', ['label' => 'Enviar', 'class' => 'bt_send' ]); $this->addDisplayGroup(['btn_save'], 'buttons', []); return $this; } /** * @return $this * @throws \Zend_Form_Exception */ private function addDadosContato(): self { $this->addElementWith('email', $this->getOptions('E-mail:', 35)) ->addElementWith('celular', $this->getOptions('Celular:', 15, 15, 'mascara(this, telefone)')) ->addElementWith( 'telefone_residencial', $this->getOptions('Fone Residencial:', 15, 15, 'mascara(this, telefone)') ) ->addElementWith( 'telefone_comercial', $this->getOptions('Fone Comercial:', 15, 15, 'mascara(this, telefone)') ) ->getElement('email')->addValidators(['EmailAddress']); $this->addDisplayGroup(self::contatoGroup(), 'dados-contato', ['legend' => 'Contato']); return $this; } /** * @return string[] */ public static function contatoGroup(): array { return [ 'email', 'celular', 'telefone_residencial', 'telefone_comercial' ]; } /** * @return $this * @throws \Zend_Form_Exception */ private function addDadosBancarios(): self { $this->addSelect('banco', 'Banco:', Combos::getBancosFebrabanOptions()) ->addElementWith('agencia', $this->getOptions('Agência')) ->addElementWith('conta', $this->getOptions('Conta:')) ->addElementWith('titular', $this->getOptions('Titular:', 35)) ->addElementWith('cpf_titular', $this->getOptions('CPF/CNPJ Titular:', 15, 14, 'mascara(this, soNumeros)')) ->addSelect('tipo_conta', 'Tipo de Conta:', TipoContaBancoOptions::OPTIONS) ->addElementWith('chave_pix', $this->getOptions('Chave Pix:', 35, 50)); $this->getElement('banco')->setAttrib('class', 'comboautocomplete'); $this->addDisplayGroup(self::contaGroup(), 'dados-bancarios', array('legend' => 'Dados bancários')); return $this; } /** * @return string[] */ public static function contaGroup(): array { return [ 'banco', 'agencia', 'conta', 'titular', 'cpf_titular', 'tipo_conta', 'chave_pix' ]; } /** * @return $this * @throws \Zend_Form_Exception */ private function addDadosEndereco(): self { $this->addElementWith('endereco', $this->getOptions('Endereço:', 35)) ->addElementWith('bairro', $this->getOptions('Bairro:', 35)) ->addElementWith('complemento', $this->getOptions('Complemento:', 35)) ->addElementWith('cidade', $this->getOptions('Cidade:', 10)) ->addElementWith('uf', $this->getOptions('UF:', 3, 2)) ->addInt('cep', 'CEP:', 8) ->addInt('numero', 'Número:', 8); $this->getElement('uf')->addValidator(new \Validators_Uf()); $this->addDisplayGroup(self::enderecoGroup(), 'dados-endereco', ['legend' => 'Endereço']); return $this; } /** * @return string[] */ public static function enderecoGroup(): array { return [ 'cep', 'endereco', 'bairro', 'complemento', 'cidade', 'uf', 'numero' ]; } /** * @return $this * @throws \Zend_Form_Exception */ private function addDadosPessoais(): self { $this->addElementWith('nome', $this->getOptions('Nome / Razão Social:', 35)) ->addElementWith('apelido', $this->getOptions('Apelido / Fantasia:', 35)) ->addElementWith('cpf', $this->getOptions('CPF / CNPJ:', null, 14, 'mascara(this, soNumeros)')) ->addInt('rg', 'RG:', 20) ->addElementWith('responsavel', $this->getOptions('Responsável:', 35)) ->addElementWith('cpf_responsavel', $this->getOptions('CPF Responsável:', null, 11, 'mascara(this, soNumeros)')) ->addElementWith('nome_mae', $this->getOptions('Mãe:', 35)) ->addElementWith('orgao_expedidor', $this->getOptions('Órgão:', 10)) ->addElementWith('numero_certificado', $this->getOptions('Número Certificado:', 10)) ->addDateElement('data_nascimento', 'Data Nascimento:') ->addDateElement('validade_certificado', 'Validade Certificado:') ->addSelect('tipo_venda', 'Tipo de venda:', Combos::getTiposVendaOptions()) ->addSelect('estado_civil', 'Estado Civil:', [ '' => '', 'SOLTEIRO' => 'SOLTEIRO(A)', 'CASADO' => 'CASADO(A)', 'DESQUITADO' => 'DESQUITADO(A)', 'DIVORCIADO' => 'DIVORCIADO(A)', 'VIUVO' => 'VIUVO(A)', 'OUTROS' => 'OUTROS' ]) ->addSelect('nacionalidade', 'Nacionalidade:', [ 'BRASILEIRO' => 'BRASILEIRO(A)', 'ESTRANGEIRO' => 'ESTRANGEIRO(A)' ]) ->addSelect('grupo_acesso', 'Grupo de Acesso:', [ 1 => 'CORRETOR', 4 => 'AFILIADO' ]) ->addElementWith('profissao', $this->getOptions('Profissão:', 35)) ->getElement('data_nascimento')->addValidator(new \Validators_DataNascimento()); $this->addDisplayGroup(self::dadosPessoaisGroup(), 'dados-pessoais', ['legend' => 'Dados Pessoais']); $this->getElement('cpf')->setAttribs([ 'class' => 'check_input', 'data-check' => 'cpf_corretor' ]); return $this; } /** * @return string[] */ public static function dadosPessoaisGroup(): array { return [ 'nome', 'apelido', 'cpf', 'rg', 'responsavel', 'cpf_responsavel', 'nome_mae', 'orgao_expedidor', 'data_nascimento', 'tipo_venda', 'numero_certificado', 'validade_certificado', 'estado_civil', 'nacionalidade', 'profissao', 'grupo_acesso' ]; } /** * @return $this * @throws \Zend_Form_Exception */ private function addUploads(): self { $this->addSelect('tipo_upload', 'Anexos: *', TipoAnexosEnum::OPTIONS) ->getElement('tipo_upload')->setAttribs(['onchange' => 'checkAnexosTipo(this)']); $this->addDisplayGroup(self::anexosGroup(), 'anexos', ['legend' => 'Anexos']); return $this; } /** * @return string[] */ public static function anexosGroup(): array { return [ 'tipo_upload', 'CNH', 'CPF', 'RG', 'COMPROVANTE_ENDERECO' ]; } /** * @return $this */ public function removeAnexos(): self { $this->removeElement('CPF'); $this->removeElement('RG'); $this->removeElement('CNH'); $this->removeElement('COMPROVANTE_ENDERECO'); return $this; } /** * @return $this * @throws \Zend_Form_Exception */ public function addAnexos(): self { $this->addElement('file', 'CNH', ['label' => 'CNH: *']) ->addElement('file', 'CPF', ['label' => 'CPF: *']) ->addElement('file', 'RG', ['label' => 'RG: *']) ->addElement('file', 'COMPROVANTE_ENDERECO', ['label' => 'Comprovante de Endereço:']); $this->addDisplayGroup(self::anexosGroup(), 'anexos', ['legend' => 'Anexos']); if (TipoAnexosEnum::RGCPF === (int) $this->getElement('tipo_upload')->getValue()) { return $this->rgCpf(); } return $this->cnh(); } public function cnh(): self { $this->getElement('CNH')->setAttrib('disabled', null); $this->setDisableds(['RG', 'CPF']); return $this; } public function rgCpf(): self { $this->getElement('RG')->setAttrib('disabled', null); $this->getElement('CPF')->setAttrib('disabled', null); $this->setDisableds(['CNH']); return $this; } public function isValid($data) { $valid = true; if ((empty($data['banco']) || empty($data['agencia']) || empty($data['conta']) || empty($data['tipo_conta'])) && empty($data['chave_pix'])) { $this->getElement('banco') ->addError('Os dados bancários devem ser informados ou uma Chave PIX'); $valid = false; } return parent::isValid($data) && $valid; } }
💾 保存文件
← 返回文件管理器