Ejemplo n.º 1
0
 public function updateAnswer($answerId, $data, $alternativeRow)
 {
     DbTable_AnswerVerificador::getInstance()->getAdapter()->beginTransaction();
     try {
         $qstnId = $data['qstn_id'];
         $aaresult_value = $data['aaresult_value'];
         $answerRow = $this->getAnswerById($answerId);
         $alternativeIdOld = $answerRow->getAlternativeId();
         $data = $this->_filterInputAnswer($data)->getUnescaped();
         $data['aaresult_value'] = $aaresult_value;
         $answerRow->setAlternativeId($data['alternative_id'])->setAnswerValue($data['answer_value'])->setStartTime($data['start_time'])->setEndTime($data['end_time'])->setAnswerDate($data['answer_date']);
         $answerRow->save();
         $AnswerHistory = new Model_AnswerHistoryVerificador();
         $AnswerHistory->createAnswerHistory(array('user_id' => $data['logged_user_id'], 'answer_id' => $answerRow->getId(), 'alternative_id' => $answerRow->getAlternativeId(), 'answer_value' => $answerRow->getAnswerValue(), 'start_time' => $answerRow->getStartTime(), 'end_time' => $answerRow->getEndTime(), 'answer_date' => $answerRow->getAnswerDate(), 'enterprise_id' => $answerRow->getEnterpriseId()));
         $this->deleteOldAnswerAnnualResult($answerRow, $alternativeIdOld);
         if ($alternativeRow->getAlternativeTypeId() == Model_AlternativeType::RESULT_ACTION) {
             $this->saveAnswerAnnualResult($answerRow, $data, $alternativeIdOld);
         }
         $userLogged = Zend_Auth::getInstance()->getIdentity();
         $permissionEvaluationOfResponse = $this->Acl->isAllowed($userLogged->getRole(), 'management:questionnaire', 'evaluation-of-response');
         $Execution = new Model_Execution();
         $Execution->cleanDevolutive($qstnId, $data['user_id'], $permissionEvaluationOfResponse);
         DbTable_AnswerVerificador::getInstance()->getAdapter()->commit();
         return array('status' => true, 'row' => $answerRow);
     } catch (Vtx_UserException $e) {
         DbTable_AnswerVerificador::getInstance()->getAdapter()->rollBack();
         return array('status' => false, 'messageError' => $e->getMessage());
     } catch (Exception $e) {
         DbTable_AnswerVerificador::getInstance()->getAdapter()->rollBack();
         throw new Exception($e);
     }
 }
