Ejemplo n.º 1
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;
 }