✏️ 正在编辑: Despesa.php
路径:
/srv/systems_dir/yuppiecred-bkp/application/forms/Filtro/Despesa.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_Filtro_Despesa extends Core_Form { public function init() { $this->setMethod('post'); $this->setName('f_filtro_despesas'); $this->setAttrib('autocomplete', 'off'); $select = new Zend_Form_Element_Select('empresa_id'); $select->setLabel('Empresa:') ->addMultiOptions(Core_Combos::getEmpresasOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('categoria_id'); $select->setLabel('Categoria:') ->addMultiOptions(Core_Combos::getCategoriasOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('fornecedor_id'); $select->setLabel('Fornecedor:') ->addMultiOptions(Core_Combos::getFornecedoresOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('corretor_id'); $select->setLabel('Corretor:') ->addMultiOptions(Core_Combos::getCorretoresOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('funcionario_id'); $select->setLabel('Funcionário:') ->addMultiOptions(Core_Combos::getFuncionariosOptions()); $this->addElement($select); $select = new Zend_Form_Element_select('supervisor_id'); $select->setLabel('Supervisor:') ->addMultiOptions(Core_Combos::getSupervisoresOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('rota_id'); $select->setLabel('Rota:') ->addMultiOptions(Core_Combos::getRotasOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('setor'); $select->setLabel('Setor:') ->addMultiOptions(Core_Combos::getSetoresOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('subsetor'); $select->setLabel('Subsetor:') ->addMultiOptions(Core_Combos::getSubSetoresOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('conta_id'); $select->setLabel('Conta') ->addMultiOptions(Core_Combos::getContasOptions()); $this->addElement($select); $select = new Zend_Form_Element_Select('forma_pagamento'); $select->setLabel('Forma Pagto.:') ->addMultiOptions(Core_Combos::getFormasPagamentoOptions()); $this->addElement($select); $this->addElement('text', 'descricao', array( 'label' => 'Descrição:' )); $this->addElement(Form_DatePicker::getDatePicker('vencimento_de', 'Vencimento de:')); $this->addElement(Form_DatePicker::getDatePicker('vencimento_a', 'a:')); $this->addElementWith('competencia', $this->getOptions('Competencia:', 7, 7, 'mascara(this, mesAno)')); $this->addElement(Form_DatePicker::getDatePicker('pagamento_de', 'Pagamento de:')); $this->addElement(Form_DatePicker::getDatePicker('pagamento_a', 'a:')); $select = new Zend_Form_Element_Select('situacao'); $select->setLabel('Situação:') ->addMultiOptions(Core_Combos::getSituacoesOptions()); $this->addElement($select); $this->addElement('text', 'lancamento_id', array( 'label' => 'ID:', 'onkeypress' => 'mascara(this, soNumeros)', 'validators' => [new Zend_Validate_Digits()] )); $this->_setDefaultDecorators(); $this->_initButtons(); } protected function _initButtons() { $this->addElement('submit', 'btn_filtrar', [ 'label' => 'Buscar', 'class' => 'bt_find' ]); $this->addElement('submit', 'btn_export', [ 'label' => 'Exportar', 'class' => 'bt_excel' ]); $this->addElement('button', 'btn_new', [ 'label' => 'Novo Cadastro', 'class' => 'bt_new', 'onclick' => "window.location='" . $this->getView()->baseUrl() . "/despesa/add'" ]); $this->addDisplayGroup(['btn_filtrar', 'btn_new', 'btn_export'], 'buttons'); } protected function _setDefaultDecorators() { $this->setDecorators( array( 'FormElements', array( 'HtmlTag', array( 'tag' => 'dl', 'class' => 'f_relatorio_despesa' ) ), 'Form' )); } public function isValid($data) { if( !empty($data['vencimento_de']) && !empty($data['vencimento_a']) ){ //calcular diferença e não deixar maior que 30 dias $dt1 = new Zend_Date($data['vencimento_de']); $dt2 = new Zend_Date($data['vencimento_a']); $diff = $dt2->sub($dt1)->toValue(); $days = ceil($diff/60/60/24) +1; if( $days > 31 ){ $this->getElement('vencimento_de') ->addError('O intervalo não pode ser superior a 30 dias'); return false; } } if( !empty($data['pagamento_de']) && !empty($data['pagamento_a']) ){ //calcular diferença e não deixar maior que 30 dias $dt1 = new Zend_Date($data['pagamento_de']); $dt2 = new Zend_Date($data['pagamento_a']); $diff = $dt2->sub($dt1)->toValue(); $days = ceil($diff/60/60/24) +1; if( $days > 31 ){ $this->getElement('pagamento_de') ->addError('O intervalo não pode ser superior a 30 dias'); return false; } } return parent::isValid($data); } }
💾 保存文件
← 返回文件管理器