Пример #1
0
 public function indexAction()
 {
     //$this->_redirect('/?cache');
     //desabilita layout
     //$this->_helper->layout()->disableLayout();
     //echo "teste";
     $this->cache = Zend_Registry::get('cache_FS');
     $devol = new Model_User();
     $user = $devol->getUserById(66);
     //var_dump('user: '******'cache: ', $this->cache);
     $userCache = $this->cache->load('userCache');
     echo "<br><br><br>";
     //var_dump('userCache: ', $userCache);
     //recupera do cache
     if ($userCache == false) {
         //add fechall from db into cache
         $this->cache->save($user, 'userCache');
     }
     echo "<br><br>------------------------";
     $this->cache->save('conteudo variavel teste2 eh este!!', 'teste2');
     $this->cache->save('conteudo variavel teste3 eh este!!', 'teste3');
     echo "<br>teste2: " . $this->cache->load('teste2');
     echo "<br>teste3: " . $this->cache->load('teste3');
 }
Пример #2
0
$u = $p = "";
if (isset($_POST['edit_user'])) {
    if ($_POST['txtuser'] == NULL) {
        $error[] = "Please input your username";
    } else {
        $u = $_POST['txtuser'];
    }
    if ($_POST['txtpass'] != $_POST['txtrepass']) {
        $error[] = "Password not match";
    } else {
        if ($_POST['txtpass'] != "") {
            $p = $_POST['txtpass'];
        } else {
            $p = "none";
        }
    }
    $l = $_POST['level'];
    if ($u && $p && $l) {
        $muser->setUsername($u);
        $muser->setPassword($p);
        $muser->setLevel($l);
        if ($muser->checkUsername($id) == true) {
            $muser->updateUser($id);
            redirect("{$baseurl}/user/list");
        } else {
            $error[] = "Your user name has been registed";
        }
    }
}
$data = $muser->getUserById($id);
require "views/user/edit_view.php";
Пример #3
0
 /**
  * 
  * @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);
 }
Пример #4
0
 public function action_editUser()
 {
     $this->template->show_logout = TRUE;
     $this->template->title = 'Edit user';
     $id = $this->request->param('id');
     $id = isset($_POST['id']) ? $_POST['id'] : $id;
     $user = Model_User::getUserById($id);
     $errors = array();
     if ($_POST) {
         if (isset($_POST['role'])) {
             unset($_POST['role']);
         }
         //
         if ($user['email'] == $_POST['email']) {
             unset($_POST['email']);
         } else {
             if (Model_User::checkEmailExists($_POST['email'])) {
                 $errors[] = 'E-mail address is taken!';
             }
         }
         //
         if ($user['username'] == $_POST['username']) {
             unset($_POST['username']);
         } else {
             if (Model_User::checkUsernameExists($_POST['username'])) {
                 $errors[] = 'Username is taken!';
             }
         }
         //
         if ($_POST['password'] == '') {
             unset($_POST['password']);
         } else {
             $_POST['password'] = Auth::instance()->hash_password($_POST['password']);
         }
         //
         if (empty($errors)) {
             Model_User::editUser($_POST, $_POST['id']);
             $this->redirect('dashboard/users');
         } else {
             $user = Model_User::getUserById($_POST['id']);
         }
     }
     $view = $this->template->content = View::factory('dashboard/users/edit')->set('errors', $errors)->set('user', $user);
     $this->response->body($view);
 }
Пример #5
0
 /**
  * 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);
 }
Пример #6
0
 /**
  * 
  * @param type $questionnaireId
  * @param type $userId
  * @param type $dirName
  * @param type $publicDir
  * @param type $arqName
  * @param type $isRA
  * @return type
  */
 public function makePdfDevolutiveAutoAvaliacaoExecuta($questionnaireId, $userId, $programaId, $dirName, $publicDir, $arqName, $isRA = false, $conclusao = false)
 {
     $modelEnterprise = new Model_Enterprise();
     $modelUser = new Model_User();
     $isRAWithConclusion = $conclusao;
     $objUser = $modelUser->getUserById($userId);
     $objEnterprise = $modelEnterprise->getEnterpriseByUserId($userId);
     $programaTipo = Zend_Registry::get('programaTipo');
     $isSebraeMais = $programaTipo == 'SebraeMais' ? TRUE : FALSE;
     if ($arrBlocksResult = $this->Questionnaire->getBlocksAutoavaliacao($questionnaireId)) {
         //$governancaBlockId = $arrBlocksResult[0];
         //Pegar ID do Zend Registry - setar em DevolutiveController - indexAction
         //Parte 1 - Gestao da Empresa
         $gestaoBlockId = $this->objDevolutive->getBlockIdGestaoEmpresa();
         //50;
         //Parte 2 - Comportamento Empreendededor - igual parte 2 do PSMN
         $comportamentoBlockId = $this->objDevolutive->getBlockIdEmpreendedorismo();
         //51
         //Parte 3 - Responsabilidade Social
         $responsabilidadeSocialBlockId = $this->objDevolutive->getBlockIdResponsabilidadeSocial();
         //52
         //Parte 4 - Praticas Inovacao
         $praticasInovacaoBlockId = $this->objDevolutive->getBlockIdPraticasInovacao();
         //53
         $enterpriseData = new Vtx_Devolutive_Tipo_MPE_getEnterpriseData();
         $arrayDevolutive = new Vtx_Devolutive_Tipo_MPE_getArrayDevolutive();
         //$arrayDevolutiveRAA->getArrayDevolutiveRAA($questionnaireId, $userId, $blockId);
         if (self::OK_DADOS_CADASTRO) {
             list($arrEnterprise, $arrContact, $arrIssues) = $enterpriseData->getEnterpriseData($userId);
         }
         if (self::OK_PARTE_1) {
             //Bloco Gestao da Empresa
             list($arrDevolutiveGes, $arrBlocksGes, $arrCriteriaGes, $arrQuestionnaire) = $arrayDevolutive->getArrayDevolutiveReturn($questionnaireId, $userId, $programaId, $gestaoBlockId);
         }
         if (self::OK_PARTE_2) {
             //Bloco Comportamento Empreendedor
             list($arrDevolutiveBlockId2, $arrBlocksBlockId2, $arrCriteriaBlockId2, $arrQuestionnaire) = $arrayDevolutive->getArrayDevolutiveReturn($questionnaireId, $userId, $programaId, $comportamentoBlockId);
         }
         if (self::OK_PARTE_3) {
             //Bloco Responsabilidade Social
             list($arrDevolutiveBlockId3, $arrBlocksBlockId3, $arrCriteriaBlockId3, $arrQuestionnaire) = $arrayDevolutive->getArrayDevolutiveReturn($questionnaireId, $userId, $programaId, $responsabilidadeSocialBlockId);
             //var_dump ('arrDevolutiveBlockId3: ', $arrDevolutiveBlockId3);
             //echo "<br>";
         }
         if (self::OK_PARTE_4) {
             //Bloco Praticas Inovacao
             list($arrDevolutiveBlockId4, $arrBlocksBlockId4, $arrCriteriaBlockId4, $arrQuestionnaire) = $arrayDevolutive->getArrayDevolutiveReturn($questionnaireId, $userId, $programaId, $praticasInovacaoBlockId);
         }
         if (self::OK_PARTE_1) {
             //dados para Grafico Radar
             list($arrRadarDataGes, $arrTabulationGes, $arrPunctuationGes) = $this->Questionnaire->getRadarData($questionnaireId, $gestaoBlockId, $userId, $programaId);
         }
         $strPathRadar = false;
         if (self::OK_PARTE_1) {
             //ano ciclo
             $qto_operation_beginning = utf8_decode($arrQuestionnaire['operation_beginning']);
             $dta_tmp = explode("/", $qto_operation_beginning);
             $str_ciclo = $dta_tmp[2];
             $this->setStrCiclo($str_ciclo);
             $makeRadarPlot = new Vtx_Devolutive_Tipo_MPE_makeRadarPlot();
             $strPathRadar = $makeRadarPlot->makeRadarPlot($arrCriteriaGes, $arrRadarDataGes, $arrTabulationGes, $arrPunctuationGes, $dirName, $str_ciclo);
             //obj StdClass com dados completos para a tabela de pontuacao
             $objDadosPontuacao = $makeRadarPlot->dadosTabelaPontuacao();
             $makeScoreRAA = new Vtx_Devolutive_Tipo_MPE_makeScoreRAA();
             //$makeScoreRAA->makeScoreRAA($questionnaireId, $userId);
             //seta variaveis para pontuacao do bloco Gestao Empresa
             //em model devolutive tem o metodo que grava esta pontuacao na tb ExecutionPontuacao
             $this->objDevolutive->setGravaPontuacaoGestaoEmpresa(true);
             //$gravaPontuacaoGestaoEmpresa
             $this->objDevolutive->setArrPunctuationGes($arrPunctuationGes);
             //$arrPunctuationGes
             $arrScores = $makeScoreRAA->makeScoreRAA($questionnaireId, $userId, $programaId);
             $scorePart1 = $arrScores['IsgcScore'];
             $scorePart2 = $arrScores['IsgScore'];
         }
         // Desabilita header e footer
         //$pdf->header = 0;
         //$pdf->footer = 0;
         $this->header = 0;
         $this->footer = 0;
         // Prepara variáveis para paginação
         $this->AliasNbPages();
         //insere pdfs da devolutiva
         $pagina = $this->pagina = 1;
         $offSet = 0;
         // Habilita header e footer
         $this->header = 1;
         // Anterior [-] $this->AddPage();
         $this->footer = 1;
         ######## nova CAPA #############################################
         if (self::OK_CAPA) {
             $this->CapaMPE($isRA);
         }
         ####################################################################
         #################################################################
         ## Dados Cadastrais do avaliado
         if (self::OK_DADOS_CADASTRO) {
             $emp = new Vtx_Devolutive_Tipo_MPE_EnterpriseDataMPE($this);
             $emp->dadosEmpresa($arrEnterprise, $arrContact, $arrIssues);
         }
         ########## Fim dados cadastro
         #### comeco Parte 1 da devolutiva
         /**
          * parte 1 eh o minimo exigido para printar a devolutiva
          * 
          */
         if (self::OK_PARTE_1) {
             $devolutiveParte1 = new Vtx_Devolutive_Tipo_MPE_DevolutiveParte1MPE($this);
             $devolutiveParte1->paginasIntroducao();
             ## Cria a imagem RADAR e a capa para a Parte 1
             $this->RadarMPE($arrCriteriaGes, $offSet, $strPathRadar, $scorePart1, $scorePart2);
             //monta tabela de pontuacao para Parte 1/Bloco 1
             $tabelaPontuacao = new Vtx_Devolutive_Tipo_MPE_TabelaPontuacao($this, $objDadosPontuacao);
             //pagina interpretacao radar
             $devolutiveParte1->paginasInterpretacaoRadar();
             //criterios e questoes
             $devolutiveParte1->DevolutiveParte1MPE($arrDevolutiveGes, $arrBlocksGes, $arrCriteriaGes, $offSet, $isRA);
         }
         ######################### Fim parte 1 da devolutiva
         if (self::OK_PARTE_2) {
             // Parte 2
             $getPreenchidoBlockIdEmpreendedorismo = $this->objDevolutive->getPreenchidoBlockIdEmpreendedorismo();
             if ($getPreenchidoBlockIdEmpreendedorismo and !$isSebraeMais) {
                 //checa se respondeu questoes e NÃO é FGA
                 //$this->DevolutiveParte2MPE($arrDevolutiveBlockId2, $arrBlocksBlockId2, $arrCriteriaBlockId2, $offSet);
                 $devolutiveParte2 = new Vtx_Devolutive_Tipo_MPE_DevolutiveParte2MPE($this);
                 $devolutiveParte2->DevolutiveParte2MPE($arrDevolutiveBlockId2, $arrBlocksBlockId2, $arrCriteriaBlockId2, $offSet);
                 //Tabela pontuacao Comportamento Empreendedor
                 new Vtx_Devolutive_Tipo_MPE_PontuacaoCaracteristicaEmpreendedoraPdf($this, $this->objDevolutive);
                 //insere pdfs de Analise Combinacoes
                 $devolutiveParte2->analiseCombinacoes();
             }
         }
         if (self::OK_PARTE_3) {
             // Parte 3
             if ($this->objDevolutive->getPreenchidoBlockIdResponsabilidadeSocial() and !$isSebraeMais) {
                 //checa se respondeu questoes e NÃO é FGA
                 $devolutiveParte3 = new Vtx_Devolutive_Tipo_MPE_DevolutiveParte3MPE($this);
                 $devolutiveParte3->DevolutiveParte3MPE($arrDevolutiveBlockId3, $arrBlocksBlockId3, $arrCriteriaBlockId3, $offSet, $isRA);
             }
         }
         if (self::OK_PARTE_4) {
             // Parte 4
             if ($this->objDevolutive->getPreenchidoBlockIdPraticasInovacao() and !$isSebraeMais) {
                 //checa se respondeu questoes e NÃO é FGA
                 $devolutiveParte4 = new Vtx_Devolutive_Tipo_MPE_DevolutiveParte4MPE($this);
                 $devolutiveParte4->DevolutiveParte4MPE($arrDevolutiveBlockId4, $arrBlocksBlockId4, $arrCriteriaBlockId4, $offSet, $isRA);
             }
         }
         //$thisWithConclusion = serialize($this);
         //$thisOk = unserialize(serialize($this));
         // Parte 5 - Conclusão do avaliador
         if ($isRAWithConclusion) {
             $configDb = Zend_Registry::get('configDb');
             $enterpriseId = $objEnterprise->getId();
             $devolutiveParte5 = new Vtx_Devolutive_Tipo_MPE_DevolutiveParte5MPE($this);
             $devolutiveParte5->DevolutiveParte5MPE($enterpriseId, $configDb->programaIdAvaliador);
             //$this->view->conclusion = $questionnaireConclusionRow->getConclusion();
             /*
             $thisWithConclusion->Output($dirName.'xxx'.$arqName,'F');
             $thisWithConclusion = unserialize($thisWithConclusion);
             // Configura as permissões do arquivo
             chmod($dirName.'xxx'.$arqName,0666);
             */
             $arqName = 'Conclusao_' . $arqName;
             // pegar a ultima devolutiva.
         }
         // Renderização do arquivo PDF
         $this->Output($dirName . $arqName, 'F');
         // Configura as permissões do arquivo
         chmod($dirName . $arqName, 0666);
         if ($strPathRadar) {
             if (file_exists($dirName . 'radarTMP.png')) {
                 // Remove o arquivo temporário do radar
                 unlink($dirName . 'radarTMP.png');
             }
         }
         //del image_bar.png - Questionario Caracteristica Empreendedor
         if (file_exists($dirName . 'image_bar.png')) {
             // Remove o arquivo temporário do radar
             unlink($dirName . 'image_bar.png');
         }
         if (self::OK_DADOS_CADASTRO and !$isRA) {
             //envia email personalizado para usuario
             $this->enviaEmailAposGeracaoDevolutiva($arrEnterprise, $userId, $publicDir . $arqName);
         }
     } else {
         throw new Exception("Faltando o cadastro dos blocos de questões para Questionario MPE.");
     }
     return $publicDir . $arqName;
 }
Пример #7
0
 /**
  * altera password do usuario
  *
  * @param type $IdUser
  * @return type
  */
 public function setPassword($IdUser)
 {
     $senhaRandon = substr(uniqid(), -8);
     //pass com 8 caracteres
     $senhaToMd5 = md5($senhaRandon);
     $pass = Vtx_Util_String::hashMe($senhaToMd5);
     $keypass = $pass['sha'];
     $salt = $pass['salt'];
     $User = new Model_User();
     $userRowData = $User->getUserById($IdUser);
     $userRowData->setKeypass($keypass);
     $userRowData->setSalt($salt);
     $userRowData->save();
     return array('status' => true, 'senhaRandon' => $senhaRandon, 'userObj' => $userRowData);
 }
Пример #8
0
 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;
     }
 }