Example #1
0
 public static function reorder($questionnaire_id, $fromId = null, $fromOldPosition = null, $oldPositionId = null)
 {
     if (!is_numeric($questionnaire_id)) {
         return false;
     }
     $modelBlock = new Model_Block();
     $orderBy = 0;
     $where = array('QuestionnaireId = ?' => $questionnaire_id);
     $order = array('Designation ASC');
     $blocks = $modelBlock->getAll($where, $order);
     $newPositionRowId = null;
     if ($fromId) {
         $newPositionRow = $modelBlock->getBlockById($fromId);
         $newPositionRowId = $newPositionRow->getId() ? $newPositionRow->getId() : null;
     }
     if ($fromOldPosition) {
         $fromOldPosition = $fromOldPosition ? $fromOldPosition : null;
     }
     $toPositionRowId = null;
     if ($oldPositionId) {
         $toPositionRow = $modelBlock->getBlockById($oldPositionId);
         $toPositionRowId = $toPositionRow->getId() ? $toPositionRow->getId() : null;
         $toNewPosition = $toPositionRow->getDesignation() ? $toPositionRow->getDesignation() : null;
     }
     if (!is_object($blocks) || !(count($blocks) > 0)) {
         return false;
     }
     foreach ($blocks as $blockRow) {
         $orderBy++;
         if ($blockRow->getId() == $newPositionRowId) {
             // não editar $newPositionRowId
             continue;
         }
         $data['questionnaire_id'] = $questionnaire_id;
         $data['value'] = $blockRow->getValue();
         $data['long_description'] = $blockRow->getLongDescription();
         $data['conclusion_text'] = $blockRow->getConclusionText();
         if ($blockRow->getId() == $toPositionRowId) {
             $blockRow->setId($toPositionRowId);
             if ($fromOldPosition <= $toNewPosition) {
                 $data['designation'] = $toNewPosition - 1;
             } else {
                 $data['designation'] = $toNewPosition + 1;
             }
         } else {
             $data['designation'] = $orderBy;
         }
         $modelBlock->updateBlock($blockRow, $data);
     }
     return true;
 }
 public function indexAction()
 {
     $this->view->getAllCompetition = $this->modelCompetition->getAllCompetition();
     $modelBlock = new Model_Block();
     $arrConfiguration = $this->Configuration->getSescoopConfiguration();
     $this->view->allConfig = $arrConfiguration;
     $this->view->getAutoavaliacaoQuestionnaires = $this->Questionnaire->getQuestionnairesByDevolutiveCalcId(3);
     $this->view->getAllBlockByAutoavaliacao = $modelBlock->getAllByQuestionnaireId($arrConfiguration->qstn->currentAutoavaliacaoId);
     if (!$this->getRequest()->isPost()) {
         return;
     }
     // ---------------------------
     // Autoavaliação - ID
     $autoavaliacaoConfigurationRow = $this->Configuration->getConfigurationByConfKey('qstn.currentAutoavaliacaoId');
     $updateAutoavaliacaoConfiguration = $this->Configuration->updateConfig($autoavaliacaoConfigurationRow, $this->_getParam('autoavaliacao_value'));
     // bloco de empreendedorismo
     $blockEmpreendedorismoConfigurationRow = $this->Configuration->getConfigurationByConfKey('qstn.currentBlockIdEmpreendedorismo');
     $updateEmpreendedorismoBlockConfiguration = $this->Configuration->updateConfig($blockEmpreendedorismoConfigurationRow, $this->_getParam('block_empreendedorismo_value'));
     // bloco de negócios corrente
     $blockNegociosConfigurationRow = $this->Configuration->getConfigurationByConfKey('qstn.currentBlockIdNegocios');
     $updateNegocioBlockConfiguration = $this->Configuration->updateConfig($blockNegociosConfigurationRow, $this->_getParam('block_negocios_value'));
     // Contato por email
     $secoopContactConfigurationRow = $this->Configuration->getConfigurationByConfKey('addr.sescoopContactEmail');
     $updateSecoopContactConfiguration = $this->Configuration->updateConfig($secoopContactConfigurationRow, $this->_getParam('secoop_contact_value'));
     // Contato por email (inelegibilidade )
     $eligibilityGestorConfigurationRow = $this->Configuration->getConfigurationByConfKey('addr.eligibilityGestorEmail');
     $updateEligibilityGestorConfiguration = $this->Configuration->updateConfig($eligibilityGestorConfigurationRow, $this->_getParam('eligibility_gestor_value'));
     // Concurso (competition_id)
     $competitionConfigurationRow = $this->Configuration->getConfigurationByConfKey('competitionIdKey');
     $updateCompetitionConfiguration = $this->Configuration->updateConfig($competitionConfigurationRow, $this->_getParam('competition_id'));
     if (!$updateAutoavaliacaoConfiguration['status']) {
         $this->view->messageError = $updateAutoavaliacaoConfiguration['messageError'];
         return;
     }
     if (!$updateSecoopContactConfiguration['status']) {
         $this->view->messageError = $updateSecoopContactConfiguration['messageError'];
         return;
     }
     if (!$updateEligibilityGestorConfiguration['status']) {
         $this->view->messageError = $updateEligibilityGestorConfiguration['messageError'];
         return;
     }
     if (!$updateCompetitionConfiguration['status']) {
         $this->view->messageError = $updateCompetitionConfiguration['messageError'];
         return;
     }
     $this->view->itemSuccess = true;
     return;
 }
Example #3
0
 /**
  * stage一覧を返す、引数に数字が渡されていた場合は特定のステージ情報を返す
  *
  * @param Mixed $num ステージ番号
  *
  */
 public function action_stages($num = null)
 {
     if (!$num) {
         $stages = Model_Stage::find('all');
         $this->response($stages);
         return;
     }
     $stage = Model_Block::find_by('stage_id', '1');
     $this->response($stage);
 }
Example #4
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;
 }