✏️ 正在编辑: Proposta.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/forms/Proposta.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_Proposta extends Core_Form { public function init() { $ns = new Zend_Session_Namespace(); $params = $this->_getParams(); $this->setName('f_save_proposta'); $this->setAttrib('autocomplete', 'off'); $this->addElement('hidden', 'id', array( 'class' => 'invisivel' )); $this->addElement('hidden', 'token', array( 'class' => 'invisivel', 'value' => "proposta_" . md5(time()) )); $select = new Zend_Form_Element_Select('subestabelecido_id'); $select->setLabel('Subestabelecido:') ->addMultiOptions(Core_Combos::getSubestabelecidosOptions()); $this->addElement($select); $this->addElement('text', 'cpf', array( 'label' => 'CPF:', 'onkeypress' => 'mascara(this, fcpf)', 'maxlength' => 14, 'required' => true, 'validators' => array( new Validators_Cpf() ), 'class' => 'load-data-client' )); $this->addElement('text', 'nome', array( 'label' => 'Nome:', 'required' => true, 'size' => 30, )); $this->addElement('text', 'rg', array( 'label' => 'Identidade (RG):', )); $this->addElement('text', 'orgao_expedidor', array( 'label' => 'Órgão Emissor:', )); $this->addElement('text', 'uf_expedidor', array( 'label' => 'UF Emissor:', 'size' => 2, 'maxlength' => 2 )); $this->addElement('text', 'data_expedicao', array( 'label' => 'Data Expedição:', 'onkeypress' => 'mascara(this, data)', 'maxlength' => 10, 'size' => 11 )); $this->addElement('text', 'data_nascimento', array( 'label' => 'Data Nascimento:', 'onkeypress' => 'mascara(this, data)', 'maxlength' => 10, 'size' => 11, 'validators' => array( new Validators_DataNascimento() ) )); $this->addElement('text', 'naturalidade', array( 'label' => 'Naturalidade:', 'size' => 30, )); $this->addElement('text', 'nome_pai', array( 'label' => 'Pai:', 'size' => 30, )); $this->addElement('text', 'nome_mae', array( 'label' => 'Mãe:', 'size' => 30, )); $this->addElement('text', 'conjuge', array( 'label' => 'Cônjuge:', 'size' => 30, )); $this->addElement('text', 'endereco', array( 'label' => 'Endereço:', 'size' => 30, )); $this->addElement('text', 'complemento', array( 'label' => 'Complemento:', 'size' => 30, )); $this->addElement('text', 'bairro', array( 'label' => 'Bairro:', )); $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', 'email', array( 'label' => 'E-mail:', 'validators' => array( 'EmailAddress' ), 'size' => 30 )); $this->addElement('text', 'celular', array( 'label' => 'Celular:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 15, 'class' => 'consulta-fone-nao-perturbe', 'size' => 15 )); $this->addElement('text', 'fax', array( 'label' => 'Fax:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 15, 'size' => 15 )); $this->addElement('text', 'fone', array( 'label' => 'Fone Residencial:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 14, 'class' => 'consulta-fone-nao-perturbe', 'size' => 15 )); $select = new Zend_Form_Element_Select('representante_legal'); $select->setLabel('Possui Repr. Legal:') ->setAttrib('onchange', "exibirRepresentanteLegal(this)") ->addMultiOptions([ 0 => 'Não', 1 => 'Sim', ]); $this->addElement($select); $this->addElement('text', 'nome_representante', [ 'label' => 'Nome Representante:', 'size' => 30, ]); $this->addElement('text', 'cpf_representante', [ 'label' => 'CPF Representante:', 'onkeypress' => 'mascara(this, fcpf)', 'maxlength' => 14, 'validators' => [new Validators_Cpf()], 'class' => 'load-data-client', ]); $this->addElement('text', 'telefone_comercial', array( 'label' => 'Fone Comercial:', 'onkeypress' => 'mascara(this, telefone)', 'maxlength' => 15, 'class' => 'consulta-fone-nao-perturbe', 'size' => 15 )); $this->addElement('text', 'senha_contracheque', array( 'label' => 'Senha contra-cheque:', 'size' => 30, 'class' => 'not_upper' )); if( isset($params['controller']) && $params['controller'] == 'emprestimo-pessoal' ){ $select = new Zend_Form_Element_Select('banco_id'); $select->setLabel('Banco:') ->setRequired(true) ->addMultiOptions(Core_Combos::getBancosCreditoPessoalOptions(array( 'credito_pessoal' => 1 ))) ->setAttrib('onchange', "populateComboProdutos(this.id, 'produto')"); $this->addElement($select); } else { $select = new Zend_Form_Element_Select('banco_id'); $select->setLabel('Banco:') ->setRequired(true) ->addMultiOptions(Core_Combos::getBancosOptions()); $this->addElement($select); } $select = new Zend_Form_Element_Select('convenio_id'); $select->setLabel('Convênio:') ->setRequired(true) ->addMultiOptions(Core_Combos::getConveniosOptions()) ->setAttrib('onchange', "populateComboTabelas(this.id, 'tabela_id', 'banco_id')") ->setAttrib('class', "comboautocomplete"); $this->addElement($select); $select = new Zend_Form_Element_Select('tabela_id'); $select->setLabel('Tabela:') ->setRegisterInArrayValidator(false); $this->addElement($select); $select = new Zend_Form_Element_Select('corretor_id'); $select->setLabel('Corretor:') ->setRequired(true) ->addMultiOptions(Core_Combos::getCorretoresOptions(true)); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo'); $select->setLabel('Tipo:') ->addMultiOptions(Core_Combos::getTiposProdutosPropostasOptions()) ->setAttrib('onchange', "populateComboProdutos('banco_id', 'produto'); addCamposDigitacaoProposta()") ->setRequired(true); $this->addElement($select); $this->addElement(Form_DatePicker::getDatePicker('data_emissao', 'Data de Emissão:', date('d/m/Y'), true)); $this->getElement('data_emissao')->addValidator(new Validators_DataContrato()); $this->addElement('text', 'prazo', array( 'label' => 'Prazo:', 'required' => true, 'size' => 10, 'onkeypress' => 'mascara(this, soNumeros)' )); $select = new Zend_Form_Element_Select('forma_liberacao'); $select->setLabel('Forma de Liberação:') ->setAttrib('class', 'not_multiselect') ->addMultiOptions(Core_Combos::getFormasLiberacaoOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('produto'); $select->setLabel('Produto:') ->setRegisterInArrayValidator(false); $this->addElement($select); $this->addElement('text', 'digitador', array( 'label' => 'Digitador:', 'value' => Yuppie_Auth::getIdentity()->login, 'readonly' => true, 'size' => 30, )); $this->addElement('text', 'numero_beneficio', array( 'label' => 'Número Benefício:', 'size' => 20, 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'valor_beneficio', array( 'label' => 'Valor Benefício (R$):', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)', 'placeholder' => '0,00' )); $this->addElement('text', 'especie', array( 'label' => 'Código Espécie:', 'size' => 10, 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'numero_contrato', array( 'label' => 'Nº Contrato:', 'size' => 20, 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'numero_ade', array( 'label' => 'Nº ADE:', 'size' => 20, 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'valor_bruto', array( 'label' => 'Valor Bruto (R$):', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)', 'required' => true, 'placeholder' => '0,00' )); $this->addElement('text', 'valor_liquido', array( 'label' => 'Valor Líquido (R$):', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)', 'required' => true, 'placeholder' => '0,00' )); $this->addElement('text', 'valor_prestacao', [ 'label' => 'Valor Parcela (R$):', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)', 'placeholder' => '0,00' ]); $this->addTwoOptionsElement('beneficiado_recebe_cartao', 'Recebe por cartão:') ->addSelect('captador_id', 'Captador:', Core_Combos::getCorretoresOptions(true)); $select = new Zend_Form_Element_Select('banco_cartao'); $select->setLabel('Banco do Cartão:') ->addMultiOptions(Core_Combos::getBancosFebrabanOptions()); $this->addElement($select); $this->addElement('text', 'agencia_cartao', [ 'label' => 'Agencia do Cartão:', 'size' => 10 ]); $this->addElement('hidden', 'valor_reducao', ['placeholder' => '0,00']); $this->addElement('hidden', 'banco_reducao'); $this->addElement('text', 'saldo_banco', array( 'label' => 'Saldo no Banco (R$):', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)', 'placeholder' => '0,00' )); $select = new Zend_Form_Element_Select('banco_beneficiado'); $select->setLabel('Banco do Beneficiado:') ->addMultiOptions(Core_Combos::getBancosFebrabanOptions()); $this->addElement($select); $this->addElement('text', 'agencia_beneficiado', array( 'label' => 'Agência do Beneficiado:', 'size' => 10, )); $this->addElement('text', 'operacao_beneficiado', array( 'label' => 'Operação:', 'size' => 10, 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'conta_beneficiado', array( 'label' => 'Conta do Beneficiado:', 'size' => 10, )); $select = new Zend_Form_Element_Select('midia_origem_id'); $select->setLabel('Mídia de Origem:') ->addMultiOptions(Core_Combos::getMidiasOrigemOptions()); $this->addElement($select); if ($ns->acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, "midia-origem-obrigatório")){ $this->getElement('midia_origem_id')->setRequired(); } $select = new Zend_Form_Element_Select('digitado_banco'); $select->setLabel('Situação:') ->addMultiOptions([''] + Core_Combos::getSituacaoDigitacaoProposta()); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo_pix'); $select->setLabel('Tipo de Chave PIX:') ->addMultiOptions(['' => ''] + Core_Combos::getTipoPix()); $this->addElement($select); $this->getElement('tipo_pix')->setAttribs([ 'onchange' => 'changeKeyPix()' ]); $this->addElement('text', 'chave_pix', [ 'label' => 'Chave PIX:', 'size' => 30, ]); $this->addElement(Form_DatePicker::getDatePicker('data_agendamento_proposta', 'Formalização Agendada:')); $this->addElement('text', 'hora_agendada', array( 'label' => 'Hora agendada:', 'onkeypress' => 'mascara(this, hora)', 'maxlength' => 5, 'size' => 10 )); $this->addElement('select', 'anterior_banco', array( 'label' => 'Banco Anterior:', 'multiOptions' => Core_Combos::getBancosFebrabanOptions() )); $this->addElement('text', 'anterior_parcelas_restantes', array( 'label' => 'Parcelas Restantes:', 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'anterior_saldo_devedor', array( 'label' => 'Saldo Devedor:', 'onkeypress' => 'mascara(this, mvalor)', 'placeholder' => '0,00' )); $this->addElement('text', 'anterior_numero', array( 'label' => 'Nº Contrato anterior:' )); $this->addElement('text', 'anterior_prazo', array( 'label' => 'Prazo anterior:', 'onkeypress' => 'mascara(this, soNumeros)' )); $this->addElement('text', 'anterior_valor_parcela', array( 'label' => 'Valor Parcela (R$):', 'onkeypress' => 'mascara(this, mvalor)', 'placeholder' => '0,00' )); $multiOptions = array('' => '') + Core_Combos::getTipoContratoAnexoOptions(); $this->addElement('select', 'tipo_id', array( 'label' => 'Tipo anexo:', 'multiOptions' => $multiOptions )); $file = new Zend_Form_Element_File('arquivo'); $file->setLabel('Arquivo:'); $file->addValidator('Extension', false, 'jpg,pdf,png,bmp,wav,mp3,amr'); $file->addValidator('Size', false, '1MB'); $this->addElement($file); $this->addElement('button', 'adicionar', array( 'label' => 'Adicionar', 'class' => 'load-anexos', 'onClick' => 'addAnexoProposta()', 'style' => 'margin-left: 40px' )); $element = $this->getElement('adicionar'); $element->removeDecorator('DtDdWrapper'); $this->addElement('textarea', 'obs', array( 'label' => 'OBS:', 'cols' => 92, 'rows' => 5 )); $this->addElement('button', 'btn_back', array( 'label' => 'Voltar', 'class' => 'bt_back', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/proposta'" )); $this->addElement('submit', 'btn_save', array( 'label' => 'Salvar', 'class' => 'bt_save', 'onClick' => 'cleanExit()' )); $this->addElement('button', 'btn_new', array( 'label' => 'Novo Cadastro', 'class' => 'bt_new', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/proposta/save'" )); if( isset($params['id']) && $params['id'] > 0 ){ $this->addElement('button', 'btn_efetivar', array( 'label' => 'Efetivar', 'class' => 'bt_efetivar', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/proposta/efetivar/id/{$params['id']}'" )); $this->addElement('button', 'btn_analise_fraude', array( 'label' => 'Esteira anti-fraude', 'class' => 'bt_analise_fraude', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/proposta/fraude/id/{$params['id']}'" )); $this->addElement('button', 'btn_enviar_capa_wp', [ 'label' => 'Enviar capa', 'class' => 'whatsapp', 'onclick' => "enviarCapaContrato({$params['id']}, 'whatsapp')" ]); $this->addElement('button', 'btn_enviar_capa_email', [ 'label' => 'Enviar capa', 'class' => 'send', 'onclick' => "enviarCapaContrato({$params['id']}, 'email')" ]); $this->addElement('button', "btn_link_anexos", [ 'label' => 'Copiar Link Anexos', 'class' => 'btn_link_anexos', 'onclick' => "copiarLinkAnexos({$params['id']})" ]); $this->addElement('button', "btn_enviar_link_anexos", [ 'label' => 'Enviar Link Anexos', 'class' => 'btn_enviar_link_anexos', 'onclick' => "enviarLinkDocumentacao({$params['id']})" ]); } $this->_agruparCampos(); $this->_agruparBotoes(); $this->_setDefaultDecorators(); if ($ns->acl->isAllowed(Yuppie_Auth::getIdentity()->grupo, "digitacao-simplificada-proposta")){ $elements = $this->getElements(); foreach ($elements as $element){ if(!$element->isRequired() && $element->getName() != 'id' && $element->getName() != 'token' && $element->getName() != 'tipo_id' && $element->getName() != 'arquivo' && $element->getName() != 'obs' && $element->getName() != 'fone' && $element->getName() != 'celular' && $element->getName() != 'beneficiado_recebe_cartao' && $element->getName() != 'banco_cartao' && $element->getName() != 'agencia_cartao' && $element->getName() != 'captador_id' && $element->getType() != 'Zend_Form_Element_Submit' && $element->getType() != 'Zend_Form_Element_Button') { $this->removeElement($element->getName()); } } } } protected function _setDefaultDecorators() { $this->setDecorators( array( 'FormElements', array( 'HtmlTag', array( 'tag' => 'dl', 'class' => 'zend_form form_proposta' ) ), 'Form' )); } protected function _agruparCampos() { $this->addDisplayGroup(array( 'cpf', 'nome', 'rg', 'orgao_expedidor', 'data_expedicao', 'uf_expedidor', 'data_nascimento', 'naturalidade', 'nome_pai', 'nome_mae', 'conjuge', 'cep', 'endereco', 'complemento', 'bairro', 'cidade', 'uf', 'email', 'celular', 'fax', 'fone', 'telefone_comercial', 'senha_contracheque', 'representante_legal', 'nome_representante', 'cpf_representante', ), 'dados_tomador', array( 'legend' => 'Dados do tomador' )); $this->addDisplayGroup(array( 'corretor_id', 'subestabelecido_id', 'banco_id', 'tipo', 'convenio_id', 'tabela_id', 'data_emissao', 'prazo', 'forma_liberacao', 'produto', 'numero_contrato', 'numero_ade', 'valor_bruto', 'valor_liquido', 'valor_prestacao', 'saldo_banco', 'digitador', 'numero_beneficio', 'valor_beneficio', 'especie', 'banco_beneficiado', 'agencia_beneficiado', 'operacao_beneficiado', 'conta_beneficiado', 'beneficiado_recebe_cartao', 'banco_cartao', 'agencia_cartao', 'captador_id', 'midia_origem_id', 'data_agendamento_proposta', 'hora_agendada', 'digitado_banco', 'tipo_pix', 'chave_pix', 'valor_reducao', 'banco_reducao', ), 'dados_liberacao', array( 'legend' => 'Dados para liberação' )); $this->addDisplayGroup(array( 'anterior_banco', 'anterior_prazo', 'anterior_parcelas_restantes', 'anterior_saldo_devedor', 'anterior_numero', 'anterior_valor_parcela', ), 'dados_portabilidade', array( 'legend' => 'Dados para portabilidade' )); $this->addDisplayGroup(array( 'tipo_id', 'arquivo', 'adicionar', 'obs',), 'dados_agente', array( 'legend' => 'Anexos' )); $this->_pintarCamposObrigatorios(); } protected function _agruparBotoes() { $this->addDisplayGroup([ 'btn_back', 'btn_save', 'btn_new', 'btn_efetivar', 'btn_analise_fraude', 'btn_enviar_capa_email', 'btn_enviar_capa_wp', 'btn_link_anexos', 'btn_enviar_link_anexos' ], 'buttons'); foreach ( $this->getDisplayGroups() as $displayGroup ) { $displayGroup->removeDecorator('DtDdWrapper'); $displayGroup->removeDecorator('HtmlTag'); if( $displayGroup->getName() == 'buttons' ){ foreach ( $displayGroup->getElements() as $element ) { $element->setDecorators(array( 'ViewHelper' )); } } } } public function populateSave($values){ return $this->populate($values); } public function populateUpdate($values){ $filter = new Core_FilterValor; $values['saldo_banco'] = $filter->filter($values['saldo_banco']); $values['anterior_saldo_devedor'] = $filter->filter($values['anterior_saldo_devedor']); return $this->populate($values); } public function populate(array $values) { $filter = new Core_FilterValor; $values['valor_bruto'] = number_format($filter->filter($values['valor_bruto']), 2, ',', '.'); $values['valor_liquido'] = number_format($filter->filter($values['valor_liquido']), 2, ',', '.'); $values['valor_prestacao'] = number_format($filter->filter($values['valor_prestacao']), 2, ',', '.'); $values['saldo_banco'] = number_format($filter->filter($values['saldo_banco']), 2, ',', '.'); $values['valor_reducao'] = number_format($filter->filter($values['valor_reducao']), 2, ',', '.'); $values['valor_beneficio'] = number_format($filter->filter($values['valor_beneficio']), 2, ',', '.'); $values['renda'] = number_format($filter->filter($values['renda']), 2, ',', '.'); $values['data_emissao'] = !empty($values['data_emissao']) && $values['data_emissao'] != '0000-00-00' ? date('d/m/Y', strtotime($values['data_emissao'])) : ''; $values['data_nascimento'] = !empty($values['data_nascimento']) && $values['data_nascimento'] != '0000-00-00' ? date('d/m/Y', strtotime($values['data_nascimento'])) : ''; $values['data_expedicao'] = !empty($values['data_expedicao']) && $values['data_expedicao'] != '0000-00-00' ? date('d/m/Y', strtotime($values['data_expedicao'])) : ''; $values['data_agendamento_proposta'] = !empty($values['data_agendamento_proposta']) && $values['data_agendamento_proposta'] != '0000-00-00' ? date('d/m/Y', strtotime($values['data_agendamento_proposta'])) : ''; $ns = new Zend_Session_Namespace(); $identity = Yuppie_Auth::getIdentity(); if(!empty($values['status']) && $values['status'] == 3){ $this->removeElement('btn_efetivar'); if($ns->acl->isAllowed($identity->grupo, 'visualizar-motivo-anti-fraude')){ $alert = new Zend_Controller_Action_Helper_FlashMessenger(); $alert->addMessage(array('error' => "Proposta recusada na esteira anti-fraude. Motivo: {$values['descricao_pendencia']}")); } } if( !empty($values['banco_id']) && !empty($values['tipo']) && $this->getElement('produto') != null ){ $this->getElement('produto') ->addMultiOptions(Core_Combos::getProdutosOptions($values)); } if( !empty($values['banco_id']) && !empty($values['convenio_id']) && $this->getElement('tabela_id') != null ){ $this->getElement('tabela_id') ->addMultiOptions(Core_Combos::getTabelasOptions($values['convenio_id'], $values['banco_id'])); } $this->_criaCamposReducao($values); return parent::populate($values); } public function isValid($data) { $config = new Zend_Config_Ini(CLIENT_PATH . '/configs/application.ini', APPLICATION_ENV); if ($data['tipo'] == "PORTABILIDADE" && is_object($config->yuppie) && $config->yuppie->campos_obrigatorios_portabilidade) { $this->getElement('anterior_banco')->setRequired(); $this->getElement('anterior_prazo')->setRequired(); $this->getElement('anterior_parcelas_restantes')->setRequired(); $this->getElement('anterior_saldo_devedor')->setRequired(); $this->getElement('anterior_numero')->setRequired(); $this->getElement('anterior_valor_parcela')->setRequired(); $this->getElement('celular')->setRequired(); $this->getElement('forma_liberacao')->setRequired(); $this->getElement('banco_beneficiado')->setRequired(); $this->getElement('agencia_beneficiado')->setRequired(); $this->getElement('conta_beneficiado')->setRequired(); $this->getElement('numero_beneficio')->setRequired(); $this->getElement('especie')->setRequired(); } $this->_criaCamposReducao($data); return parent::isValid($data); } public function _pintarCamposObrigatorios() { foreach ( $this->getElements() as $element ) { if( $element->isRequired() ){ $class = $element->getAttrib('class'); $element->setAttrib("class", $class . ' camp_required'); } } } public function _editElements() { $this->getElement('btn_back')->setAttrib('onclick', "window.close()"); $this->removeElement('btn_save'); $this->removeElement('btn_new'); $this->removeElement('btn_efetivar'); $this->removeElement('btn_analise_fraude'); } protected function _criaCamposReducao($values) { if ($values['tipo'] == "REDUCAO DE PARCELA") { $this->removeElement('valor_reducao'); $this->removeElement('banco_reducao'); $this->getElement('valor_prestacao')->setRequired(); $this->addElement('text', 'valor_reducao', [ 'label' => 'Valor Redução (R$):', 'required' => true, 'onkeypress' => 'mascara(this, mvalor)', 'order' => 15, 'placeholder' => '0,00' ]); $this->addElement('select', 'banco_reducao', [ 'label' => 'Banco Redução:', 'multiOptions' => Core_Combos::getBancosOptions(), 'required' => true, 'order' => 16 ]); $this->getDisplayGroup('dados_liberacao')->addElements([ $this->getElement('valor_reducao'), $this->getElement('banco_reducao') ]); } } }
💾 保存文件
← 返回文件管理器