✏️ 正在编辑: DiarioLancamento.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/forms/DiarioLancamento.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_DiarioLancamento extends Core_Form { public function init() { $this->setName('form_update_lancamento'); $this->setEnctype('multipart/form-data'); $rotasSupervisor = Core_Combos::getRotasSupervisorOptions(); $categorias = Core_Combos::getCategoriasOptions(); $this->addElement(Form_DatePicker::getDatePicker('tipo1_data', 'Data')); $this->addElement('text', 'tipo1_cidade', array( 'label' => 'Cidade:' )); $this->addElement('text', 'tipo1_uf', array( 'label' => 'Uf:', 'maxlength' => 2, 'size' => 3, 'validators' => array( new Validators_Uf() ) )); $this->addElement('text', 'tipo1_km_veiculo', array( 'label' => 'Km do veículo:', )); $this->addElement('text', 'tipo1_valor', array( 'label' => 'Valor Abastecimento:', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)', )); $select = new Zend_Form_Element_Select('tipo1_categoria'); $select->setLabel('Categoria:') ->addMultiOptions($categorias); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo1_rota'); $select->setLabel('Rota:') ->addMultiOptions($rotasSupervisor); $this->addElement($select); $file = new Zend_Form_Element_File('tipo1_anexo'); $file->setLabel('Anexar Arquivo:') ->setValueDisabled(true); $file->addValidator('Size', false, '2MB'); $this->addElement($file); $this->addDisplayGroup(array('tipo1_data', 'tipo1_cidade', 'tipo1_uf', 'tipo1_km_veiculo', 'tipo1_valor','tipo1_categoria', 'tipo1_rota', 'tipo1_anexo'), 'dados_combustivel', array('legend' => 'Combustível')); //Hospedagem $this->addElement(Form_DatePicker::getDatePicker('tipo2_data', 'Data')); $this->addElement('text', 'tipo2_cidade', array( 'label' => 'Cidade:' )); $this->addElement('text', 'tipo2_uf', array( 'label' => 'Uf:', 'maxlength' => 2, 'size' => 3, 'validators' => array( new Validators_Uf() ) )); $this->addElement('text', 'tipo2_hospedagem', array( 'label' => 'Hotel/Pousada:', )); $this->addElement('text', 'tipo2_valor', array( 'label' => 'Valor Hospedagem:', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)' )); $select = new Zend_Form_Element_Select('tipo2_categoria'); $select->setLabel('Categoria:') ->addMultiOptions($categorias); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo2_rota'); $select->setLabel('Rota:') ->addMultiOptions($rotasSupervisor); $this->addElement($select); $file = new Zend_Form_Element_File('tipo2_anexo'); $file->setLabel('Anexar Arquivo:') ->setValueDisabled(true); $file->addValidator('Size', false, '2MB'); $this->addElement($file); $this->addDisplayGroup(array('tipo2_data', 'tipo2_cidade', 'tipo2_uf', 'tipo2_hospedagem', 'tipo2_valor', 'tipo2_categoria', 'tipo2_rota', 'tipo2_anexo'), 'dados_hospedagem', array('legend' => 'Hospedagem')); //Alimentação $this->addElement(Form_DatePicker::getDatePicker('tipo3_data', 'Data')); $this->addElement('text', 'tipo3_cidade', array( 'label' => 'Cidade:' )); $this->addElement('text', 'tipo3_uf', array( 'label' => 'Uf:', 'maxlength' => 2, 'size' => 3, 'validators' => array( new Validators_Uf() ) )); $this->addElement('select', 'tipo3_refeicao', array( 'label' => 'Refeição:', 'multiOptions' => array( '' => '', '1' => 'Café', '2' => 'Almoço', '3' => 'Jantar' ) )); $this->addElement('text', 'tipo3_valor', array( 'label' => 'Valor Refeição:', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)' )); $select = new Zend_Form_Element_Select('tipo3_categoria'); $select->setLabel('Categoria:') ->addMultiOptions($categorias); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo3_rota'); $select->setLabel('Rota:') ->addMultiOptions($rotasSupervisor); $this->addElement($select); $file = new Zend_Form_Element_File('tipo3_anexo'); $file->setLabel('Anexar Arquivo:') ->setValueDisabled(true); $file->addValidator('Size', false, '2MB'); $this->addElement($file); $this->addDisplayGroup(array('tipo3_data', 'tipo3_cidade', 'tipo3_uf', 'tipo3_refeicao', 'tipo3_valor', 'tipo3_categoria', 'tipo3_rota', 'tipo3_anexo'), 'dados_alimentacao', array('legend' => 'Alimentação')); //Extra $this->addElement(Form_DatePicker::getDatePicker('tipo5_data', 'Data')); $this->addElement('text', 'tipo5_cidade', array( 'label' => 'Cidade:' )); $this->addElement('text', 'tipo5_uf', array( 'label' => 'Uf:', 'maxlength' => 2, 'size' => 3, 'validators' => array( new Validators_Uf() ) )); $this->addElement('text', 'tipo5_valor', array( 'label' => 'Valor', 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)' )); $this->addElement('text', 'tipo5_motivo_gasto', array( 'label' => 'Motivo do gasto' )); $select = new Zend_Form_Element_Select('tipo5_categoria'); $select->setLabel('Categoria:') ->addMultiOptions($categorias); $this->addElement($select); $select = new Zend_Form_Element_Select('tipo5_rota'); $select->setLabel('Rota:') ->addMultiOptions($rotasSupervisor); $this->addElement($select); $file = new Zend_Form_Element_File('tipo5_anexo'); $file->setLabel('Anexar Arquivo:') ->setValueDisabled(true); $file->addValidator('Size', false, '2MB'); $this->addElement($file); $this->addDisplayGroup(array('tipo5_data', 'tipo5_cidade', 'tipo5_uf', 'tipo5_valor', 'tipo5_motivo_gasto', 'tipo5_categoria', 'tipo5_rota', 'tipo5_anexo'), 'dados_extra', array('legend' => 'Extra')); $this->addElement('submit', 'btn_save', array( 'label' => 'Salvar', 'class' => 'bt_save' )); $this->addElement('button', 'btn_back', array( 'label' => 'Fechar janela', 'onclick' => "window.close()" )); $this->addDisplayGroup(array( 'btn_back', 'btn_save'), '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 isValid($data) { // Verifica se existe algum campo preenchido para aquela categoria de lançamento // Se existir todos os campos(menos rota) devem ser obrigatórios. foreach ( $data as $fieldKey => $fieldValue ) { $tipo = explode("_", $fieldKey); if( !empty($fieldValue) ){ foreach ( $data as $k => $v ) { $t = explode("_", $k); if( $tipo[0] == $t[0] && $t[1] != 'rota' && property_exists($this, $k)){ $this->getElement($k)->setRequired(); } } } } return parent::isValid($data); } }
💾 保存文件
← 返回文件管理器