✏️ 正在编辑: Usuario.php
路径:
/srv/systems_dir/yuppiecred-lidernegocios/application/forms/Usuario.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_Usuario extends Core_Form { public function init() { $params = $this->_getParams(); $this->setName('f_save_usuario'); $this->addElement('hidden', 'id', array( 'class' => 'invisivel' )); $usuario = Yuppie_Auth::getIdentity(); $whereUser = ""; $grupoCorretor = $usuario->grupo == "Corretor"; if(!empty($params['operador'])){ $whereUser = " AND exibir_operador = 1"; }elseif ($grupoCorretor){ $whereUser = " AND exibir_corretor = 1"; } $select = new Zend_Form_Element_Select('grupo_id'); $select->setLabel('Grupo') ->setRequired(true) ->addMultiOptions(Core_Combos::getGruposUsuariosOptions($whereUser)); $this->addElement($select); $this->addElement('text', 'nome', array( 'label' => 'Nome', 'size' => 35, 'required' => true )); $this->addElement('text', 'login', array( 'label' => 'Login', 'size' => 15, 'required' => true )); $front = Zend_Controller_Front::getInstance(); $this->getElement('login')->addValidator('Db_NoRecordExists', false, array( 'table' => 'vw_usuarios', 'field' => 'login', 'messages' => array( 'recordFound' => 'O login informado já está em uso.' ), 'exclude' => array( 'field' => 'id', 'value' => $front->getRequest()->getParam('id') ) )); $this->addElement('password', 'senha', array( 'label' => 'Senha:', 'size' => 15, )); $whereEmpresa = $grupoCorretor ? array( 'empresa' => $usuario->empresa_id ) : array(); $select = new Zend_Form_Element_Select('empresa_id'); $select->setLabel('Empresa') ->setRequired(true) ->addMultiOptions(Core_Combos::getEmpresasOptions($whereEmpresa)); $this->addElement($select); $this->addElement('text', 'ip', array( 'label' => 'Ip de acesso', 'validators' => array(new Zend_Validate_Ip()), 'size' => 15, )); $select = new Zend_Form_Element_Select('funcionario_id'); $select->setLabel('Vincular funcionario') ->addMultiOptions(Core_Combos::getFuncionariosOptions()); $this->addElement($select); if( !$grupoCorretor ){ $select = new Zend_Form_Element_Select('corretor_id'); $select->setLabel('Corretor') ->addMultiOptions(Core_Combos::getCorretoresOptions(true)); $this->addElement($select); } $this->addElement('text', 'ramal_numero', array( 'label' => 'Número do ramal', 'onkeypress' => 'mascara(this, soNumeros)', )); if (Core_Discador_Factory::load()) { $this->addElement('text', 'discador_id', array( 'label' => 'Código no Discador: ', 'onkeypress' => 'mascara(this, soNumeros)', 'size' => 15, )); } $this->addElement('text', 'email', array( 'label' => 'E-mail', 'size' => 35, 'class' => 'noKeyup', 'validators' => array( 'EmailAddress' ) )); $this->getElement('email')->addDecorator('Label', array( 'tag' => 'dt', 'tagClass' => 'clear' )); $this->addElement('text', 'email_copia', array( 'label' => 'Mensagens Cc para', 'size' => 35, 'class' => 'noKeyup', 'validators' => array( 'EmailAddress' ) )); $this->addElement('checkbox', 'receber_email_copia', array( 'label' => 'Receber cópia', )); $this->addElement('checkbox', 'bater_ponto', array( 'label' => 'Ativar Ponto Eletrônico', )); $this->addElement('text', 'hora_inicio', array( 'label' => 'Horário inicial', 'maxlength' => 5, 'required' => true, 'onkeypress' => 'mascara(this, hora)', 'validators' => array( array( 'Date', false, array( 'format' => 'HH:mm' ) ) ) )); $this->addElement('text', 'hora_fim', array( 'label' => 'Horário final', 'maxlength' => 5, 'required' => true, 'onkeypress' => 'mascara(this, hora)', 'validators' => array( array( 'Date', false, array( 'format' => 'HH:mm' ) ) ) )); $this->addElement('multiCheckbox', 'dias', array( 'label' => 'Dias', 'multiOptions' => array( 'Dom', '2ª', '3ª', '4ª', '5ª', '6ª', 'Sáb' ), 'separator' => ' ', 'required' => true, 'value' => array( 1, 2, 3, 4, 5 ) )); $this->addElement('button', 'btn_back', array( 'label' => 'Voltar', 'class' => 'bt_back', 'onclick' => "window.location='" . $this->_getReferer() . "'" )); $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('usuario/save') . "'" )); $this->addTwoOptionsElement('desativado', 'Desativado', false); $this->displayGroupNotificacoes(); $this->addDisplayGroup(array( 'btn_back', 'btn_save', 'btn_new' ), 'buttons'); } public function populate(array $values) { if( isset($values['dias']) ){ if( $values['dias'] ){ if( is_string($values['dias']) ){ $values['dias'] = explode(',', $values['dias']); } } else { $values['dias'] = null; } } if (!empty($values['assuntos_chamado'])){ $values['assuntos_chamado'] = explode(',', $values['assuntos_chamado']); } if (!empty($values['assuntos_proposta'])){ $values['assuntos_proposta'] = explode(',', $values['assuntos_proposta']); } if (!empty($values['assuntos_simulacao'])){ $values['assuntos_simulacao'] = explode(',', $values['assuntos_simulacao']); } return parent::populate($values); } private function displayGroupNotificacoes() { $this->addElement('multiselect', 'assuntos_chamado', [ 'label' => 'Chamado', 'class' => 'multi_assuntos', 'multiOptions' => array_filter(Core_Combos::getAssuntosChamadosOptions()), 'registerInArrayValidator' => false ]); $this->addElement('multiselect', 'assuntos_proposta', [ 'label' => 'Proposta', 'class' => 'multi_assuntos', 'multiOptions' => array_filter(Core_Combos::getAssuntosPropostasOptions()), 'registerInArrayValidator' => false ]); $this->addElement('multiselect', 'assuntos_simulacao', [ 'label' => 'Simulações', 'class' => 'multi_assuntos', 'multiOptions' => array_filter(Core_Combos::getAssuntosSimulacoesOptions()), 'registerInArrayValidator' => false ]); $this->addDisplayGroup([ 'assuntos_chamado', 'assuntos_proposta', 'assuntos_simulacao' ], 'notificacoes', [ 'legend' => "Notificar por assunto" ]); $group = $this->getDisplayGroup('notificacoes'); $group->removeDecorator('DtDdWrapper'); $group->removeDecorator('HtmlTag'); } }
💾 保存文件
← 返回文件管理器