✏️ 正在编辑: Corretor.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/forms/Corretor.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php use Modules\Pessoa\Enum\StatusCadastroCorretorEnum; use Modules\Gatekeeper\Service\Gatekeeper as Gatekeeper; class Form_Corretor extends Core_Form { /** @var Model_DbTable_Corretor */ private $table; private $_niveis = array( 0 => 'Esteira livre', 1 => 'Esteira aprovador', 2 => 'Esteira Padrão' ); private $grupoAcesso = [ 1 => 'Corretor', 4 => 'Afiliado' ]; public function init() { $this->table = table('corretor'); $this->setName('f_save_corretor'); $this->addElement('hidden', 'id', array( 'class' => 'invisivel' )); $this->addElement('text', 'id2', array( 'label' => 'ID:', 'disabled' => 'disabled' )); $this->addElementWith('data_cadastro', $this->getOptions('Data Cadastro: ')) ->addElementWith('data_ultima_atualizacao', $this->getOptions('Data Atualização: ')) ->setDisableds(['data_cadastro', 'data_ultima_atualizacao']); $this->getElement('data_cadastro') ->addDecorator('Label', ['tag' => 'dt', 'tagClass' => 'clear']); $this->addDadosOperacionais(); $this->addDadosPessoais(); $this->addDadosEndereco(); $this->addDadosBancarios(); $this->addDadosContato(); $this->addDadosAcesso(); $this->addDadosConfiguracao(); $this->addAutomatizacaoOportunidadesNegocios(); $this->removeDisplayGroupLabels(); $this->initButtons(); } protected function addDadosOperacionais() { $select = new Zend_Form_Element_Select('nivel_esteira'); $select->setLabel('Nível esteira') ->addMultiOptions($this->_niveis) ->setAttrib('style', "width: 100%;"); $this->addElement($select); $select = new Zend_Form_Element_Select('empresa_id'); $select->setLabel('Empresa') ->setRequired(true) ->addMultiOptions(Core_Combos::getEmpresasOptions()) ->setAttrib('style', "width: 100%;"); $this->addElement($select); $select = new Zend_Form_Element_Select('grupo_comissao'); $select->setLabel('Grupo Comissão:') ->addMultiOptions(Core_Combos::getGruposComissaoOptions()) ->setAttrib('style', "width: 100%;"); $this->addElement($select); $select = new Zend_Form_Element_Select('rota_id'); $select->setLabel('Rota:') ->setRequired(true) ->addMultiOptions(Core_Combos::getRotasOptions()) ->setAttrib('style', "width: 100%;"); $this->addElement($select); $select = new Zend_Form_Element_Select('grupo_acesso'); $select->setLabel('Grupo de Acesso:') ->setRequired() ->addMultiOptions($this->grupoAcesso) ->setAttrib('style', "width: 100%;"); $this->addElement($select); $this->addElement('text', 'numero_certificado', [ 'label' => 'Número do certificado:', ]); $this->getElement('numero_certificado') ->addDecorator('Label', ['tag' => 'dt', 'tagClass' => 'clear']); $this->addElement(Form_DatePicker::getDatePicker('validade_certificado', 'Validade certificado:', '')); $this->addElement(Form_DatePicker::getDatePicker('data_inicio_operacao', 'Início Operação:', '')); $this->addElement(Form_DatePicker::getDatePicker('data_fim_operacao', 'Fim Operação:', '')); $this->addDisplayGroup(array( 'empresa_id', 'nivel_esteira', 'grupo_comissao', 'rota_id', 'grupo_acesso', 'numero_certificado', 'validade_certificado', 'data_inicio_operacao', 'data_fim_operacao', ), 'dados-operacionais', array('legend' => 'Dados Operacionais')); } protected function addDadosPessoais() { $this->addElement('text', 'nome', array( 'label' => 'Nome / Razão Social:', 'size' => 35, 'required' => true )); $this->addElement('text', 'apelido', array( 'label' => 'Apelido / Fantasia:', 'size' => 35 )); $this->addElement('text', 'cpf', array( 'label' => 'CPF/CNPJ:', 'onkeypress' => 'mascara(this, soNumeros)', 'maxlength' => 14, 'onchange' => 'validCpfCorretor(value)', 'required' => true, )); $this->addElement('text', 'responsavel', array( 'label' => 'Sócio administrador:', 'size' => 35, )); $this->getElement('responsavel') ->addDecorator('Label', ['tag' => 'dt', 'tagClass' => 'clear']); $this->addElement('text', 'cpf_responsavel', array( 'label' => 'CPF Sócio:', 'onkeypress' => 'mascara(this, soNumeros)', 'maxlength' => 11, )); $this->addElement('text', 'rg', array( 'label' => 'RG:', )); $this->addElement('text', 'nome_mae', array( 'label' => 'Mãe:', 'size' => 35 )); $this->addElement('text', 'orgao_expedidor', array( 'label' => 'Órgão:', )); $this->addElement('text', 'data_nascimento', array( 'label' => 'Data Nascimento:', 'onkeypress' => 'mascara(this, data)', 'maxlength' => 10, 'size' => 11, 'validators' => array( new Validators_DataNascimento() ) )); $this->addSelect('estado_civil', 'Estado Civil:', [ '' => '', 'SOLTEIRO' => 'SOLTEIRO(A)', 'CASADO' => 'CASADO(A)', 'DESQUITADO' => 'DESQUITADO(A)', 'DIVORCIADO' => 'DIVORCIADO(A)', 'VIUVO' => 'VIUVO(A)', 'OUTROS' => 'OUTROS' ]); $this->addSelect('nacionalidade', 'Nacionalidade:', [ 'BRASILEIRO' => 'BRASILEIRO(A)', 'ESTRANGEIRO' => 'ESTRANGEIRO(A)' ]); $this->addElement('text', 'profissao', [ 'label' => 'Profissão:' ]); $this->addElement('textarea', 'obs', array( 'label' => 'Observação:', 'rows' => 5, 'cols' => 35 )); $this->addDisplayGroup(array( 'nome', 'apelido', 'cpf', 'responsavel', 'cpf_responsavel', 'rg', 'nome_mae', 'orgao_expedidor', 'data_nascimento', 'estado_civil', 'nacionalidade', 'profissao', 'obs' ), 'dados-pessoais', array('legend' => 'Dados Pessoais')); } protected function addDadosEndereco() { $this->addElement('text', 'endereco', array( 'label' => 'Endereço:', 'size' => 35, )); $this->addElement('text', 'bairro', array( 'label' => 'Bairro:', )); $this->addElement('text', 'complemento', array( 'label' => 'Complemento:', 'size' => 35, )); $this->addElement('text', 'cidade', array( 'label' => 'Cidade:', )); $this->addElement('text', 'uf', array( 'label' => 'UF:', 'maxlength' => 2, 'size' => 3, 'validators' => array( new Validators_Uf() ) )); $this->addElement('text', 'cep', array( 'label' => 'CEP:', 'maxlength' => 8 )); $this->addElement('text', 'numero', array( 'label' => 'Número:', 'maxlength' => 8 )); $this->addDisplayGroup(array( 'endereco', 'bairro', 'complemento', 'cidade', 'uf', 'cep', 'numero', ), 'dados-endereco', array('legend' => 'Endereço')); } protected function addDadosBancarios() { $select = new Zend_Form_Element_Select('banco'); $select->setLabel('Banco:') ->addMultiOptions(Core_Combos::getBancosFebrabanOptions()) ->setAttribs(['style' => "width: 250px;", 'class' => 'comboautocomplete']); $this->addElement($select); $this->addElement('text', 'agencia', array( 'label' => 'Agência:', )); $this->addElement('text', 'conta', array( 'label' => 'Conta:', )); $this->addElement('text', 'titular', array( 'label' => 'Titular:', 'size' => 35, )); $this->addElement('text', 'cpf_titular', array( 'label' => 'CPF/CNPJ Titular:', 'onkeypress' => 'mascara(this, soNumeros)', 'maxlength' => 14, )); $select = new Zend_Form_Element_Select('tipo_conta'); $select->setLabel('Tipo de Conta:') ->addMultiOptions($this->_getTiposContaOptions()); $this->addElement($select); $this->addElement('text', 'chave_pix', [ 'label' => 'Chave PIX', 'size' => 35, 'maxlength' => 50 ]); $this->addDisplayGroup(array( 'banco', 'agencia', 'conta', 'titular', 'cpf_titular', 'tipo_conta', 'chave_pix' ), 'dados-bancarios', array('legend' => 'Dados bancários')); } protected function addDadosContato() { $this->addElement('text', 'email', array( 'label' => 'E-mail:', 'validators' => array( 'EmailAddress' ), 'class' => 'noKeyup', 'size' => 35 )); $this->addElement('text', 'celular', array( 'label' => 'Celular:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 15, 'size' => 15 )); $this->addElement('text', 'fax', array( 'label' => 'Fax:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 15, 'size' => 15 )); $this->addElement('text', 'telefone_residencial', array( 'label' => 'Fone Residencial:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 14, 'size' => 15 )); $this->addElement('text', 'telefone_comercial', array( 'label' => 'Fone Comercial:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 15, 'size' => 15 )); $this->addDisplayGroup(array( 'email', 'celular', 'fax', 'telefone_residencial', 'telefone_comercial' ), 'dados-contato', array('legend' => 'Contato')); } protected function addDadosAcesso() { $this->addElement('text', 'login', array( 'label' => 'Login:', 'size' => 35, )); $this->addElement('password', 'senha', array( 'label' => 'Senha:', 'size' => 35, )); $this->addElement('text', 'ip', array( 'label' => 'IP de Acesso:', 'validators' => array(new Zend_Validate_Ip()), 'size' => 35, )); $this->addElement('checkbox', 'mudar_senha', array( 'label' => 'Mudar Senha', 'description' => 'Solicitar uma nova senha no próximo acesso' )); // $this->addElement('checkbox', 'acesso_aplicativo', array( // 'label' => 'Acesso Aplicativo', // 'description' => 'Permitir o acesso ao aplicativo mobile' // )); // $this->addElement('checkbox', 'acesso_temporario', array( // 'label' => 'Acesso Temporário', // 'description' => 'Permitir o acesso temporário de 10 dias no aplicativo' // )); $this->addElement('checkbox', 'corretor_desativado', array( 'label' => 'Corretor desativado', 'description' => 'Desativar e bloquear o acesso do corretor' )); $this->addElement('hidden', 'data_temporario_app', array( )); $this->addDisplayGroup(array( 'login', 'senha', 'ip', 'mudar_senha', // 'acesso_aplicativo', // 'acesso_temporario', 'corretor_desativado', 'data_temporario_app', ), 'dados-acesso', array('legend' => 'Dados de acesso')); } protected function addDadosConfiguracao() { $select = new Zend_Form_Element_Select('tipo_venda'); $select->setLabel('Tipo de venda') ->addMultiOptions(Core_Combos::getTiposVendaOptions()) ->setAttrib('style', "width: 100%;"); $this->addElement($select); $this->addElement('text', 'prazo_fisico', array( 'label' => 'Prazo Limite Físico:', 'onkeypress' => 'mascara(this, soNumeros)', 'maxlength' => 3 )); $this->addElement('text', 'token_sinc_yuppies', array( 'label' => 'Token de acesso:', 'class' => 'noKeyup', 'size' => 35 )); $this->addElement('checkbox', 'permitir_sinc_yuppies', array( 'label' => 'Habilitar token:', )); $this->addElement('text', 'dias_bloqueio_producao', array( 'label' => 'Dias para bloqueio sem produção:', 'onkeypress' => 'mascara(this, soNumeros)', 'maxlength' => 3 )); $this->addElement('text', 'percentual_corte', array( 'label' => 'Corte de Produção: (%)', 'onkeypress' => 'mascara(this, mvalor)', 'maxlength' => 6 )); $this->addElement('text', 'potencial_venda', array( 'label' => 'Potencial de Venda: (R$)', 'onkeypress' => 'mascara(this, mvalor)', )); $this->addElement('checkbox', 'bloquear_pagamento', array( 'label' => 'Bloquear pagamento', 'description' => 'Forçar bloqueio de pagamento' )); $this->addElement('text', 'motivo', array( 'label' => 'Motivo bloqueio:', 'size' => 35 )); $this->addElement('checkbox', 'obedecer_id', array( 'label' => 'Obedecer ID' )); $this->addElement('radio', 'descontar_taxa_transf', array( 'label' => 'Descontar Taxa Transf:', 'separator' => "", 'multiOptions' => array( '0' => 'Não', '1' => 'Sim' ) )); $this->addSelect('status_cadastro', 'Status Cadastro:', StatusCadastroCorretorEnum::OPTIONS); $this->addSelect('permitir_autocontratacao', 'Permitir Auto-contratação:', [ '0' => 'Não', '1' => 'Sim' ]); $this->addDisplayGroup(array( 'tipo_venda', 'prazo_fisico', 'token_sinc_yuppies', 'permitir_sinc_yuppies', 'dias_bloqueio_producao', 'obedecer_id', 'bloquear_pagamento', 'descontar_taxa_transf', 'motivo', 'percentual_corte', 'potencial_venda', 'status_cadastro', 'permitir_autocontratacao' ), 'dados-configuracao', array('legend' => 'Configurações')); } protected function removeDisplayGroupLabels() { foreach ($this->getDisplayGroups() as $displayGroup){ $displayGroup->removeDecorator('DtDdWrapper'); } } protected function initButtons() { $this->addElement('button', 'btn_back', array( 'label' => 'Voltar', 'class' => 'bt_back', 'onclick' => "window.location='" . $this->getView()->baseUrl('corretor') . "'" )); $this->addElement('submit', 'btn_save', array( 'label' => 'Salvar', 'class' => 'bt_save' )); $this->addElement('button', 'btn_new', array( 'label' => 'Novo Cadastro', 'class' => 'bt_new', 'onclick' => "window.location='" . $this->getView()->baseUrl('corretor/save') . "'" )); $params = Zend_Controller_Front::getInstance()->getRequest()->getParams(); $id = (int)$params['id']; $groupTermo = ''; if (!empty($id) && !Gatekeeper::getPlanoConfig()) { $this->addElement('button', 'send_email', [ 'label' => 'E-mail de Boas Vindas', 'class' => 'bt_new', 'onclick' => "window.location='" . $this->getView()->baseUrl("corretor/save-confirm/id/{$id}/reenvio/1") . "'" ]); } if ($this->isPermitirSincYuppies($id)) { $this->addElement('button', 'btn_gerar_link', [ 'label' => 'Obter link de digitação de proposta', 'class' => 'btn_gerar_link bt_find' ]); } $this->addDisplayGroup( ['btn_back', 'btn_save', 'btn_new', 'send_email', $groupTermo, 'btn_gerar_link'], 'buttons' ); } protected function _getTiposContaOptions() { $options = array( '' => '' ); $options['CC'] = 'CC'; $options['CP'] = 'CP'; return $options; } public function isValid($data) { $result2 = true; if( !isset($data['id']) || empty($data['id']) ){ $validator = new Zend_Validate_Db_NoRecordExists(array( 'table' => 'vw_corretores', 'field' => 'login' )); $this->getElement('login')->addValidator($validator); } $result = parent::isValid($data); if( $data['id'] ){ $corretor = $this->table->findByLogin($data['login']); if( is_object($corretor) && !empty($corretor->login) && !empty($corretor->id) && $corretor->id != $data['id'] ){ $this->getElement('login')->addError('O login informado já está em uso.'); $result2 = false; } } if(isset($data['cpf']) && $data['cpf']){ $cpfCnpj = String_Refatorar::soNumeros($data['cpf']); if( strlen($cpfCnpj) <= 11 ){ $this->getElement('cpf')->setValidators(array( new Validators_Cpf() )); } else { $this->getElement('cpf')->setValidators(array( new Validators_Cnpj() )); } } return ($result && $result2); } public function populate(array $values) { if( isset($values['id']) && !empty($values['id']) ){ $values['id2'] = $values['id']; } if(empty($values['token_sinc_yuppies'])){ $values['token_sinc_yuppies'] = md5(uniqid(rand(), true)); } if(!empty($values['percentual_corte'])){ $values['percentual_corte'] = number_format($values['percentual_corte'], 2, ',', '.'); } if(!empty($values['potencial_venda'])){ $values['potencial_venda'] = number_format($values['potencial_venda'], 2, ',', '.'); } if( !empty($values['data_nascimento']) && $values['data_nascimento'] != '0000-00-00' ){ $values['data_nascimento'] = date('d/m/Y', strtotime($values['data_nascimento'])); } if( !empty($values['validade_certificado']) && $values['validade_certificado'] != '0000-00-00' ){ $values['validade_certificado'] = date('d/m/Y', strtotime($values['validade_certificado'])); } if (!empty($values['data_cadastro']) && $values['data_cadastro'] != '0000-00-00') { $values['data_cadastro'] = date('d/m/Y H:i:s', strtotime($values['data_cadastro'])); } if (!empty($values['data_ultima_atualizacao']) && $values['data_ultima_atualizacao'] != '0000-00-00') { $values['data_ultima_atualizacao'] = date('d/m/Y H:i:s', strtotime($values['data_ultima_atualizacao'])); } if( !empty($values['data_inicio_operacao']) && $values['data_inicio_operacao'] != '0000-00-00' ){ $values['data_inicio_operacao'] = date('d/m/Y', strtotime($values['data_inicio_operacao'])); } if( !empty($values['data_fim_operacao']) && $values['data_fim_operacao'] != '0000-00-00' ){ $values['data_fim_operacao'] = date('d/m/Y', strtotime($values['data_fim_operacao'])); } return parent::populate($values); } /** * @param int|null $corretor * @return bool */ public function isPermitirSincYuppies(?int $corretor): bool { return $corretor && (bool) $this->table->fetchRow(['id = ?' => $corretor])->permitir_sinc_yuppies; } /** * @throws Zend_Form_Exception */ private function addAutomatizacaoOportunidadesNegocios(): self { $this->addTwoOptionsElement('automatizacao_oportunidades_negocios', 'Habilitado:', false) ->addSelect( 'oportunidades_negocios_filtro_id', 'Filtro:', Core_Combos::getAutoOportunidadesNegocios() ); $this->addDisplayGroup( ['automatizacao_oportunidades_negocios', 'oportunidades_negocios_filtro_id'], 'auto_oportunidades_negocios', ['legend' => 'Automatização Oportunidades Negócios'] ); return $this; } }
💾 保存文件
← 返回文件管理器