public function indexnacAction()
 {
     // sandra - quando é nacional, em que passar mais um parametro
     $nacional = '2';
     $this->userAuth = Zend_Auth::getInstance()->getIdentity();
     $this->evaluationRow = $this->Appraiser->isCheckerPermit($this->enterpriseRow->getId(), $this->userAuth->getUserId(), $this->programId, $nacional);
     if (!$this->evaluationRow or $this->evaluationRow->getStatus() == 'C') {
         throw new Exception('Não autorizado');
     }
     if ($this->evaluationRow->getStatus() == 'N') {
         $this->_redirect('management/appraiser/checker/retorno/true');
     }
     $commentQuestions = $this->Appraiser->getQuestions();
     $evaluationQuestions = DbTable_QuestionChecker::getInstance()->fetchAll('QuestionTypeId = 7', 'Designation');
     $questions = $this->Appraiser->getQuestions();
     $V = array('enterprise' => $this->enterpriseRow, 'president' => $this->enterpriseRow->getPresidentRow(), 'questoes' => $commentQuestions, 'questionsAvaliacao' => $evaluationQuestions, 'respostas' => $this->evaluationRow->getAnswers(), 'commentAnswers' => $this->evaluationRow->getCommentAnswers(), 'conclusao' => $this->evaluationRow->getConclusao(), 'scores' => $this->Appraiser->getEnterpriseScoreAppraisersData($this->enterpriseRow->getId(), null, 2), 'verificacaoAvaliador' => $this->Appraiser->getEnterpriseScoreAppraiserAnwserVerificadorData($this->enterpriseRow->getId(), $this->userAuth->getUserId()), 'conclusao' => $this->evaluationRow->getConclusao(), 'comentarioVerificador' => $this->Appraiser->getApeEvaluationVerificadorComment($this->enterpriseRow->getId(), $this->userAuth->getUserId()));
     // var_dump($this->Appraiser->getEnterpriseScoreAppraisersData($this->enterpriseRow->getId(), null, 2));die; este tinha dados avaliadores estaduais
     $this->view->assign($V);
     $this->loggedUserId = $this->userLogged->getUserId();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     $conclusao = $this->_getParam('conclusao', false);
     $data = array();
     $data['enterprise_id'] = $this->enterpriseRow->getId();
     $data['appraiser_id'] = $this->userAuth->getUserId();
     //Sandra - tipo 8 é o verificador nacional
     $data['tipo'] = '8';
     $data['nacional'] = $nacional;
     $data['programa_id'] = Zend_Registry::get('configDb')->competitionId;
     $data['etapa'] = $this->_getParam('etapa', 'nacional');
     $last = $this->Appraiser->getCheckerToEnterpriseVerificador($data);
     $data['id'] = $last->getId();
     $AppraiserEnterprise = new Model_Appraiser();
     $AppraiserEnterprise->setAppraiserToEnterprise($data);
     // Sandra $$$ verificar se pode deixar esta linha
     //$this->evaluationRow->setId($AppraiserEnterprise->getAppraiserId());
     $save = $this->Appraiser->saveApeEvaluationVerificador($questions, $this->evaluationRow, $this->_getParam('ans'), $conclusao);
     $appraiserEnterpriseId = $this->enterpriseRow->getId();
     $userId = $this->loggedUserId;
     $save = $this->Appraiser->saveApeEvaluationVerificadorComment($commentQuestions, $evaluationQuestions, $this->_getParam('comments'), $appraiserEnterpriseId, $userId);
     $data['enterprise_id'] = $this->enterpriseRow->getId();
     $data['user_id'] = $this->loggedUserId;
     $data['programa_id'] = $this->competitionId;
     // Sandra - 2 é verificador nacional
     $data['tipo'] = 2;
     $data['status'] = "II";
     $AppraiserModel = new Model_Appraiser();
     $objAppraiser = $AppraiserModel->setCheckerToEnterpriseVerificador($data);
     if ($save['status']) {
         $this->_redirect('management/appraiser/checker/' . $this->enterpriseKey);
     }
     //finalizacao da avaliação faltando conclusão final
     if (!$conclusao) {
         $V['commentAnswers'] = $this->evaluationRow->getCommentAnswers();
         $V['resposta'] = $this->evaluationRow->getAnswers();
         //$V['conclusaoErro'] = true;
         // $V['questionsError'] = isset($save['questionsError'])? $save['questionsError'] : array();
         $this->view->assign($V);
         return;
     }
 }
Esempio n. 2
0
 public function setAppraiserToEnterpriseAction()
 {
     $data['enterprise_id'] = $this->Enterprise->getEnterpriseByIdKey($this->_getParam('idKey'))->getId();
     $data['appraiser_id'] = $this->_getParam('appraiserId');
     $data['tipo'] = $this->_getParam('tipo');
     $data['programa_id'] = Zend_Registry::get('configDb')->competitionId;
     $data['etapa'] = $this->_getParam('etapa', 'estadual');
     if ($data['etapa'] == 'nacional') {
         /* @TODO só pode gestor nacional */
         unset($data['desclassificar']);
         unset($data['justificativa']);
         switch ($data['tipo']) {
             case 1:
                 $data['tipo'] = 4;
                 break;
             case 2:
                 $data['tipo'] = 5;
                 break;
             case 3:
                 $data['tipo'] = 6;
                 break;
         }
     } else {
         if (!in_array($data['tipo'], array(1, 2, 3))) {
             throw new Exception('erro');
         }
     }
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $AppraiserEnterprise = new Model_Appraiser();
     $objAppraiser = $AppraiserEnterprise->setAppraiserToEnterprise($data);
     if (!isset($objAppraiser['messageError'])) {
         $objAppraiser['messageError'] = '';
     }
     //print_r($objAppraiser);exit;
     $this->view->itemSuccess = $objAppraiser;
 }