/** * faz calculo da pontuacao para tabela Radar */ public function dadosTabelaPontuacao() { $arrCriteria = $this->getArrCriteria(); $arrPunctuation = $this->getArrPunctuation(); $arrRadarData = $this->getArrRadarData(); $arrTabulation = $this->getArrTabulation(); $pontuacaoMaxima = Vtx_Util_Array::pontuacaoMaximaCriteriosGestao(); #('15,0', '9,0', '9,0', '6,0', '6,0','9,0','16,0','30,0' ); $objPontuacao = new stdClass(); //Lideranca $objPontuacao->Lideranca = new stdClass(); $objPontuacao->Lideranca->nome = $arrCriteria[1]; $objPontuacao->Lideranca->pontuacaoMaxima = $pontuacaoMaxima[1]; $objPontuacao->Lideranca->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[1]); $objPontuacao->Lideranca->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[1]); //Estrategias e Planos $objPontuacao->Estrategias = new stdClass(); $objPontuacao->Estrategias->nome = $arrCriteria[2]; $objPontuacao->Estrategias->pontuacaoMaxima = $pontuacaoMaxima[2]; $objPontuacao->Estrategias->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[2]); $objPontuacao->Estrategias->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[2]); //Clientes $objPontuacao->Clientes = new stdClass(); $objPontuacao->Clientes->nome = $arrCriteria[3]; $objPontuacao->Clientes->pontuacaoMaxima = $pontuacaoMaxima[3]; $objPontuacao->Clientes->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[3]); $objPontuacao->Clientes->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[3]); //Sociedade $objPontuacao->Sociedade = new stdClass(); $objPontuacao->Sociedade->nome = $arrCriteria[4]; $objPontuacao->Sociedade->pontuacaoMaxima = $pontuacaoMaxima[4]; $objPontuacao->Sociedade->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[4]); $objPontuacao->Sociedade->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[4]); //Informações e Conhecimento $objPontuacao->Informacoes = new stdClass(); $objPontuacao->Informacoes->nome = $arrCriteria[5]; $objPontuacao->Informacoes->pontuacaoMaxima = $pontuacaoMaxima[5]; $objPontuacao->Informacoes->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[5]); $objPontuacao->Informacoes->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[5]); //Pessoas $objPontuacao->Pessoas = new stdClass(); $objPontuacao->Pessoas->nome = $arrCriteria[6]; $objPontuacao->Pessoas->pontuacaoMaxima = $pontuacaoMaxima[6]; $objPontuacao->Pessoas->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[6]); $objPontuacao->Pessoas->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[6]); //Processos $objPontuacao->Processos = new stdClass(); $objPontuacao->Processos->nome = $arrCriteria[7]; $objPontuacao->Processos->pontuacaoMaxima = $pontuacaoMaxima[7]; $objPontuacao->Processos->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[7]); $objPontuacao->Processos->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[7]); //Resultados $objPontuacao->Resultados = new stdClass(); $objPontuacao->Resultados->nome = $arrCriteria[8]; $objPontuacao->Resultados->pontuacaoMaxima = $pontuacaoMaxima[8]; $objPontuacao->Resultados->pontuacaoObtida = Vtx_Util_Formatting::roundAndDouble($arrPunctuation[8]); $objPontuacao->Resultados->porcentagem = Vtx_Util_Formatting::roundAndDouble($arrRadarData[8]); return $objPontuacao; }
/** * * @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); }
private function appendQueryFilters($query, $loggedUserId, $filter, $ignoreRegionalFilter = false) { if (in_array('annual_revenue', array_keys($filter)) && $filter['annual_revenue'] != '') { $query->where('E.AnnualRevenue = ?', $filter['annual_revenue']); } if (in_array('category_sector_id', array_keys($filter)) && $filter['category_sector_id'] != '') { $query->where('E.CategorySectorId = ?', $filter['category_sector_id']); } if (in_array('education_id', array_keys($filter)) && $filter['education_id'] != '') { $query->where('P.EducationId = ?', $filter['education_id']); } if (in_array('category_award_id', array_keys($filter)) && $filter['category_award_id'] != '') { $query->where('E.CategoryAwardId = ?', $filter['category_award_id']); } if (!$ignoreRegionalFilter) { $regionalId = null; if (in_array('regional_id', array_keys($filter)) && $filter['regional_id'] != '') { $regionalId = $filter['regional_id']; } $this->appendUserRegionalJoins($query, $loggedUserId, $regionalId); } if (in_array('metier_id', array_keys($filter)) && $filter['metier_id'] != '') { $query->where('E.MetierId = ?', $filter['metier_id']); } if (in_array('state_id', array_keys($filter)) && $filter['state_id'] != '') { $query->where("AE.StateId = ?", $filter['state_id']); } if (in_array('city_id', array_keys($filter)) && $filter['city_id'] != '') { $query->where("AE.CityId = ?", $filter['city_id']); } if (in_array('neighborhood_id', array_keys($filter)) && $filter['neighborhood_id'] != '') { $query->where("AE.NeighborhoodId = ?", $filter['neighborhood_id']); } if (in_array('status', array_keys($filter)) && $filter['status'] != '') { $query->where('E.Status = ?', $filter['status']); } if (in_array('verified_subscription', array_keys($filter)) && $filter['verified_subscription'] != '') { $query->where('ECAC.Verified = ?', $filter['verified_subscription']); } if (in_array('coop_name', array_keys($filter)) && $filter['coop_name'] != '') { $query->where("E.SocialName LIKE ? OR E.FantasyName LIKE ?", '%' . $filter['coop_name'] . '%'); } if (in_array('candidatura', array_keys($filter)) && $filter['candidatura'] != '') { if ($filter['candidatura'] == 'C') { $query->where('EXE.DevolutivePath is not null'); } else { $query->where('EXE.DevolutivePath is null'); } } if (in_array('cnpj', array_keys($filter)) && $filter['cnpj'] != '') { $clean_cnpj = preg_replace('/[^0-9]/', '', $filter['cnpj']); $query->where('E.Cnpj LIKE "%' . $clean_cnpj . '%"'); } if (in_array('president_name', array_keys($filter)) && $filter['president_name'] != '') { $query->where("P.Name LIKE ? OR P.NickName LIKE ?", '%' . $filter['president_name'] . '%'); } if (in_array('cpf', array_keys($filter)) && $filter['cpf'] != '') { $clean_cpf = preg_replace('/[^0-9]/', '', $filter['cpf']); $query->where('P.Cpf LIKE "%' . $clean_cpf . '%"'); } if (in_array('employees_quantity', array_keys($filter)) && $filter['employees_quantity'] != '') { $clean_employees_quantity = trim($filter['employees_quantity']); $query->where('E.EmployeesQuantity = ?', $clean_employees_quantity); } if (in_array('appraiser_id', array_keys($filter)) && $filter['appraiser_id'] != '') { $appraiser_id = $filter['appraiser_id']; $query->where('APE1.UserId = ?', $appraiser_id); $query->ORwhere('APE2.UserId = ?', $appraiser_id); $query->ORwhere('APE3.UserId = ?', $appraiser_id); } if (in_array('faixa', array_keys($filter)) && $filter['faixa'] != '') { $range = Vtx_Util_Array::faixaIdadePSMN($filter['faixa']); $start = preg_replace('/[^0-9]/', '', $range[1]); $end = preg_replace('/[^0-9]/', '', $range[2]); $query->where(new Zend_Db_Expr("FLOOR(DATE_FORMAT(NOW(),'%Y')-DATE_FORMAT(P.Borndate,'%Y')) BETWEEN {$start} AND {$end}")); } }
/** * 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 reportGlobalAction() { $this->incluirJoinRegionalForce = false; $filter = $this->_getParam('filter', null); $filter['show_only'] = 'candidatas'; if (isset($filter['competition_id']) and $filter['competition_id'] != $this->competitionId) { throw new Exception('access denied'); return; } $format = $this->_getParam('format', null); $render = $format == 'csv' ? 'report-global' : 'index'; $this->_helper->viewRenderer->setRender($render); if (!$format) { self::indexAction(); return; } $cacheQuestion = new Vtx_Cache_MPE_QuestionarioCache(); $Qstn = new Model_Questionnaire(); $alternativesByQuestion = $allAlternativeIds = array(); $blockId = isset($filter['qstn']) ? $filter['qstn'] : Zend_Registry::get('configDb')->qstn->currentBlockIdNegocios; //$this->view->showRadar = $blockId==Model_Devolutive::BLOCO_GESTAOEMPRESA? true : false; $this->view->showRadar = false; $questions = $cacheQuestion->BlocoECriterios($blockId, $Qstn->getCurrentQstnRow()); $this->view->questions = $questions = $questions[$blockId]; foreach ($questions['Criterions'] as $criterion) { foreach ($criterion['Questions'] as $questionId => $question) { $alternativesQuestion = $cacheQuestion->alternativasEQuestoes($question['QuestionId'], new Model_Alternative()); $alternativesByQuestion[$questionId] = $alternativesQuestion; foreach ($alternativesQuestion as $alternative) { $allAlternativeIds[] = $alternative['Id']; } } } $this->filterAdditional = $filter; $this->filterAdditional['alternativesId'] = $allAlternativeIds; $this->view->alternativesByQuestion = $alternativesByQuestion; $this->fetchReturn = 'pairs'; $this->fetchReturnForce = 'pairs'; $this->tipoRelatorio = 'report-global-respostas'; self::indexAction(); $this->view->qtRespostasAlternativa = $this->view->getAllEnterprise; if (!$this->view->showRadar) { return; } $dataCriterios = $this->Enterprise->getAllByColAE($this->paramsBuscaServiceArea[0], $this->paramsBuscaServiceArea[1], $this->autoavaliacaoId, null, null, $this->filter, null, $format, 'assoc', 'report-global-criterios'); $dataCriteriosPorcent = array(); $this->view->dataCriterios = $dataCriterios['total']; $this->view->pontuacaoMaxima = $pontuacaoMaxima = Vtx_Util_Array::pontuacaoMaximaCriteriosGestao(); $i = 0; foreach ($this->view->dataCriterios as $criterio => $pontuacao) { if ($i != 0) { $dataCriteriosPorcent[] = (double) $pontuacao / (double) $pontuacaoMaxima[$i] * 100; } $i++; } $this->view->dataCriteriosPoncent = $dataCriteriosPorcent; }
public function hasPermissionToCreateRegional($regionalIdOwner, $newServiceAreaData, $indice) { $modelServiceArea = new Model_ServiceArea(); $regionalOwnerSA = $modelServiceArea->getAllServiceAreaByRegionalId($regionalIdOwner); switch ($indice) { case 'StateId': // só verifica se tem acesso aos Estados if (!($regionalOwnerSA['indice'] == 'StateId')) { $error['messageError'] = 'Sem permissão para criar regional com Estado(s)'; throw new Vtx_UserException($error['messageError']); return; } // verifica se é/são o(s) mesmo(s) Estado(s) if (!Vtx_Util_Array::array_all_in_array($newServiceAreaData['StateId'], $regionalOwnerSA['value']['StateId'])) { $error['messageError'] = 'Sem permissão para criar regional com este(s) Estado(s)'; throw new Vtx_UserException($error['messageError']); return; } break; case 'CityId': //Regional Estadual, pode criar p/ cidades. if ($regionalOwnerSA['indice'] == 'StateId') { return true; } if ($regionalOwnerSA['indice'] == 'NeighborhoodId') { $error['messageError'] = 'Sem permissão para criar regional com esta(s) Cidade(s)'; throw new Vtx_UserException($error['messageError']); return; } //Regional Municipal, apenas para suas cidades. if (!Vtx_Util_Array::array_all_in_array($newServiceAreaData['CityId'], $regionalOwnerSA['value']['CityId'])) { $error['messageError'] = 'Sem permissão para criar regional com esta(s) Cidade(s)'; throw new Vtx_UserException($error['messageError']); return; } break; case 'NeighborhoodId': //Regional Estadual, pode criar p/ cidades. if ($regionalOwnerSA['indice'] == 'StateId') { return true; } //Regional Municipal, pode criar p/ bairros. if ($regionalOwnerSA['indice'] == 'CityId') { return true; } //Regional Bairro, apenas para seus bairros. if (!Vtx_Util_Array::array_all_in_array($newServiceAreaData['NeighborhoodId'], $regionalOwnerSA['value']['NeighborhoodId'])) { $error['messageError'] = 'Sem permissão para criar regional com este(s) Bairro(s)'; throw new Vtx_UserException($error['messageError']); return; } break; default: break; } return true; }
private function getCategorySector() { return Vtx_Util_Array::categorySector($this->getEnterprise()->getCategorySectorId()); }