✏️ 正在编辑: LancarMetasGerente.php
路径:
/srv/systems_dir/yuppiecred/application/forms/LancarMetasGerente.php
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
<?php class Form_LancarMetasGerente extends Core_Form { public function init() { $this->addElement('hidden', 'id', array( 'decorators' => array( 'ViewHelper' ) )); $this->setName('f_lancar_metas'); $select = new Zend_Form_Element_Multiselect('gerente_id'); $select->setAttrib('class', 'corretores_pagar_comissao'); $this->addElement($select); $select = new Zend_Form_Element_Multiselect('banco_id'); $select->setLabel('Banco:') ->addMultiOptions(array_filter(Core_Combos::getBancosOptions())) ->setAttrib('class', 'multiple_banco'); $this->addElement($select); $this->addElement('text', 'metas', array( 'label' => 'Meta:', 'required' => true, 'size' => 10, 'onkeypress' => 'mascara(this, mvalor)' )); $this->getElement('metas')->setAttrib("required", true); $this->addElement(Form_DatePicker::getDatePicker('data_inicial', 'Data inicial:', null, true)); $this->getElement('data_inicial')->setAttrib("required", true); $this->addElement(Form_DatePicker::getDatePicker('data_final', 'Data final:', null, true)); $this->getElement('data_final')->setAttrib("required", true); $this->addElement('submit', 'btn_save', array( 'label' => 'Salvar', 'class' => 'bt_save' )); } public function populate(array $values) { if( isset($values['supervisor_id']) && $values['supervisor_id'] ){ $meta = new Model_GerenteMeta(); $gm = $meta->fetchUltimaMeta($values['supervisor_id']); if( $gm ){ $dataInicial = new Zend_Date($gm->data_final, 'yyyy-MM-dd'); $dataInicial->addDay(1); $values['data_inicial'] = $dataInicial->get('dd/MM/yyyy'); } } if( isset($values['gerente_rota_id']) && $values['gerente_rota_id'] ){ $meta = new Model_GerenteMeta(); $gm = $meta->fetchUltimaMeta($values['gerente_rota_id'], true); if( $gm ){ $dataInicial = new Zend_Date($gm->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( isset($data['data_inicial']) && isset($data['data_final']) && $data['data_inicial'] != null && $data['data_final'] != null ){ $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); } public function addOptions($controller = null){ if($controller == "gerente_rota"){ $this->setAttrib("role", "gerente_rota"); $element = $this->getElement('gerente_id'); $element->setLabel('Supervisor:'); $element->addMultiOptions(array_filter(Core_Combos::getSupervisoresOptions())); }else{ $this->setAttrib("role", "gerente"); $element = $this->getElement('gerente_id'); $element->setLabel('Gerente:'); $element->addMultiOptions(array_filter(Core_Combos::getGerentesOptions())); } } }
💾 保存文件
← 返回文件管理器