/** * @see CoreExt_Entity_Validatable#getDefaultValidatorCollection() */ public function getDefaultValidatorCollection() { // Enums $tipoNotaValor = RegraAvaliacao_Model_Nota_TipoValor::getInstance(); $tipoProgressao = RegraAvaliacao_Model_TipoProgressao::getInstance(); $tipoParecerDescritivo = RegraAvaliacao_Model_TipoParecerDescritivo::getInstance(); $tipoPresenca = RegraAvaliacao_Model_TipoPresenca::getInstance(); // ids de fórmulas de média $formulaMedia = $this->getDataMapper()->findFormulaMediaFinal(); $formulaMedia = CoreExt_Entity::entityFilterAttr($formulaMedia, 'id'); // ids de fórmulas de recuperação $formulaRecuperacao = $this->getDataMapper()->findFormulaMediaRecuperacao(); $formulaRecuperacao = CoreExt_Entity::entityFilterAttr($formulaRecuperacao, 'id'); $formulaRecuperacao[0] = NULL; // ids de tabelas de arredondamento $tabelas = $this->getDataMapper()->findTabelaArredondamento($this); $tabelas = CoreExt_Entity::entityFilterAttr($tabelas, 'id'); // Instituições $instituicoes = array_keys(App_Model_IedFinder::getInstituicoes()); // Fórmula de média é obrigatória? $isFormulaMediaRequired = TRUE; // Média é obrigatória? $isMediaRequired = TRUE; if ($this->get('tipoNota') == RegraAvaliacao_Model_Nota_TipoValor::NENHUM) { $isFormulaMediaRequired = FALSE; $isMediaRequired = FALSE; // Aceita somente o valor NULL quando o tipo de nota é Nenhum. $formulaMedia = $formulaMedia + array(NULL); } return array('instituicao' => new CoreExt_Validate_Choice(array('choices' => $instituicoes)), 'nome' => new CoreExt_Validate_String(array('min' => 5, 'max' => 50)), 'formulaMedia' => new CoreExt_Validate_Choice(array('choices' => $formulaMedia, 'required' => $isFormulaMediaRequired)), 'formulaRecuperacao' => new CoreExt_Validate_Choice(array('choices' => $formulaRecuperacao, 'required' => FALSE)), 'tipoNota' => new CoreExt_Validate_Choice(array('choices' => $tipoNotaValor->getKeys())), 'tipoProgressao' => new CoreExt_Validate_Choice(array('choices' => $tipoProgressao->getKeys())), 'tabelaArredondamento' => new CoreExt_Validate_Choice(array('choices' => $tabelas, 'choice_error' => 'A tabela de arredondamento selecionada não ' . 'corresponde ao sistema de nota escolhido.')), 'parecerDescritivo' => new CoreExt_Validate_Choice(array('choices' => $tipoParecerDescritivo->getKeys())), 'tipoPresenca' => new CoreExt_Validate_Choice(array('choices' => $tipoPresenca->getKeys())), 'media' => $this->validateIfEquals('tipoProgressao', RegraAvaliacao_Model_TipoProgressao::CONTINUADA, 'CoreExt_Validate_Numeric', array('required' => $isMediaRequired, 'min' => 1, 'max' => 10), array('required' => $isMediaRequired, 'min' => 0, 'max' => 10)), 'porcentagemPresenca' => new CoreExt_Validate_Numeric(array('min' => 1, 'max' => 100)), 'mediaRecuperacao' => $this->validateIfEquals('tipoProgressao', RegraAvaliacao_Model_TipoProgressao::CONTINUADA, 'CoreExt_Validate_Numeric', array('required' => $isMediaRequired, 'min' => 1, 'max' => 14), array('required' => $isMediaRequired, 'min' => 0, 'max' => 14))); }
/** * @see clsCadastro#Gerar() */ public function Gerar() { $this->campoOculto('id', $this->getEntity()->id); // Instituição $instituicoes = App_Model_IedFinder::getInstituicoes(); $this->campoLista('instituicao', $this->_getLabel('instituicao'), $instituicoes, $this->getEntity()->instituicao); // Nome $this->campoTexto('nome', $this->_getLabel('nome'), $this->getEntity()->nome, 50, 50, TRUE, FALSE, FALSE, $this->_getHelp('nome')); // Nota tipo valor $notaTipoValor = RegraAvaliacao_Model_Nota_TipoValor::getInstance(); $this->campoRadio('tipoNota', $this->_getLabel('tipoNota'), $notaTipoValor->getEnums(), $this->getEntity()->get('tipoNota'), '', $this->_getHelp('tipoNota')); // Tabela de arredondamento $tabelaArredondamento = $this->getDataMapper()->findTabelaArredondamento($this->getEntity()); $tabelaArredondamento = CoreExt_Entity::entityFilterAttr($tabelaArredondamento, 'id', 'nome'); if (empty($tabelaArredondamento)) { $tabelaArredondamento = array(0 => 'O tipo de nota não possui tabela de arredondamento.'); } $this->campoLista('tabelaArredondamento', $this->_getLabel('tabelaArredondamento'), $tabelaArredondamento, $this->getEntity()->get('tabelaArredondamento'), '', FALSE, $this->_getHelp('tabelaArredondamento'), '', FALSE, FALSE); // Tipo progressão $tipoProgressao = RegraAvaliacao_Model_TipoProgressao::getInstance(); $this->campoRadio('tipoProgressao', $this->_getLabel('tipoProgressao'), $tipoProgressao->getEnums(), $this->getEntity()->get('tipoProgressao'), '', $this->_getHelp('tipoProgressao')); // Média $this->campoTexto('media', $this->_getLabel('media'), $this->getEntity()->media, 5, 50, FALSE, FALSE, FALSE, $this->_getHelp('media')); $this->campoTexto('mediaRecuperacao', $this->_getLabel('mediaRecuperacao'), $this->getEntity()->mediaRecuperacao, 5, 50, FALSE, FALSE, FALSE, $this->_getHelp('mediaRecuperacao')); // Cálculo média $formulas = $this->getDataMapper()->findFormulaMediaFinal(); $formulas = CoreExt_Entity::entityFilterAttr($formulas, 'id', 'nome'); $this->campoLista('formulaMedia', $this->_getLabel('formulaMedia'), $formulas, $this->getEntity()->get('formulaMedia'), '', FALSE, $this->_getHelp('formulaMedia'), '', FALSE, FALSE); // Cálculo média recuperação $formulas = $this->getDataMapper()->findFormulaMediaRecuperacao(); $formulasArray = array(0 => 'Não usar recuperação'); $formulasArray = $formulasArray + CoreExt_Entity::entityFilterAttr($formulas, 'id', 'nome'); $this->campoLista('formulaRecuperacao', $this->_getLabel('formulaRecuperacao'), $formulasArray, $this->getEntity()->get('formulaRecuperacao'), '', FALSE, $this->_getHelp('formulaRecuperacao'), '', FALSE, FALSE); // Porcentagem presença $this->campoTexto('porcentagemPresenca', $this->_getLabel('porcentagemPresenca'), $this->getEntity()->porcentagemPresenca, 5, 50, TRUE, FALSE, FALSE, $this->_getHelp('porcentagemPresenca')); // Parecer descritivo $parecerDescritivo = RegraAvaliacao_Model_TipoParecerDescritivo::getInstance(); $this->campoRadio('parecerDescritivo', $this->_getLabel('parecerDescritivo'), $parecerDescritivo->getEnums(), $this->getEntity()->get('parecerDescritivo'), '', $this->_getHelp('parecerDescritivo')); // Presença $tipoPresenca = RegraAvaliacao_Model_TipoPresenca::getInstance(); $this->campoRadio('tipoPresenca', $this->_getLabel('tipoPresenca'), $tipoPresenca->getEnums(), $this->getEntity()->get('tipoPresenca'), '', $this->_getHelp('tipoPresenca')); }
/** * @see CoreExt_Entity_Validatable#getDefaultValidatorCollection() */ public function getDefaultValidatorCollection() { $parecer = RegraAvaliacao_Model_TipoParecerDescritivo::getInstance(); return array('matricula' => new CoreExt_Validate_Numeric(array('min' => 0)), 'parecerDescritivo' => new CoreExt_Validate_Choice(array('choices' => $parecer->getKeys()))); }