Ejemplo n.º 2
0
 /**
  * 
  * // case 1 = Tipo do questionario diagnostico.
  */
 public function initTipo()
 {
     $this->execution->finishExecution($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId(), $this->devolutive->getArqPath(), null, $this->devolutive->getIsRA());
     $this->eligibility->doAutoavaliacaoEligibility($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId());
     $result = $this->devolutive->makePdfDevolutiveAllBlocks($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId(), $this->devolutive->getDirName(), $this->devolutive->getPublicDir(), $this->devolutive->getArqName(), $this->devolutive->getIsRA());
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * 
  * // case 2 = Tipo do questionario autoavaliacao.
  */
 public function initTipo()
 {
     // case 2 = Tipo do questionario autoavaliacao.
     $result = false;
     $arrScore = $this->devolutive->makeScoreRAA($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId());
     if ($arrScore) {
         //grava dados em Execution
         $this->execution->finishExecution($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId(), $this->devolutive->getArqPath(), $arrScore[2], $this->devolutive->getIsRA());
         //faz geracao do pdf
         $result = $this->devolutive->makePdfDevolutiveAutoAvaliacao($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId(), $this->devolutive->getDirName(), $this->devolutive->getPublicDir(), $this->devolutive->getArqName(), $this->devolutive->getIsRA());
     }
     //end if
     return $result;
 }
Ejemplo n.º 4
0
 private function createPendingCandidatureWarningEmails()
 {
     $Execution = new Model_Execution();
     $Enterprise = new Model_Enterprise();
     $executions = $Execution->getPendingExecutionsByProgramaId($this->competitionId);
     foreach ($executions as $execution) {
         $enterprise = $Enterprise->getEnterpriseByUserId($execution->getUserId());
         $email = $enterprise->getEmailDefault();
         $config = $this->pendingCandidatureWarningEmailConfigurations($execution->getUserId());
         if ($email and $email != '') {
             $recipients = array(array('Address' => $email));
             $this->EmailMessage->createWithRecipients($config['Context'], $config['SenderName'], $config['SenderAddress'], $config['Subject'], $config['Body'], $recipients);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * Devolutiva PSMN
  * 
  * DevolutiveCalcId 3 => Tipo de questionario PSMN
  *  
  * Tipo 3 foi baseado no questionario autoavaliacao (tipo 2).
  */
 public function initTipo()
 {
     $result = false;
     //cria diretorio no filesystem, para gravar pdf
     $this->makepdf->preparaFileSystemParaDevolutiva();
     //regra desnecessaria para geracao devolutiva de PSMN
     //$arrScore = $this->devolutive->makeScoreRAA( $this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId() );
     //if ( $arrScore ) {
     //grava dados em Execution
     $this->execution->finishExecution($this->devolutive->getQuestionnaireId(), $this->devolutive->getUserId(), $this->devolutive->getArqPath(), null, $this->devolutive->getIsRA());
     //faz geracao do pdf
     $result = true;
     $result = $this->makePdfDevolutivePSMN();
     return $result;
 }
Ejemplo n.º 6
0
 public function indexAction()
 {
     //Definicao de que CompetitionId é o mesmo que programaId para PSMN
     //19/06/2013: Everton, thiago, Marco
     $programaId = $this->competitionId;
     $enterpriseId = $this->modelUserLocality->getUserLocalityByUserId($this->enterpriseUserId)->getEnterpriseId();
     $hasECAC = $this->modelECAC->hasECAC($enterpriseId, $this->competitionId);
     if (!$hasECAC) {
         throw new Exception('access denied');
         return;
     }
     $this->view->subscriptionPeriodIsClosed = !$this->subscriptionPeriodIsOpen();
     $this->view->currentBlockIdNegocios = Zend_Registry::get('configDb')->qstn->currentBlockIdNegocios;
     $this->view->currentBlockIdEmpreendedorismo = Zend_Registry::get('configDb')->qstn->currentBlockIdEmpreendedorismo;
     $blockId = $this->_getParam('block', $this->view->currentBlockIdNegocios);
     /*
        Caso tente respnder um questionário, que não seja o atual.
     */
     if ($blockId != $this->view->currentBlockIdNegocios) {
         throw new Exception('access denied');
         return;
     }
     $this->view->qstnCurrent = $this->Questionnaire->getCurrentExecution();
     if (!$this->view->qstnCurrent) {
         throw new Exception('Nenhum questionário ativo.');
     }
     /* @TODO verificar se o bloco passado pertence ao questionário corrente que tem q ser pego por config */
     //$this->view->blockQuestions = $this->Block->getQuestionsByBlockIdForView($blockId);
     //recupera do CACHE ou MODEL
     $this->view->blockQuestions = $this->Block->cacheOrModelBlockById($blockId);
     //var_dump('blockQuestions: ',$this->view->blockQuestions);
     //echo "<br><br>";
     $this->view->blockCurrent = $this->Block->getDbTable()->find($blockId)->current();
     $this->view->qstnRespondId = $this->view->qstnCurrent->getId();
     $this->view->papelEmpresa = $this->userLogged->getRoleId() == Zend_Registry::get('config')->acl->roleEnterpriseId ? 'true' : 'false';
     $this->view->user_id = $this->enterpriseUserId;
     $this->view->enterpriseIdKey = $this->enterpriseIdKey;
     //$enterpriseId = $this->Enterprise->getEnterpriseByUserId($this->enterpriseUserId)->getId();
     /*if (!$this->Questionnaire->verifyQuestionnaireEligibility($this->view->qstnRespondId, $enterpriseId)) {
           
           $this->view->messageError = "Você não possui elegibilidade para o questionário escolhido.";
           return;
       }
        * 
        */
     /* Caso geração de devolitiva, redireciona */
     if ($this->_getParam('geraDevolutiva')) {
         if ($this->_getParam('menu-admin')) {
             $this->view->isViewAdmin = true;
             $this->_helper->_layout->setLayout('new-qstn');
         }
         //regerar devolutiva
         $regerar = $this->_getParam('regerar');
         if ($regerar) {
             //exclui o link da ultima devolutiva gerada
             $modelExec = new Model_Execution();
             $execution = $modelExec->getExecutionByUserAndPrograma($this->enterpriseUserId, $programaId);
             $execution->setDevolutivePath(null);
             $execution->save();
         }
         $this->view->questionnaireId = $this->view->qstnRespondId;
         $this->view->enterpriseUserId = $this->enterpriseUserId;
         $this->renderScript('devolutive/index.phtml');
         //$this->_forward('index', 'devolutive', 'questionnaire', array('geraDevolutiva'=>1));
         return;
     }
     //Retirar depois
     /*if (!$this->Questionnaire->verifyQuestionnaireRolePeriod($this->view->qstnRespondId,$this->userLogged->getRoleId())) {
           $this->view->messageError = "Você não possui permissão de acesso para o questionário escolhido.";
           return;
       }
        * 
        */
     $this->view->answeredByUserId = $this->Questionnaire->getQuestionsAnsweredByUserId($this->view->qstnRespondId, $this->enterpriseUserId, $blockId);
     $this->view->periodoRespostas = true;
     if (!$this->Questionnaire->isQuestionnaireExecution($this->view->qstnRespondId)) {
         $this->view->periodoRespostas = false;
         $this->view->messageError = "Período de resposta do questionário inválido.";
         return;
     }
     $UserLocality = new Model_UserLocality();
     $this->view->enterpriseRow = $UserLocality->getUserLocalityByUserId($this->enterpriseUserId)->findParentEnterprise();
     $this->view->enterpriseIdGetParam = $this->permissionNotEnterprise ? $this->enterpriseUserId : null;
     $this->view->permissionEvaluationOfResponse = $this->permissionEvaluationOfResponse;
 }
Ejemplo n.º 7
0
 public function setExecutionProgress($QstnId, $UserId)
 {
     $qtdTotal = DbTable_Questionnaire::getInstance()->getQuestionnaireTotalQuestions($QstnId)->getQtdTotal();
     $qtdFaltante = count(DbTable_Questionnaire::getInstance()->needToFinish($QstnId, $UserId)->toArray());
     $qtdRealizado = $qtdTotal - $qtdFaltante;
     $pctRealizado = round($qtdRealizado / $qtdTotal * 100, 0);
     $executionRow = DbTable_Execution::getInstance()->fetchRow(array('UserId = ?' => $UserId, 'QuestionnaireId = ?' => $QstnId));
     if (!$executionRow) {
         $Execution = new Model_Execution();
         $executionRow = $Execution->initExecution($QstnId, $UserId);
     }
     $executionRow->setProgress($pctRealizado);
     $executionRow->save();
     return true;
 }