/** * @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 CoreExt_Entity_Validatable#getDefaultValidatorCollection() */ public function getDefaultValidatorCollection() { $instituicoes = array_keys(App_Model_IedFinder::getInstituicoes()); // Tipo nota $tipoNota = RegraAvaliacao_Model_Nota_TipoValor::getInstance(); $tipoNotas = $tipoNota->getKeys(); // Remove "nenhum" das opções. unset($tipoNotas[RegraAvaliacao_Model_Nota_TipoValor::NENHUM]); return array('instituicao' => new CoreExt_Validate_Choice(array('choices' => $instituicoes)), 'nome' => new CoreExt_Validate_String(array('min' => 5, 'max' => 50)), 'tipoNota' => new CoreExt_Validate_Choice(array('choices' => $tipoNotas))); }
/** * @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 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, 40, 50, TRUE, FALSE, FALSE, $this->_getHelp('nome')); // Tipo de nota $notaTipoValor = RegraAvaliacao_Model_Nota_TipoValor::getInstance(); $notaTipos = $notaTipoValor->getEnums(); unset($notaTipos[RegraAvaliacao_Model_Nota_TipoValor::NENHUM]); if ($this->getEntity()->id != '') { $this->campoTexto('tipNota', $this->_getLabel('tipoNota'), $notaTipos[$this->getEntity()->get('tipoNota')], 40, 40, false, false, false, '', '', '', '', true); } else { $this->campoRadio('tipoNota', $this->_getLabel('tipoNota'), $notaTipos, $this->getEntity()->get('tipoNota'), '', $this->_getHelp('tipoNota')); } // Parte condicional if (!$this->getEntity()->isNew()) { // Quebra $this->campoQuebra(); // Ajuda $help = 'Caso seja necessário adicionar mais notas, ' . 'salve o formulário. Automaticamente 3 campos ' . 'novos ficarão disponíveis.<br /><br />'; $this->campoRotulo('__help1', '<strong>Notas para arredondamento</strong><br />', $help, FALSE, '', ''); // Cria campos para a postagem de notas $valores = $this->getDataMapper()->findTabelaValor($this->getEntity()); for ($i = 0, $loop = count($valores); $i < ($loop == 0 ? 5 : $loop + 3); $i++) { $valorNota = $valores[$i]; $valor_label = sprintf("valor[label][%d]", $i); $valor_id = sprintf("valor[id][%d]", $i); $valor_nome = sprintf("valor[nome][%d]", $i); $valor_descricao = sprintf("valor[descricao][%d]", $i); $valor_valor_minimo = sprintf("valor[valor_minimo][%d]", $i); $valor_valor_maximo = sprintf("valor[valor_maximo][%d]", $i); $this->campoRotulo($valor_label, 'Arredondamento ' . ($i + 1), $this->_getLabel(''), TRUE); // Id $this->campoOculto($valor_id, $valorNota->id); // Nome $this->campoTexto($valor_nome, $this->_getLabel('valor_nome'), $valorNota->nome, 5, 5, FALSE, FALSE, TRUE, $this->_getHelp('valor_nome')); // Descrição (se conceitual) if (RegraAvaliacao_Model_Nota_TipoValor::CONCEITUAL == $this->getEntity()->get('tipoNota')) { $this->campoTexto($valor_descricao, $this->_getLabel('valor_descricao'), $valorNota->descricao, 15, 25, FALSE, FALSE, TRUE, $this->_getHelp('valor_descricao')); } // Valor mínimo $this->campoTexto($valor_valor_minimo, $this->_getLabel('valor_valor_minimo'), $valorNota->valorMinimo, 6, 6, FALSE, FALSE, TRUE, $this->_getHelp('valor_valor_minimo')); // Valor máximo $this->campoTexto($valor_valor_maximo, $this->_getLabel('valor_valor_maximo'), $valorNota->valorMaximo, 6, 6, FALSE, FALSE, FALSE, $this->_getHelp('valor_valor_maximo')); } // Quebra $this->campoQuebra(); } }