✏️ 正在编辑: GerenteMeta.php
路径:
/srv/systems_dir/yuppiecred/application/forms/GerenteMeta.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_GerenteMeta extends Core_Form { public function init() { $this->setName('f_save_meta'); $this->addElement('hidden', 'id', array( 'decorators' => array( 'ViewHelper' ) )); $this->addElement('hidden', 'gerente_id', array( 'decorators' => array( 'ViewHelper' ) )); $this->addElement('hidden', 'gerente_rota_id', array( 'decorators' => array( 'ViewHelper' ) )); $this->addElement(Form_DatePicker::getDatePicker('data_inicial', 'Data inicial:', null, true)); $this->addElement(Form_DatePicker::getDatePicker('data_final', 'Data final:', null, true)); $this->getElement('data_inicial')->setAttrib("required", true); $this->getElement('data_final')->setAttrib("required", true); $select = new Zend_Form_Element_Select('banco_id'); $select->setLabel('Banco:') ->addMultiOptions(Core_Combos::getBancosOptions()); $this->addElement($select); $this->addElement('text', 'meta', array( 'label' => 'Meta:', 'required' => true, 'size' => 18, 'onkeypress' => 'mascara(this, mvalor)' )); $this->getElement('meta')->setAttrib("required", true); $this->addElement('submit', 'btn_save', array( 'label' => 'Salvar', 'class' => 'bt_save' )); } public function populate(array $values) { $meta = new Model_GerenteMeta(); if( !empty($values['gerente_id']) ){ $ultimaMeta = $meta->fetchUltimaMeta($values['gerente_id']); } if( !empty($values['gerente_rota_id']) ){ $ultimaMeta = $meta->fetchUltimaMeta($values['gerente_rota_id'], true); } if( !empty($ultimaMeta) ){ $dataInicial = new Zend_Date($ultimaMeta->data_final, 'yyyy-MM-dd'); $dataInicial->addDay(1); $values['data_inicial'] = $dataInicial->get('dd/MM/yyyy'); } return parent::populate($values); } public function isValid($data) { if( !empty($data['data_inicial']) && !empty($data['data_final']) ){ $dataInicial = new Zend_Date($data['data_inicial']); $dataFinal = new Zend_Date($data['data_final']); if( $dataInicial != $dataFinal ){ if( $dataFinal->isEarlier($dataInicial) ){ throw new Exception("Período inválido."); } } } return parent::isValid($data); } }
💾 保存文件
← 返回文件管理器