Пример #1
0
 public function hasCurrentCompetition()
 {
     $modelECAC = new Model_EnterpriseCategoryAwardCompetition();
     $enterpriseRow = Zend_Auth::getInstance()->getIdentity()->getEnterpriseRow();
     if (!$enterpriseRow) {
         return false;
     }
     $enterpriseId = $enterpriseRow->getId();
     return $modelECAC->hasECAC($enterpriseId, Zend_Registry::get('configDb')->competitionId);
 }
Пример #2
0
 public function verifyAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $enterpriseIdKey = $this->_getParam('enterprise-id-key');
     $enterprise = $this->Enterprise->getEnterpriseByIdKey($enterpriseIdKey);
     $competitionId = $this->modelQuestionnaire->getCurrentExecution()->getCompetitionId();
     $modelEnterpriseCategoryAwardCompetition = new Model_EnterpriseCategoryAwardCompetition();
     $modelEnterpriseCategoryAwardCompetition->updateECACVerifiedByEnterpriseIdAndYear($enterprise->getId(), $competitionId);
 }
Пример #3
0
 public function updateEnterpriseTransaction($ficha, $enterpriseRow, $addressEnterpriseRow, $presidentRow, $addressPresidentRow, $userRow)
 {
     $User = new Model_User();
     $President = new Model_President();
     $PresidentProgram = new Model_PresidentProgram();
     //$Eligibility = new Model_Eligibility();
     $AddressEnterprise = new Model_AddressEnterprise();
     $AddressPresident = new Model_AddressPresident();
     $modelEntCatAwardCompetition = new Model_EnterpriseCategoryAwardCompetition();
     $modelLogCadastroEmpresa = new Model_LogCadastroEmpresa();
     // dados Empresa
     $registerEnterpriseData = $ficha['enterprise'];
     // dados endereço da empresa
     $registerAddressEnterpriseData = $ficha['addressEnterprise'];
     $registerAddressPresidentData = $ficha['addressPresident'];
     $registerAddressEnterpriseData['enterprise_id'] = $enterpriseRow->getId();
     $registerAddressPresidentData['president_id'] = $presidentRow->getId();
     // dados do presidente da empresa
     $registerPresidentData = $ficha['president'];
     $registerPresidentData['enterprise_id'] = $enterpriseRow->getId();
     $registerPresidentData['hasnt_email'] = isset($ficha['enterprise']['hasnt_email']) ? $ficha['enterprise']['hasnt_email'] : 0;
     // dados do programa do presidente da empresa
     $registerPresidentProgramData = isset($ficha['presidentProgram']) ? $ficha['presidentProgram'] : null;
     // dados do usuário
     $registerUserData = isset($ficha['user']) ? $ficha['user'] : array();
     $registerUserData['first_name'] = $registerPresidentData['name'];
     $registerUserData['surname'] = $registerPresidentData['nick_name'];
     $registerUserData['email'] = $registerPresidentData['email'];
     $registerUserData['login'] = $registerPresidentData['cpf'];
     $registerLogCadastro = $ficha['log_empresa'];
     $presidentId = $presidentRow->getId();
     // start transaction externo
     Zend_Registry::get('db')->beginTransaction();
     try {
         $hasntEmail = $registerPresidentData['hasnt_email'];
         $enterpriseEmail = isset($ficha['enterprise']['email_default']) ? $ficha['enterprise']['email_default'] : '';
         $this->validateEmail($enterpriseRow->getId(), $enterpriseEmail, $hasntEmail);
         $this->validateLandline($ficha['enterprise']['phone']);
         $programaId = Zend_Registry::get('configDb')->competitionId;
         // Validação Categoria do Premio
         $updateCategoryAward = $this->validCategoryAward($registerEnterpriseData);
         if (!$updateCategoryAward['status']) {
             throw new Vtx_UserException($updateCategoryAward['messageError'], 10);
         }
         // 1.1 Empresa
         $updateEnterprise = $this->updateEnterprise($enterpriseRow, $registerEnterpriseData);
         if (!$updateEnterprise['status']) {
             throw new Vtx_UserException($updateEnterprise['messageError'], 10);
         }
         // elegibilidade para questionario de diagnostico
         //$Eligibility->doDiagnosticoEligibility($updateEnterprise['row']);
         // 1.2 Endereço da Empresa
         $updateAddressEnterprise = $AddressEnterprise->updateAddressEnterprise($addressEnterpriseRow, $registerAddressEnterpriseData);
         if (!$updateAddressEnterprise['status']) {
             throw new Vtx_UserException($updateAddressEnterprise['messageError'], 10);
         }
         // validação dos campos NewsLetter da Candidata (President)
         $newsLetterValid = $President->isValidNewsletter($ficha['newsletter'], $registerPresidentData);
         if (!$newsLetterValid['status']) {
             throw new Vtx_UserException($newsLetterValid['messageError']);
         }
         // 2.1 Presidente da Empresa
         $registerPresidentData['agree'] = $presidentRow->getAgree();
         $updatePresident = $President->updatePresident($presidentRow, $registerPresidentData);
         if (!$updatePresident['status']) {
             throw new Vtx_UserException($updatePresident['messageError']);
         }
         // 2.2 Endereço da Presidente (candidata)
         $updateAddressPresident = $AddressPresident->updateAddressPresident($addressPresidentRow, $registerAddressPresidentData);
         if (!$updateAddressPresident['status']) {
             throw new Vtx_UserException($updateAddressPresident['messageError']);
         }
         // 2.3 Programa do Presidente da Empresa
         if ($registerPresidentProgramData) {
             $PresidentProgram->deleteAllPresidentProgramByPresidentId($presidentId);
             $createPresidentProgram = $PresidentProgram->createPresidentProgramByPresidentId($registerPresidentProgramData, $presidentId);
             if (!$createPresidentProgram['status']) {
                 throw new Vtx_UserException($createPresidentProgram['messageError']);
             }
         }
         $enterpriseId = $enterpriseRow->getId();
         $hasCurrentECAC = $modelEntCatAwardCompetition->hasECAC($enterpriseId, $programaId);
         if (!$hasCurrentECAC) {
             $registerECAC = array();
             $registerECAC['enterprise_id'] = $enterpriseId;
             $registerECAC['competition_id'] = $programaId;
             $registerECAC['category_award_id'] = $registerEnterpriseData['category_award_id'];
             $insertECAC = $modelEntCatAwardCompetition->createECAC($registerECAC);
             if (!$insertECAC['status']) {
                 throw new Vtx_UserException($insertECAC['messageError']);
             }
             //  Log Cadastro da Empresa - ACEITE
             $logCadastroEmpresa['user_id_log'] = $registerLogCadastro['user_id_log'];
             $logCadastroEmpresa['enterprise_id'] = $enterpriseId;
             $logCadastroEmpresa['programa_id'] = $programaId;
             $logCadastroEmpresa['acao'] = 'aceite';
             $insertlogCadastroEmpresa = $modelLogCadastroEmpresa->createLogCadastroEmpresa($logCadastroEmpresa);
             if (!$insertlogCadastroEmpresa['status']) {
                 throw new Vtx_UserException($insertlogCadastroEmpresa['messageError']);
             }
         }
         // 3.1 Usuário (nome + sobrenome)
         $updateUser = $User->updateUser($userRow, $registerUserData);
         if (!$updateUser['status']) {
             throw new Vtx_UserException($updateUser['messageError']);
         }
         // Envia email com login/senha pro responsavel pelo cadastro
         $pass = isset($registerUserData['keypass']) ? $registerUserData['keypass'] : null;
         $enterpriseEmail = $registerEnterpriseData['email_default'];
         $presidentEmail = $registerPresidentData['email'];
         if ($enterpriseEmail != '') {
             $this->sendMailEdit($enterpriseEmail, $registerUserData['first_name'], $registerUserData['login'], $pass, $enterpriseId);
             if ($enterpriseEmail != $presidentEmail) {
                 $this->sendMailEdit($presidentEmail, $registerPresidentData['name'], $registerPresidentData['cpf'], $pass, $enterpriseId);
             }
         }
         //  Log Cadastro da Empresa - EDICAO CADASTRO
         $logCadastroEmpresa['user_id_log'] = $registerLogCadastro['user_id_log'];
         $logCadastroEmpresa['enterprise_id'] = $enterpriseId;
         $logCadastroEmpresa['programa_id'] = $programaId;
         $logCadastroEmpresa['acao'] = 'edicao_cadastro';
         $insertlogCadastroEmpresaCad = $modelLogCadastroEmpresa->createLogCadastroEmpresa($logCadastroEmpresa);
         if (!$insertlogCadastroEmpresaCad['status']) {
             throw new Vtx_UserException($insertlogCadastroEmpresaCad['messageError']);
         }
         // update
         // end transaction externo
         Zend_Registry::get('db')->commit();
         return array('status' => true);
     } catch (Vtx_UserException $e) {
         Zend_Registry::get('db')->rollBack();
         return array('status' => false, 'messageError' => $e->getMessage(), 'errorCode' => $e->getCode());
     } catch (Exception $e) {
         Zend_Registry::get('db')->rollBack();
         throw new Exception($e);
     }
 }