public function getEnterpriseRow() { $modelUserLocality = new Model_UserLocality(); $modelEnterprise = new Model_Enterprise(); //$userRow = $this->getUserRow(); $userLocalityRow = $modelUserLocality->getUserLocalityByUserId($this->getUserId()); return ($userLocalityRow and $userLocalityRow->getEnterpriseId()) ? $modelEnterprise->getEnterpriseById($userLocalityRow->getEnterpriseId()) : null; }
public function varEnterpriseRowAndUserId() { $request = Zend_Controller_Front::getInstance()->getRequest(); $key = $request->getParam('id_key', $request->getParam('enterprise-id-key', $request->getParam('enterprise_id_key'))); if ($key) { //echo "-----1----"; $modelEnterprise = new Model_Enterprise(); $UserLocality = new Model_UserLocality(); $enterpriseIdKey = $key; $enterpriseRow = $modelEnterprise->getEnterpriseByIdKey($enterpriseIdKey); $enterpriseId = $enterpriseRow->getId(); $userLocalityGetEnterprise = $UserLocality->getUserLocalityByEnterpriseId($enterpriseRow->getId()); if (!$userLocalityGetEnterprise) { throw new Exception('Nenhum usuário relacionado nesta empresa.'); } $userId = $userLocalityGetEnterprise->getUserId(); } else { $enterpriseRow = Zend_Auth::getInstance()->getIdentity()->getEnterpriseRow(); $enterpriseId = $enterpriseRow['Id']; $userId = $enterpriseRow = Zend_Auth::getInstance()->getIdentity()->getUserId(); } return array('enterpriseId' => $enterpriseId, 'userId' => $userId); }
public function questionarionegocionacAction() { $programaId = $this->competitionId; $enterpriseId = $this->modelUserLocality->getUserLocalityByUserId($this->enterpriseUserId)->getEnterpriseId(); $UserLocality = new Model_UserLocality(); $this->view->enterpriseRow = $UserLocality->getUserLocalityByUserId($this->enterpriseUserId)->findParentEnterprise(); $hasECAC = $this->modelECAC->hasECAC($enterpriseId, $this->competitionId); if (!$hasECAC) { throw new Exception('access denied'); return; } $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); 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.'); } $this->view->blockQuestions = $this->Block->cacheOrModelBlockById($blockId); $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->user_verificador_id = $this->userLogged->getUserId(); $this->view->enterpriseIdKey = $this->enterpriseIdKey; // $this->view->answeredByUserId = $this->Questionnaire->getQuestionsAnsweredByUserId( // $this->view->qstnRespondId, $this->enterpriseUserId, $blockId); // Sandra - acessa código verificador estadual $verificador = $this->Enterprise->getEnterpriseCheckerEnterprise($enterpriseId, null)->getUserId(); // Sandra - para acessar respostas verificador estadual $this->view->answeredByUserId = $this->Questionnaire->getQuestionsAnsweredByUserIdVerificador($this->view->qstnRespondId, $verificador, $this->enterpriseUserId, $blockId); // Sandra - par acessar respostas do verificador nacional $this->view->answeredByUserIdVerificador = $this->Questionnaire->getQuestionsAnsweredByUserIdVerificador($this->view->qstnRespondId, $this->userLogged->getUserId(), $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(); //var_dump($this->view->enterpriseRow);die; //- aqui tem pontos verificador estadual }
/** * * @param type $userId * @return type */ public function getEnterpriseData($userId) { $User = new Model_User(); $President = new Model_President(); $Enterprise = new Model_Enterprise(); $UserLocality = new Model_UserLocality(); $AddressEnterprise = new Model_AddressEnterprise(); //$userId = 81; $userRow = $User->getUserById($userId); $userLocalityRow = $UserLocality->getUserLocalityByUserId($userRow->getId()); $enterpriseRow = $Enterprise->getEnterpriseById($userLocalityRow->getEnterpriseId()); $presidentRow = $President->getPresidentByEnterpriseId($enterpriseRow->getId()); $addressEnterpriseRow = $AddressEnterprise->getAddressEnterpriseByEnterpriseId($enterpriseRow->getId()); $arrAnnualRevenue = Vtx_Util_Array::annualRevenue(); $neighborhood = $addressEnterpriseRow->findParentNeighborhood(); $arrEnterprise = array('Registro OCB' => $enterpriseRow->getOcbRegister() != '' ? $enterpriseRow->getOcbRegister() : '', 'Razão Social' => $enterpriseRow->getSocialName() != '' ? $enterpriseRow->getSocialName() : '', 'E-mail' => $enterpriseRow->getEmailDefault() != '' ? $enterpriseRow->getEmailDefault() : '', 'Nome Fantasia' => $enterpriseRow->getFantasyName() != '' ? $enterpriseRow->getFantasyName() : '', 'Ramo de Atividade' => $enterpriseRow->getMetierId() ? DbTable_Metier::getInstance()->getById($enterpriseRow->getMetierId())->getDescription() : '', 'Atividade Econômica(CNAE)' => $enterpriseRow->getCnae() != '' ? $enterpriseRow->getCnae() : '', 'CPF/CNPJ' => $enterpriseRow->getCnpj() != '' ? Vtx_Util_Formatting::maskFormat($enterpriseRow->getCnpj(), '##.###.###/####-##') : '', 'Porte da Empresa' => $enterpriseRow->getAnnualRevenue() != '' && isset($arrAnnualRevenue[$enterpriseRow->getAnnualRevenue()]) ? $arrAnnualRevenue[$enterpriseRow->getAnnualRevenue()] : '', 'Número de Colaboradores' => $enterpriseRow->getEmployeesQuantity() != '' ? $enterpriseRow->getEmployeesQuantity() : '', 'Data de Abertura' => $enterpriseRow->getCreationDate() != '' ? Vtx_Util_Date::format_dma($enterpriseRow->getCreationDate()) : '', 'Endereço' => is_object($addressEnterpriseRow) ? $addressEnterpriseRow->getStreetNameFull() : '', 'Número' => is_object($addressEnterpriseRow) ? $addressEnterpriseRow->getStreetNumber() : '', 'Complemento' => is_object($addressEnterpriseRow) ? $addressEnterpriseRow->getStreetCompletion() : '', 'Bairro' => $neighborhood ? $addressEnterpriseRow->findParentNeighborhood()->getName() : '', 'Cidade/Estado' => is_object($addressEnterpriseRow) ? DbTable_City::getInstance()->getById($addressEnterpriseRow->getCityId())->getName() . "/" . DbTable_State::getInstance()->getById($addressEnterpriseRow->getStateId())->getUf() : '', 'CEP' => is_object($addressEnterpriseRow) ? Vtx_Util_Formatting::maskFormat($addressEnterpriseRow->getCep(), '#####-###') : ''); $arrContact = array('Nome' => is_object($presidentRow) ? $presidentRow->getName() : '', 'Cargo' => is_object($presidentRow) ? 'Presidente' : '', 'Telefone' => is_object($presidentRow) ? $presidentRow->getPhone() : '', 'E-mail' => is_object($presidentRow) ? $presidentRow->getEmail() : '', 'Cpf' => Vtx_Util_Formatting::maskFormat($presidentRow->getCpf(), '###.###.###-##')); $arrIssues = array('0' => array('Q' => '1. É uma Matriz?', 'R' => $enterpriseRow->getHeadOfficeStatus() == '1' ? 'Sim' : 'Não'), '1' => array('Q' => '2. É uma Singular?', 'R' => $enterpriseRow->getSingularStatus() == '1' ? 'Sim' : 'Não'), '2' => array('Q' => '3. A empresa está vinculada a alguma Central?', 'R' => $enterpriseRow->getCentralName() != '' ? $enterpriseRow->getCentralName() : 'Não'), '3' => array('Q' => '4. A empresa está vinculada a alguma Federação?', 'R' => $enterpriseRow->getFederationName() != '' ? $enterpriseRow->getFederationName() : 'Não'), '4' => array('Q' => '5. A empresa está vinculada a alguma Confederação?', 'R' => $enterpriseRow->getConfederationName() != '' ? $enterpriseRow->getConfederationName() : 'Não')); return array($arrEnterprise, $arrContact, $arrIssues); }
public static function isGestorNational($userLogged = null) { if (!$userLogged) { $userLogged = Zend_Auth::getInstance()->getIdentity(); } if (!Model_User::isGestor($userLogged)) { return false; } $modelUserLocality = new Model_UserLocality(); $modelRegional = new Model_Regional(); $regionalId = $modelUserLocality->getUserLocalityByUserId($userLogged->getUserId())->getRegionalId(); $regionalRow = $modelRegional->getRegionalById($regionalId); return $regionalRow->getNational() == 'S'; }
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; }
/** * dados da empresa * * @param type $userId * @return type */ public function getEnterpriseData($userId) { $User = new Model_User(); //$President = new Model_President(); $Enterprise = new Model_Enterprise(); $UserLocality = new Model_UserLocality(); $AddressEnterprise = new Model_AddressEnterprise(); $Position = new Model_Position(); $userRow = $User->getUserById($userId); $userLocalityRow = $UserLocality->getUserLocalityByUserId($userRow->getId()); $enterpriseRow = $Enterprise->getEnterpriseById($userLocalityRow->getEnterpriseId()); //var_dump('EnterpriseId: ',$enterpriseRow->getId()); //$presidentRow = $President->getPresidentByEnterpriseId($enterpriseRow->getId()); $addressEnterpriseRow = $AddressEnterprise->getAddressEnterpriseByEnterpriseId($enterpriseRow->getId()); $arrAnnualRevenue = Vtx_Util_Array::annualRevenue(); $arrCategoria = Vtx_Util_Array::categoriaMpe(); $idCategoria = $enterpriseRow->getCategoriaId(); $nomeCategoria = ""; if (is_int($idCategoria)) { $nomeCategoria = $arrCategoria[$idCategoria]; } $arrTipoEmpresa = Vtx_Util_Array::tipoEmpresaMPE(); $idTipoEmpresa = $enterpriseRow->getEnterpriseTypeId(); $tipoEmpresa = ""; if (is_int($idTipoEmpresa)) { $tipoEmpresa = $arrTipoEmpresa[$idTipoEmpresa]; } // var_dump('addressEnterpriseRow: ',$addressEnterpriseRow); // exit; $neighborhood = $addressEnterpriseRow->findParentNeighborhood(); //var_dump('neighborhood: ',$neighborhood); $idUf = $addressEnterpriseRow->getStateId(); $idCidade = $addressEnterpriseRow->getCityId(); //var_dump($idCidade); //var_dump($idUf); if (is_int($idUf)) { $uf = DbTable_State::getInstance()->getById($idUf)->getUf(); } else { $uf = ""; } if (is_int($idCidade)) { $cidade = DbTable_City::getInstance()->getById($idCidade)->getName(); } else { $cidade = ""; } $cidadeEstado = $cidade . "/" . $uf; //var_dump ($cidadeEstado); exit; //var_dump($cidadeEstado); //exit; $cnpj = $enterpriseRow->getCnpj(); if (is_string($cnpj)) { $cpfCnpj = $cnpj; } else { $cpfCnpj = ""; } //$cnpjMask = Vtx_Util_Formatting::maskFormat($getcnpj,'##.###.###/####-##'); //$cnpj = null; //var_dump($cnpj); //exit; $arrEnterprise = array('Razão Social' => $enterpriseRow->getSocialName() != '' ? $enterpriseRow->getSocialName() : '', 'E-mail' => $enterpriseRow->getEmailDefault() != '' ? $enterpriseRow->getEmailDefault() : '', 'Nome Fantasia' => $enterpriseRow->getFantasyName() != '' ? $enterpriseRow->getFantasyName() : '', 'Atividade Econômica(CNAE)' => $enterpriseRow->getCnae() != '' ? $enterpriseRow->getCnae() : '', 'CPF/CNPJ' => $cpfCnpj, 'Faturamento Anual' => $enterpriseRow->getAnnualRevenue() != '' && isset($arrAnnualRevenue[$enterpriseRow->getAnnualRevenue()]) ? $arrAnnualRevenue[$enterpriseRow->getAnnualRevenue()] : '', 'Número de Colaboradores' => $enterpriseRow->getEmployeesQuantity() != '' ? $enterpriseRow->getEmployeesQuantity() : '0', 'Data de Abertura' => $enterpriseRow->getCreationDate() != '' ? Vtx_Util_Date::format_dma($enterpriseRow->getCreationDate()) : '', 'Endereço' => is_object($addressEnterpriseRow) ? $addressEnterpriseRow->getStreetNameFull() : '', 'Número' => is_object($addressEnterpriseRow) ? $addressEnterpriseRow->getStreetNumber() : '', 'Complemento' => is_object($addressEnterpriseRow) ? $addressEnterpriseRow->getStreetCompletion() : '', 'Bairro' => $neighborhood ? $addressEnterpriseRow->findParentNeighborhood()->getName() : '', 'Cidade/Estado' => $cidadeEstado, 'CEP' => is_object($addressEnterpriseRow) ? Vtx_Util_Formatting::maskFormat($addressEnterpriseRow->getCep(), '#####-###') : '', 'Categoria' => $nomeCategoria, 'Tipo Empresa' => $tipoEmpresa); $idPosition = $userRow->getPositionId(); $cargo = ""; if (is_int($idPosition)) { $posicao = $Position->getPosition($idPosition); $cargo = $posicao ? $posicao->getDescription() : ''; } $arrContact = array('Nome' => is_object($userRow) ? $userRow->getNomeCompleto() : '', 'Cargo' => is_object($userRow) ? $cargo : '', 'Telefone' => is_object($userRow) ? $userRow->getTelefone() : '', 'Celular' => is_object($userRow) ? $userRow->getCelular() : '', 'E-mail' => is_object($userRow) ? $userRow->getEmail() : ''); $arrIssues = array(); return array($arrEnterprise, $arrContact, $arrIssues); }
public function indexAction() { if (!isset($this->tipoRelatorio)) { $this->tipoRelatorio = 'inscricoes'; } $State = new Model_State(); $City = new Model_City(); $model_Metier = new Model_Metier(); $dbTable_Regional = new DbTable_Regional(); $modelUserLocality = new Model_UserLocality(); $modelRegional = new Model_Regional(); $Neighborhood = new Model_Neighborhood(); $Regiao = new Model_Regiao(); $Configuration = new Model_Configuration(); $modelEnterpriseCategoryAward = new Model_EnterpriseCategoryAward(); $enterprise = new Model_Enterprise(); $ApeEvaluationVerificador = new Model_ApeEvaluationVerificador(); // Sandra - acessar ciclo atual $currentYearRow = $Configuration->getConfigurationByConfKey('competitionIdKey'); $this->view->ciclo = $currentYearRow->getConfValue(); $this->view->cicloAnt = $this->view->ciclo - 1; $format = $this->_getParam('format'); $this->view->getAllEducations = $this->Education->getAll(); if ($format == 'csv') { //$this->view->getAllPosition = $this->modelPosition->getAll(); $this->_dorelatorio(); $this->incluirJoinPontuacao = '1'; $this->incluirJoinRegional = '1'; } set_time_limit(720); //6 minutos $ns = new Zend_Session_Namespace('respond'); $ns->enterpriseUserId = null; //constroi url para CSV $this->view->urlParaGerarCsv = $this->_construirUrlParaCsv(); $this->view->getAllEnterpriseCategoryAward = $modelEnterpriseCategoryAward->getAll(); //finalistas estaduais $this->view->getAllApeEvaluationVerificador = $ApeEvaluationVerificador->getAll(); //$this->view->getAllAnswerVerificador = $modelAnswerVerificador->getAllScore(); $this->view->getAllRegiao = $Regiao->getAll(); $this->view->getAllMetier = $model_Metier->getAll(); $this->view->isRanking = isset($this->view->isRanking) ? $this->view->isRanking : false; $this->filterAdditional = isset($this->filterAdditional) ? $this->filterAdditional : $this->_getParam('filter'); $filter = $this->filterAdditional; $this->view->filter = $filter; $this->view->hasFilterRegional = true; $this->view->hasFilterStatus = true; $this->view->getAllStates = $State->getAll(); if (isset($filter['state_id']) and !empty($filter['state_id'])) { $this->view->getAllCities = $City->getAllCityByStateId($filter['state_id']); } if (isset($filter['city_id']) and !empty($filter['city_id'])) { $this->view->getAllNeighborhoods = $Neighborhood->getAllNeighborhoodByCityId($filter['city_id']); } $this->view->competitionId = Zend_Registry::get('configDb')->competitionId; $this->view->getAllCompetition = $this->modelCompetition->getAllCompetition(); $userLoggedRow = $this->userAuth; //$roleRow = $this->aclModel->getRoleById($userLoggedRow->getRoleId(), false); $page = $this->_getParam('page'); $count = $this->_getParam('count', 10); $this->orderBy = isset($this->orderBy) ? $this->orderBy : null; $orderBy = $this->view->orderBy = $this->_getParam('orderBy', $this->orderBy); $filter['appraiser_id'] = isset($filter['appraiser_id']) ? $filter['appraiser_id'] : null; $filter['incluir_join_pontuacao'] = isset($this->incluirJoinPontuacao) ? $this->incluirJoinPontuacao : '0'; $filter['incluir_join_regional'] = isset($this->incluirJoinRegionalForce) ? $this->incluirJoinRegionalForce : (isset($this->incluirJoinRegional) ? $this->incluirJoinRegional : '0'); $this->view->regionalOption = 'Minha'; // List Coop by Regional $regionalId = $modelUserLocality->getUserLocalityByUserId($userLoggedRow->getUserId())->getRegionalId(); $this->view->getAllRegional = $getAllRegional = $dbTable_Regional->getAllRegionalByOneRegionalServiceArea(null, $regionalId, 'all', $filter); // $this->roleAppraiserId if (isset($filter['regional_id']) and $filter['regional_id']) { $regionalId = $filter['regional_id']; } if ($this->showAppraisersFilter) { //$filterAp['status'] = 'A'; ,$filterAp $this->view->getAllAppraisers = $this->dbTableUser->getAllAppraiserByRegionalServiceArea(null, $regionalId, array('appraiser_status' => 'able')); } if (!$format) { return; } $groupBy = in_array($this->tipoRelatorio, array('inscricoes', 'ranking', 'classificadas', 'finalistas', 'finalistas-nacional', 'candidatas-nacional', 'classificadas-nacional')) ? 'enterprise_id' : null; $this->regionalId = $regionalId; $this->filter = $filter; $this->paramsBuscaServiceArea = $regionalId ? $modelRegional->getServiceAreaByRegionalId($regionalId) : array(0 => null, 1 => null); $fetchReturn = isset($this->fetchReturnForce) ? $this->fetchReturnForce : (isset($this->fetchReturn) ? $this->fetchReturn : 'paginator'); if ($this->tipoRelatorio != 'inscricoes' || $format == 'csv') { $this->view->getAllEnterprise = $this->Enterprise->getAllByColAE($this->paramsBuscaServiceArea[0], $this->paramsBuscaServiceArea[1], $this->autoavaliacaoId, $count, $page, $filter, $orderBy, $format, $fetchReturn, $this->tipoRelatorio, $groupBy); } else { $loggedUserId = $this->userAuth->getUserId(); $this->view->getAllEnterprise = $this->Enterprise->getPaginatorForSubscriptions($loggedUserId, $filter, $count, $page); } $this->view->modelEntCategoryAward = new Model_EnterpriseCategoryAwardCompetition(); }
function userServiceAreaRegional($userLoggedRow) { $whereSA = array(); $model_ServiceArea = new Model_ServiceArea(); $model_UserLocality = new Model_UserLocality(); if ($userLoggedRow->getRoleId() != 1) { $userLocalityRow = $model_UserLocality->getUserLocalityByUserId($userLoggedRow->getUserId()); $whereSA = array('RegionalId = ?' => $userLocalityRow->getRegionalId()); } $serviceArea = $model_ServiceArea->getAll($whereSA); foreach ($serviceArea as $keyRow => $valueData) { foreach ($valueData as $keyData => $valueRow) { if ($keyData == 'StateId' and $valueRow != NULL) { $col = $keyData; $where[] = array("{$keyData} = ?" => $valueRow); } else { if ($keyData == 'CityId' and $valueRow != NULL) { $where[] = array("{$keyData} = ?" => $valueRow); $col = $keyData; } else { if ($keyData == 'NeighborhoodId' and $valueRow != NULL) { $where[] = array("{$keyData} = ?" => $valueRow); $col = $keyData; } } } } } $array = array($where, $col); return $array; }
public function createEnterpriseTransaction($ficha) { $AddressEnterprise = new Model_AddressEnterprise(); $AddressPresident = new Model_AddressPresident(); $President = new Model_President(); $PresidentProgram = new Model_PresidentProgram(); $User = new Model_User(); $UserLocality = new Model_UserLocality(); $Acl = new Model_Acl(); $modelEntCatAwardCompetition = new Model_EnterpriseCategoryAwardCompetition(); $modelLogCadastroEmpresa = new Model_LogCadastroEmpresa(); //$Eligibility = new Model_Eligibility(); // dados da Empresa $registerEnterpriseData = $ficha['enterprise']; $registerEnterpriseData['status'] = 'A'; // dados endereço da Empresa $registerAddressEnterpriseData = $ficha['addressEnterprise']; // dados da presidente da Empresa $registerPresidentData = $ficha['president']; $registerPresidentData['gender'] = 'F'; $registerPresidentData['created'] = date('Y-m-d'); $registerPresidentData['hasnt_email'] = isset($ficha['enterprise']['hasnt_email']) ? $ficha['enterprise']['hasnt_email'] : 0; // dados endereço da Empresa $registerAddressPresidentData = $ficha['addressPresident']; // dados do program do presidente da Empresa $registerPresidentProgramData = isset($ficha['presidentProgram']) ? $ficha['presidentProgram'] : null; // dados do usuário $registerUserData = $ficha['user']; $registerUserData['login'] = $registerPresidentData['cpf']; $registerUserData['first_name'] = $registerPresidentData['name']; $registerUserData['surname'] = isset($registerPresidentData['nick_name']) ? $registerPresidentData['nick_name'] : null; $registerUserData['email'] = $registerPresidentData['email']; $registerUserData['status'] = 'A'; $registerLogCadastro = isset($ficha['log_cadastro_empresa']) ? $ficha['log_cadastro_empresa'] : false; // start transaction externo Zend_Registry::get('db')->beginTransaction(); try { $enterpriseEmail = isset($ficha['enterprise']['email_default']) ? $ficha['enterprise']['email_default'] : ''; $hasntEmail = isset($ficha['enterprise']['hasnt_email']) ? $ficha['enterprise']['hasnt_email'] : 0; $this->validateEmail(NULL, $enterpriseEmail, $hasntEmail); $this->validateLandline($ficha['enterprise']['phone']); // Validação Categoria do Premio $insertCategoryAward = $this->validCategoryAward($registerEnterpriseData); if (!$insertCategoryAward['status']) { throw new Vtx_UserException($insertCategoryAward['messageError'], 10); } // 1.1 Insert Empresa $insertEnterprise = $this->createEnterprise($registerEnterpriseData); if (!$insertEnterprise['status']) { throw new Vtx_UserException($insertEnterprise['messageError'], 10); } // elegibilidade para questionario de diagnostico //$Eligibility->doDiagnosticoEligibility($insertEnterprise['row']); // 1.2 Insert Endereço da Empresa $registerAddressEnterpriseData['enterprise_id'] = $insertEnterprise['lastInsertId']; $insertAddressEnterprise = $AddressEnterprise->createAddressEnterprise($registerAddressEnterpriseData); if (!$insertAddressEnterprise['status']) { throw new Vtx_UserException($insertAddressEnterprise['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 Insert Presidente da Empresa $registerPresidentData['enterprise_id'] = $insertEnterprise['lastInsertId']; $insertPresident = $President->createPresident($registerPresidentData); if (!$insertPresident['status']) { throw new Vtx_UserException($insertPresident['messageError']); } $registerECAC = array(); $registerECAC['enterprise_id'] = $insertEnterprise['lastInsertId']; $registerECAC['competition_id'] = Zend_Registry::get('configDb')->competitionId; $registerECAC['category_award_id'] = $registerEnterpriseData['category_award_id']; $insertECAC = $modelEntCatAwardCompetition->createECAC($registerECAC); if (!$insertECAC['status']) { throw new Vtx_UserException($insertECAC['messageError']); } // 2.2 Insert Endereço da Presidente $registerAddressPresidentData['president_id'] = $insertPresident['lastInsertId']; $insertAddressPresident = $AddressPresident->createAddressPresident($registerAddressPresidentData); if (!$insertAddressPresident['status']) { throw new Vtx_UserException($insertAddressPresident['messageError']); } // 2.3 Programa do Presidente da Empresa if ($registerPresidentProgramData) { $presidentId = $insertPresident['lastInsertId']; $createPresidentProgram = $PresidentProgram->createPresidentProgramByPresidentId($registerPresidentProgramData, $presidentId); if (!$createPresidentProgram['status']) { throw new Vtx_UserException($createPresidentProgram['messageError']); } } // 3.1 Insert Responsável pelo preenchimento - usuário do sistema if (isset($registerUserData['set_login_cpf']) and $registerUserData['set_login_cpf'] == '1') { $registerUserData['login'] = $registerUserData['cpf']; } $insertUser = $User->createUser($registerUserData); if (!$insertUser['status']) { throw new Vtx_UserException($insertUser['messageError']); } // 4.1 Insert Relação UserLocality $registerUserLocalityData['user_id'] = $insertUser['lastInsertId']; $registerUserLocalityData['enterprise_id'] = $insertEnterprise['lastInsertId']; $insertUserLocality = $UserLocality->createUserLocality($registerUserLocalityData); if (!$insertUserLocality['status']) { throw new Vtx_UserException($insertUserLocality['messageError']); } $enterpriseEmail = isset($registerEnterpriseData['email_default']) ? $registerEnterpriseData['email_default'] : ''; $presidentEmail = isset($registerPresidentData['email']) ? $registerPresidentData['email'] : ''; if ($enterpriseEmail != '') { // Envia email com login/senha pro responsavel pelo cadastro $this->sendMail($enterpriseEmail, $registerUserData['first_name'], $insertEnterprise['lastInsertId']); if ($enterpriseEmail != $presidentEmail) { $this->sendMail($presidentEmail, $registerPresidentData['name'], $insertEnterprise['lastInsertId']); } } // 5.1 Insert User Role $Acl->setUserRole($insertUser['lastInsertId'], Zend_Registry::get('config')->acl->roleEnterpriseId); // 6.1 Log Cadastro da Empresa if (!$registerLogCadastro) { $registerLogCadastro['user_id_log'] = $insertUser['lastInsertId']; } $logCadastroEmpresa['user_id_log'] = $registerLogCadastro['user_id_log']; $logCadastroEmpresa['enterprise_id'] = $insertEnterprise['lastInsertId']; $logCadastroEmpresa['programa_id'] = Zend_Registry::get('configDb')->competitionId; $logCadastroEmpresa['acao'] = 'aceite'; $insertlogCadastroEmpresa = $modelLogCadastroEmpresa->createLogCadastroEmpresa($logCadastroEmpresa); if (!$insertlogCadastroEmpresa['status']) { throw new Vtx_UserException($insertlogCadastroEmpresa['messageError']); } // end transaction externo Zend_Registry::get('db')->commit(); return array('status' => true, 'lastInsertIdKey' => $insertEnterprise['lastInsertIdKey']); //throw new Vtx_UserException("Chegou aqui - gravacao ate o fim codigo"); } 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); } }
public function editAction() { $UserLocality = new Model_UserLocality(); $reportId = $this->_getParam('report_id'); $enterpriseIdKey = $this->_getParam('enterprise_id_key', null); $reportRow = $this->modelEnterpriseReport->getEnterpriseReportById($reportId); $enterpriseRow = $this->modelEnterprise->getEnterpriseByIdKey($enterpriseIdKey); if (!$reportRow or $reportRow->findParentEnterprise()->getIdKey() != $enterpriseRow->getIdKey()) { throw new Exception('Invalid Report'); return; } if ($this->_getParam('report_id') and $this->Acl->isAllowed($this->userLogged->getRole(), 'questionnaire:register', 'publisher')) { $enterpriseId = $reportRow->getEnterpriseId(); } else { $enterpriseId = $UserLocality->getUserLocalityByUserId($this->userLogged->getUserId())->getEnterpriseId(); } $this->view->reportId = $reportId; $this->view->enterpriseIdKey = $enterpriseIdKey; $this->view->reportRow = $reportRow; $this->view->addressEnterpriseRow = $this->modelAddressEnterprise->getAddressEnterpriseByEnterpriseId($enterpriseId); if (isset($this->view->isViewAdmin) and $this->view->isViewAdmin) { $this->view->enterpriseRow = $reportRow->findParentEnterprise(); } $this->view->reportRowData = array('competition_id' => $reportRow->getCompetitionId(), 'report' => $reportRow->getReport(), 'title' => $reportRow->getTitle()); $this->view->subscriptionPeriodIsClosed = !$this->subscriptionPeriodIsOpen(); if (!$this->getRequest()->isPost() or $this->view->subscriptionPeriodIsClosed) { return; } if (!$this->validateReportCompetitionEdition($reportRow)) { return; } // die; unset($this->view->reportId); unset($this->view->reportRow); unset($this->view->reportRowData); $reportRowData = $this->_getAllParams(); $hasECAC = $this->modelECAC->hasECAC($enterpriseId, $reportRowData['competition_id']); if (!$hasECAC) { throw new Exception('access denied'); return; } $update = $this->modelEnterpriseReport->updateReport($reportRow, $reportRowData, $enterpriseId); if (!$update['status']) { $this->view->itemSuccess = $update['status']; $this->view->messageError = $update['messageError']; return; } $this->view->itemSuccess = true; if ($this->Acl->isAllowed($this->auth->getIdentity()->getRole(), 'management:report', 'index')) { $this->view->loadUrlReport = $this->view->baseUrl('/management/report/success/itemEditSuccess/true/enterpriseIdKey/' . $enterpriseIdKey); return; } /* if ($this->Acl->isAllowed($this->auth->getIdentity()->getRole(), 'questionnaire:register', 'publisher')) { $this->view->loadUrlReport = $this->view ->baseUrl('/management/enterprise/success/itemEditSuccess/true/social_name/' .urlencode($ficha['enterprise']['social_name'])); return; } */ if ($this->Acl->isAllowed($this->auth->getIdentity()->getRole(), 'questionnaire:report', 'index')) { $this->view->loadUrlReport = $this->view->baseUrl('/questionnaire/report/success/itemEditSuccess/true'); return; } }
public function editAction() { $Acl = Zend_Registry::get('acl'); $auth = Zend_Auth::getInstance(); $User = new Model_User(); $President = new Model_President(); $PresidentProgram = new Model_PresidentProgram(); $modelLogCadastroEmpresa = new Model_LogCadastroEmpresa(); $UserLocality = new Model_UserLocality(); $AddressEnterprise = new Model_AddressEnterprise(); $AddressPresident = new Model_AddressPresident(); $this->_helper->viewRenderer->setRender('index'); $this->view->editStatus = false; $this->view->editByAdmin = false; if ($this->_getParam('id_key') and ($Acl->isAllowed($this->userLogged->getRole(), 'questionnaire:register', 'publisher') or $Acl->isAllowed($this->userLogged->getRole(), 'questionnaire:register', 'acompanhacadastro'))) { $enterpriseIdKey = $this->_getParam('id_key'); $enterpriseRow = $this->Enterprise->getEnterpriseByIdKey($enterpriseIdKey); $userLocalityGetEnterprise = $UserLocality->getUserLocalityByEnterpriseId($enterpriseRow->getId()); if (!$userLocalityGetEnterprise) { throw new Exception('Nenhum usuário relacionado nesta empresa.'); } $this->view->editStatus = true; $this->view->enterpriseIdKey = $enterpriseIdKey; $userId = $userLocalityGetEnterprise->getUserId(); $this->view->editByAdmin = true; } else { $userId = $this->userLogged->getUserId(); } $userRow = $User->getUserById($userId); $userLocalityRow = $UserLocality->getUserLocalityByUserId($userRow->getId()); $enterpriseRow = $this->Enterprise->getEnterpriseById($userLocalityRow->getEnterpriseId()); $presidentRow = $President->getPresidentByEnterpriseId($enterpriseRow->getId()); $addressPresidentRow = $AddressPresident->getAddressPresidentByPresidentId($presidentRow->getId()); $presidentProgramRow = $PresidentProgram->getAllPresidentProgramByPresidentId($presidentRow->getId()); $addressEnterpriseRow = $AddressEnterprise->getAddressEnterpriseByEnterpriseId($enterpriseRow->getId()); $logCadastradoPor = $modelLogCadastroEmpresa->getLogCadastroEmpresaByEnterpriseId($enterpriseRow->getId()); $cadastroNome = 'Site'; $cadastroCriadoEm = '00:00:00'; if ($logCadastradoPor) { if ($logCadastradoPor->getUserIdLog() != $userLocalityRow->getUserId()) { $cadastroNome = $User->getUserById($logCadastradoPor->getUserIdLog())->getFirstName(); } $cadastroCriadoEm = $logCadastradoPor->getCriadoEm(); } $this->view->logCadastroEmpresa = array('NomeCadastro' => $cadastroNome, 'CriadoEm' => $cadastroCriadoEm); if (!$enterpriseRow || !$presidentRow) { throw new Exception('Usuário inválido, não encontrado.'); } $this->view->userIdview = $userId; $this->view->enterpriseIdview = $enterpriseRow->getId(); // $modelQuest = new Model_Questionnaire(); // // $arrTerminoEtapas = $modelQuest->terminoEtapas($enterpriseRow, $userId); // // var_dump($arrTerminoEtapas); $this->view->getAllStates = $this->State->getAll(); if ($addressEnterpriseRow) { $this->view->getAllCities = $this->City->getAllCityByStateId($addressEnterpriseRow->getStateId()); //$this->view->getAllNeighborhoods = $this->Neighborhood->getAllNeighborhoodByCityId($addressEnterpriseRow->getCityId()); $this->view->getAllNeighborhoods = $addressEnterpriseRow->getCityId() ? $this->Neighborhood->getAllNeighborhoodByCityId($addressEnterpriseRow->getCityId()) : null; } if ($addressPresidentRow) { $this->view->getAllCitiesPresident = $this->City->getAllCityByStateId($addressPresidentRow->getStateId()); //$this->view->getAllNeighborhoodsPresident = $this->Neighborhood->getAllNeighborhoodByCityId($addressPresidentRow->getCityId()); $this->view->getAllNeighborhoodsPresident = $addressPresidentRow->getCityId() ? $this->Neighborhood->getAllNeighborhoodByCityId($addressPresidentRow->getCityId()) : null; } $this->view->getAllPositions = $this->Position->getAll(); $this->view->getAllEducations = $this->Education->getAll(); $this->view->getAllMetier = $this->Metier->getAll(); $this->view->getAllPresidentProgramType = $this->modelPresidentProgramType->getAll(); $this->view->hasECAC = $this->modelEnterpriseCategoryAwardCompetition->hasECAC($enterpriseRow->getId(), Zend_Registry::get('configDb')->competitionId); $hasntEmail = $enterpriseRow->getHasntEmail(); $hasntEmail = isset($hasntEmail) ? $hasntEmail : 1; $this->view->registerEnterpriseData = array('cnpj' => $enterpriseRow->getCnpj(), 'category_award_id' => $enterpriseRow->getCategoryAwardId(), 'category_sector_id' => $enterpriseRow->getCategorySectorId(), 'state_registration' => $enterpriseRow->getStateRegistration(), 'dap' => $enterpriseRow->getDap(), 'register_ministry_fisher' => $enterpriseRow->getRegisterMinistryFisher(), 'company_history' => $enterpriseRow->getCompanyHistory(), 'site' => $enterpriseRow->getSite(), 'status' => $enterpriseRow->getStatus(), 'social_name' => $enterpriseRow->getSocialName(), 'fantasy_name' => $enterpriseRow->getFantasyName(), 'creation_date' => $enterpriseRow->getCreationDate(), 'employees_quantity' => $enterpriseRow->getEmployeesQuantity(), 'phone' => $enterpriseRow->getPhone(), 'email_default' => $enterpriseRow->getEmailDefault(), 'annual_revenue' => $enterpriseRow->getAnnualRevenue(), 'cnae' => $enterpriseRow->getCnae(), 'nirf' => $enterpriseRow->getNirf(), 'farm_size' => $enterpriseRow->getFarmSize(), 'hasnt_email' => $hasntEmail); if ($addressEnterpriseRow) { $this->view->registerAddressEnterpriseData = array('cep' => $addressEnterpriseRow->getCep(), 'state_id' => $addressEnterpriseRow->getStateId(), 'city_id' => $addressEnterpriseRow->getCityId(), 'name_full_log' => $addressEnterpriseRow->getStreetNameFull(), 'street_number' => $addressEnterpriseRow->getStreetNumber(), 'street_completion' => $addressEnterpriseRow->getStreetCompletion(), 'neighborhood_id' => $addressEnterpriseRow->getNeighborhoodId()); } $this->view->registerPresidentData = array('enterprise_id' => $presidentRow->getEnterpriseId(), 'education_id' => $presidentRow->getEducationId(), 'position_id' => $presidentRow->getPositionId(), 'find_us_id' => $presidentRow->getFindUsId(), 'nick_name' => $presidentRow->getNickName(), 'cellphone' => $presidentRow->getCellphone(), 'newsletter_email' => $presidentRow->getNewsletterEmail(), 'newsletter_mail' => $presidentRow->getNewsletterMail(), 'newsletter_sms' => $presidentRow->getNewsletterSms(), 'agree' => $presidentRow->getAgree(), 'name' => $presidentRow->getName(), 'cpf' => $presidentRow->getCpf(), 'email' => $presidentRow->getEmail(), 'phone' => $presidentRow->getPhone(), 'born_date' => $presidentRow->getBornDate(), 'gender' => $presidentRow->getGender()); if ($addressPresidentRow) { $this->view->registerAddressPresidentData = array('cep' => $addressPresidentRow->getCep(), 'state_id' => $addressPresidentRow->getStateId(), 'city_id' => $addressPresidentRow->getCityId(), 'name_full_log' => $addressPresidentRow->getStreetNameFull(), 'street_number' => $addressPresidentRow->getStreetNumber(), 'street_completion' => $addressPresidentRow->getStreetCompletion(), 'neighborhood_id' => $addressPresidentRow->getNeighborhoodId()); } $this->view->registerPresidentProgramData = $presidentProgramRow; $this->view->registerUserData = array('first_name' => $userRow->getFirstName(), 'surname' => $userRow->getSurname(), 'password_hint' => $userRow->getPasswordHint()); $this->view->hasEligibility = $hasEligibility = $this->Enterprise->hasEligibilityRules($enterpriseRow->getIdKey()); if ($this->_getParam('forward', null) == true) { return; } if (!$this->getRequest()->isPost()) { return; } $ficha = $this->_getAllParams(); $ficha['log_empresa']['user_id_log'] = $this->userLogged->getUserId(); unset($this->view->editStatus); unset($this->view->getAllStates); unset($this->view->getAllCities); unset($this->view->getAllNeighborhoods); unset($this->view->getAllCitiesPresident); unset($this->view->getAllNeighborhoodsPresident); unset($this->view->getAllPositions); unset($this->view->getAllEducations); unset($this->view->getAllMetier); unset($this->view->getAllPresidentProgramType); unset($this->view->hasECAC); unset($this->view->registerEnterpriseData); unset($this->view->registerAddressEnterpriseData); unset($this->view->registerPresidentData); unset($this->view->registerAddressPresidentData); unset($this->view->registerPresidentProgramData); unset($this->view->registerUserData); unset($this->view->editByAdmin); // $this->view->registerData = $ficha; $updateEnterpriseTransaction = $this->Enterprise->updateEnterpriseTransaction($ficha, $enterpriseRow, $addressEnterpriseRow, $presidentRow, $addressPresidentRow, $userRow); if (!$updateEnterpriseTransaction['status']) { $this->view->messageError = $updateEnterpriseTransaction['messageError']; $this->view->errorCode = $updateEnterpriseTransaction['errorCode']; return; } $this->view->itemSuccess = true; $emailEnterprise = isset($ficha['enterprise']['email_default']) ? $ficha['enterprise']['email_default'] : ''; $socialName = $ficha['enterprise']['social_name']; $cnpj = $ficha['enterprise']['cnpj']; if ($this->view->itemSuccess && ($emailEnterprise == null || $emailEnterprise == '')) { $stateId = $ficha['addressEnterprise']['state_id']; $this->sendWhiteListMail($stateId, $socialName, $cnpj); } $hasEligibility = $this->Enterprise->hasEligibilityRules($enterpriseRow->getIdKey()); if ($Acl->isAllowed($auth->getIdentity()->getRole(), 'questionnaire:register', 'publisher')) { $this->view->loadUrlRegister = $this->view->baseUrl('/management/enterprise/success/itemEditSuccess/true/social_name/' . urlencode($ficha['enterprise']['social_name']) . '/enterpriseIdKey/' . $enterpriseIdKey . '/hasEligibility/' . $hasEligibility); return; } if ($Acl->isAllowed($auth->getIdentity()->getRole(), 'questionnaire:register', 'index')) { $this->view->loadUrlRegister = $this->view->baseUrl('/questionnaire/register/success/itemEditSuccess/true/hasEligibility/' . $hasEligibility); return; } }