Example #1
0
 public function getPresidentRow()
 {
     $President = new Model_President();
     return $President->getPresidentByEnterpriseId($this->getId());
 }
 /**
  * 
  * @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);
 }
Example #3
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;
     }
 }