✏️ 正在编辑: CadastrarUsuariosApi.php
路径:
/srv/systems_dir/yuppiecred/application/forms/CadastrarUsuariosApi.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_CadastrarUsuariosApi extends Core_Form { const IGNORE_COLUMNS = [ 'id', 'api', 'tipo', 'data_cadastro', 'auto_contratacao', 'importacao', 'importado_arquivo', 'ativo', 'data_utilizacao', 'excluido' ]; const API_KEY = [ "DAYCOVAL", "BEVICRED" ]; const CLIENT_ID = [ "V8", ]; const PROVIDER = [ "V8", ]; const PLAYER = [ "VCTEX", ]; protected $_id; public function __construct($id = null) { if ($id > 0 ) { $this->_id = $id; } parent::__construct(); } public function init() { $this->setName('f_save_usuarios_api'); $this->setMethod('post'); $this->setAttrib('class', 'form-usuarios-api'); $this->addElement('hidden', 'id', [ 'class' => 'invisivel' ]); $listaApis = Core_Combos::getListaApis(); $select = new Zend_Form_Element_Select('api'); $select->setLabel('API:') ->setRequired(true) ->setAttrib('style', 'width: 200px;') ->addMultiOptions($listaApis); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo'); $select->setLabel('Tipo:') ->setRequired(true) ->addMultiOptions([ 'API-WS' => 'API/WS', 'PAN(Webmail)' => 'PAN (Webmail)' ]) ->setAttrib('onchange', 'setCamposUsuariosApi(this)'); $this->addElement($select); $this->addElement('checkbox', 'auto_contratacao', [ 'label' => 'Auto Contratação:', 'description' => '(FGTS, INSS, Siape, Cartão Benefício, Credcesta)', 'value' => true ]); $this->addElement('checkbox', 'importacao', [ 'label' => 'Importação:', 'description' => '(Produção, Comissão, Status)', 'value' => true ]); $this->addDisplayGroup(['auto_contratacao', 'importacao'], 'checks', [ 'legend' => 'Recursos', 'decorators' => [ 'FormElements', 'Fieldset', ['HtmlTag', ['style' => 'width:100%']] ] ] ); if ($this->_id > 0) { $this->adicionarCampos(); $model = new Model_UsuariosApi(); $dados = $model->exibir($this->_id); } $this->addElement('button', 'btn_back', [ 'label' => 'Voltar', 'class' => 'bt_back', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/sincronizacao/dados-sincronizacao'" ]); $this->addElement('submit', 'btn_salvar', [ 'label' => 'Salvar', 'class' => 'bt_save' ]); $this->addElement('button', 'btn_new', [ 'label' => 'Novo Cadastro', 'class' => 'bt_new', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/sincronizacao/cadastrar-usuarios-api'" ]); if ($this->_id > 0 && empty($dados['ativo'])) { $this->addElement('button', 'btn_ativar', [ 'label' => 'Reativar usuário', 'class' => 'bt_apply', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/sincronizacao/ativar-usuarios-api/id/{$dados['id']}'" ]); } $this->addDisplayGroup(['btn_back', 'btn_salvar', 'btn_new', 'btn_ativar'], 'buttons'); $this->addElement('hidden', 'importado_arquivo', [ 'class' => 'invisivel' ]); } public function adicionarCampos() { $model = new Model_UsuariosApi(); $dados = $model->exibir($this->_id)->toArray(); $dados = array_filter($dados); $fields = []; foreach ($dados as $key => $campo) { if (in_array($key, self::IGNORE_COLUMNS)) { continue; } $type = 'text'; $label = ucfirst(str_replace('_', ' ', $key)); if (in_array($dados['api'], self::API_KEY) && $key == "senha") { $label = "APIKey"; } elseif ($dados['api'] == "BONSUCESSO") { if ($key == "usuario") { $label = "Olé Key"; } if ($key == "senha") { $label = "Dev Key"; } } if (in_array($dados['api'], self::CLIENT_ID) && $key == "senha_consig") { $label = "Client Id"; $size = 45; } if (in_array($dados['api'], self::PROVIDER) && $key == "usuario_consig") { $type = 'select'; $label = "Provider"; $options = Core_Combos::providersV8(); } if (in_array($dados['api'], self::PLAYER) && $key == "usuario_consig") { $type = 'select'; $label = "Player"; $options = Core_Combos::playersVCTex(); } $params = [ 'label' => $label . ':', 'class' => 'not_upper', 'size' => $size ?: '', 'multiOptions' => $options ?: '', ]; if (stristr($key, 'cpf')) { $params = array_merge($params, ['onkeypress' => 'mascara(this, fcpf)', 'maxlength' => 14]); } // if (stristr($key, 'senha')) { // $type = 'password'; // $params = array_merge($params, ['renderPassword' => 'true']); // } if (stristr($key, 'codigo') || $key == 'canal_venda') { $params = array_merge($params, ['onkeypress' => 'mascara(this, soNumeros)']); } if (stristr($key, 'chave')) { $type = 'textarea'; $params = array_merge($params, ['rows' => 5, 'cols' => 50]); } $this->addElement($type, $key, $params); if (stristr($key, 'chave')) { $this->getElement($key)->addDecorator('Label', ['tag' => 'dt', 'tagClass' => 'clear']); } $fields = array_merge($fields, [$key]); } if (!empty($fields)) { $this->addDisplayGroup($fields, 'fields', [ 'legend' => 'Dados de acesso', 'decorators' => [ 'FormElements', 'FieldSet', ['HtmlTag', ['style' => 'width:100%']] ] ] ); } } }
💾 保存文件
← 返回文件管理器