Esempio n. 1
0
 public function listSystemMenu()
 {
     $menuSistema = Core_Integration_Sica_User::getInfoSystems();
     $urlSica = rtrim(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('urlSica'), '/');
     $listaSistema = '<ul class="dropdown-menu">';
     $total = 1;
     foreach ($menuSistema as $key => $sistema) {
         if (\Core_Integration_Sica_User::getUserSystem() == $sistema['sqSistema']) {
             continue;
         }
         $listaSistema .= '<li>' . '<a href="javascript:Sistemas.verifica(\'' . $urlSica . '\',' . $sistema['sqSistema'] . ');">' . $sistema['sgSistema'] . '</a></li>';
         if ($total == 5) {
             break;
         }
         $total++;
     }
     if (count($menuSistema) - 1 > 4) {
         $listaSistema .= '<li class="divider"></li>';
         $listaSistema .= '<li><a href="' . $urlSica . '/index/home">Todos</a></li>';
     }
     $listaSistema .= '</ul>';
     if (1 === count($menuSistema)) {
         $listaSistema = '';
     }
     return $listaSistema;
 }
Esempio n. 2
0
 public function detalheAction()
 {
     $params = $this->_request->getParams();
     if (!empty($params['id'])) {
         $model = new \Core_Doctrine_DBAL_Event_Listeners_Logger();
         $log = $model->getTrilhaAuditoria(array('paramsColumn' => array(array('column' => 'sq_sistema', 'condition' => '=', 'value' => \Core_Integration_Sica_User::getUserSystem()), array('column' => 'sq_auditoria', 'condition' => '=', 'value' => $params['id']))));
         try {
             if (!empty($log)) {
                 $xml = new SimpleXMLElement($log[0]['xmTrilha']);
                 $xmlCampos = array();
                 foreach ($xml->tabela->coluna as $campo) {
                     $coluna = (string) $campo->nome;
                     $xmlCampos[$coluna] = (string) $campo->valor;
                 }
                 ksort($xmlCampos);
                 $this->view->trilha = $log[0];
                 $this->view->colunas = $xmlCampos;
                 $this->view->xml = $xml;
                 $this->view->tabela = $this->getDadosTabela($xml);
             }
         } catch (Exception $e) {
             $this->view->exception = TRUE;
             $this->view->mensagem = $e->getMessage();
             $this->view->stringXml = new SimpleXMLElement($log[0]['xmTrilha']);
         }
     } else {
         $this->_redirect('/log');
     }
 }
Esempio n. 3
0
 public function getSistemasPorTipoPerfil($sqTipoPerfil = 1, array $arrTipoPerfil = array(1, 2), $exc = TRUE)
 {
     $qBuilder = $this->_em->createQueryBuilder();
     $query = $qBuilder->select('s.sqSistema')->from('app:UsuarioPerfil', 'up')->innerJoin('up.sqUsuario', 'u')->innerJoin('up.sqPerfil', 'p')->innerJoin('p.sqTipoPerfil', 'tp')->innerJoin('p.sqSistema', 's')->where($qBuilder->expr()->in('tp.sqTipoPerfil', ':sqTipoPerfil'))->andWhere($qBuilder->expr()->eq('u.sqUsuario', ':sqUsuario'))->setParameters(array('sqTipoPerfil' => $arrTipoPerfil, 'sqUsuario' => \Core_Integration_Sica_User::getUserId()));
     $result = $query->getQuery()->getResult();
     $arrSistemas = array();
     foreach ($result as $value) {
         $arrSistemas[] = $value['sqSistema'];
     }
     $arrSistemas = array_unique($arrSistemas);
     $sqSistema = \Core_Integration_Sica_User::getUserSystem();
     if ($sqTipoPerfil == 3) {
         $key = array_search($sqSistema, $arrSistemas);
         if ($key !== FALSE) {
             unset($arrSistemas[$key]);
         }
     }
     if (!$arrSistemas || in_array($sqSistema, $arrSistemas) && count($arrSistemas) == 1) {
         if ($exc) {
             \Core_Messaging_Manager::getGateway('Service')->addErrorMessage('MN148');
             throw new \Core_Exception_ServiceLayer_Verification();
         }
     }
     return $arrSistemas;
 }
Esempio n. 4
0
 public function changeSystem()
 {
     $urlSistema = rtrim(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('urlSica'), '/');
     $session = (int) Core_Integration_Sica_User::getUserProfile();
     $sqSistema = (int) Core_Integration_Sica_User::getUserSystem();
     if ($session > 1) {
         return '<li><a href="' . $urlSistema . '/sistema/change-system/sqSistema/' . $sqSistema . '">Alterar Perfil</a></li>';
     }
 }
Esempio n. 5
0
 /**
  *
  */
 protected static function getParams($data, $type, $options, $metodo)
 {
     self::checaOperacaoWs($metodo);
     $sqUsuario = \Core_Integration_Sica_User::getUserId() ? \Core_Integration_Sica_User::getUserId() : null;
     $perfilUsuario = isset($_SESSION["USER"]) ? \Core_Integration_Sica_User::getUserProfileExternal() : true;
     $sistema = \Core_Integration_Sica_User::getInfoSystem(\Core_Integration_Sica_User::getUserSystem());
     $request = new \Zend_Controller_Request_Http();
     $arrRequest = explode('/', $request->getRequestUri());
     $params = array('sqSistema' => (int) $sistema['sqSistema'], 'sgSistema' => (string) $sistema['sgSistema'], 'sqClasse' => 0, 'noClasse' => (string) $arrRequest[1] . '/' . $arrRequest[2], 'sqMetodo' => 0, 'noMetodo' => (string) 'index', 'sqUsuario' => $sqUsuario, 'sgOperacao' => self::$sqOperacao, 'stUsuarioExterno' => (int) $perfilUsuario);
     $params['xmTrilha'] = self::geraTagXml($type);
     return $params;
 }
Esempio n. 6
0
 /**
  *
  */
 protected static function getParams($data, $type, $options, $metodo)
 {
     self::checaOperacaoWs($metodo);
     $session = \Core_Integration_Sica_User::has();
     $sqUsuario = \Core_Integration_Sica_User::getUserId() ? \Core_Integration_Sica_User::getUserId() : null;
     $perfilUsuario = $session ? \Core_Integration_Sica_User::getUserProfileExternal() : true;
     $sistema = \Core_Integration_Sica_User::getInfoSystem(\Core_Integration_Sica_User::getUserSystem());
     $sis = \Zend_Registry::get('doctrine')->getEntityManager()->getRepository('app:Sistema')->findBySgSistema('SICA-e');
     $sqSistema = $session ? $sistema['sqSistema'] : $sis[0]->getSqSistema();
     $sgSistema = $session ? $sistema['sgSistema'] : $sis[0]->getSgSistema();
     $request = new \Zend_Controller_Request_Http();
     $arrRequest = explode('/', $request->getRequestUri());
     $params = array('sqSistema' => (int) $sqSistema, 'sgSistema' => (string) $sgSistema, 'sqClasse' => self::NUM_ZERO, 'noClasse' => (string) $arrRequest[1] . '/' . $arrRequest[2], 'sqMetodo' => self::NUM_ZERO, 'noMetodo' => (string) 'index', 'sqUsuario' => $sqUsuario, 'sgOperacao' => self::$sqOperacao, 'stUsuarioExterno' => (int) $perfilUsuario);
     $params['xmTrilha'] = self::geraTagXml($type);
     return $params;
 }
Esempio n. 7
0
 public function modalSelecionarPerfil()
 {
     $urlSica = rtrim(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('urlSica'), '/') . '/';
     $html = '<div class="modal hide" id="modal-usuario-perfil">
                 <div class="modal-header">
                     <button type="button" class="close" data-dismiss="modal">×</button>
                     <h3>Perfil</h3>
                 </div>
                 <form id="form-user-profile"
                       method="post"
                       name="form-user-profile"
                       action="' . $this->view->urlCurrent(array('controller' => 'usuario-perfil', 'action' => 'user-profile')) . '"
                       class="form-horizontal">
                     <div class="modal-body">
                         <fieldset>
                             <input type="hidden" name="systemId" id="systemId" value="' . \Core_Integration_Sica_User::getUserSystem() . '" />
                             <div class="control-group">
                                 <label class="control-label"><span class="required">*</span> Perfil</label>
                                 <div class="controls">
                                     <select name="sqPerfilUsuarioExterno" class="required" id="sqPerfilUsuarioExterno">';
     $html .= "<option value=\"\">Selecione uma opção</option>";
     foreach ((array) \Core_Integration_Sica_User::getUserAllProfile() as $perfil) {
         $html .= "<option value=\"{$perfil['sqPerfil']}\">";
         $html .= $perfil['noPerfil'] . '</option>';
     }
     $html .= '</select>
                                 </div>
                             </div>
                         </fieldset>
                     </div>
                     <div class="modal-footer">
                         <button class="btn btn-primary">Concluir</button>
                         <a href="#" class="btn" data-dismiss="modal">
                         <i class="icon-remove"></i>
                         Cancelar</a>
                     </div>
                 </form>
             </div>';
     $html .= '<script src="' . $urlSica . $this->view->assetUrl('sica/usuario-externo/sistemas.js') . '" type="text/javascript"></script>';
     return $html;
 }
Esempio n. 8
0
 private static function geraTagXml($columns, $metadata, $args)
 {
     $sistema = Core_Integration_Sica_User::getInfoSystem(Core_Integration_Sica_User::getUserSystem());
     $schema = current($args->getEntityManager()->getConnection()->getSchemaManager()->getSchemaSearchPaths());
     $request = new Zend_Controller_Request_Http();
     $arrRequest = explode('/', $request->getRequestUri());
     $rota = (string) $arrRequest[1] . '/' . $arrRequest[2];
     $vCont = 0;
     $xml = new XMLWriter();
     $xml->openMemory();
     $xml->startDocument('1.0', 'UTF-8');
     $xml->startElement("schema");
     $xml->writeElement("nome", $schema);
     $xml->writeElement("rota", $rota);
     $xml->startElement("tabela");
     $xml->writeElement("nome", $metadata->getTableName());
     foreach ($columns as $key => $value) {
         $xml->startElement("coluna");
         $xml->writeElement("nome", $key);
         $xml->writeElement("valor", $value);
         $xml->endElement();
         $vCont++;
     }
     $xml->endElement();
     $xml->endElement();
     return $xml->outputMemory(true);
 }
Esempio n. 9
0
 /**
  * $sqSistema   = Sigla do sistema
  * $sqClass     = sequencial da class, para indefinido utilize 0 (zero)
  * $sqMetodo    = sequencial do metodo, para indefinido utilize 0 (zero)
  * $noSchema    = Nome do Schema
  * $noTabela    = Nome da tabela
  * $sqUsuario   = Usuario logado
  * $sgOperacao  = I, U, D
  * $columns     = {campo1, campo2, campo3}
  * $values      = {value1, value2, value3}
  * @param \Doctrine\ORM\Event\LifecycleEventArgs $args
  */
 protected static function getParams(LifecycleEventArgs $args)
 {
     $metadata = $args->getEntityManager()->getClassMetadata(get_class($args->getEntity()));
     $sistema = Core_Integration_Sica_User::getInfoSystem(Core_Integration_Sica_User::getUserSystem());
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $params = array('sgSistema' => (string) $sistema['sgSistema'], 'noClasse' => $request->getModuleName() . '/' . $request->getControllerName(), 'noMetodo' => $request->getActionName(), 'sqUsuario' => \Core_Integration_Sica_User::getUserId(), 'sgOperacao' => self::$sqOperacao, 'stUsuarioExterno' => 0);
     $columns = array();
     $values = array();
     $associationMaps = array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
     foreach ($associationMaps as $name) {
         $value = $metadata->getFieldValue($args->getEntity(), $name);
         $column = $metadata->getColumnName($name);
         if ($metadata->hasAssociation($name)) {
             $associationMap = $metadata->getAssociationMapping($name);
             $value = self::validateValue($value, $args);
             if (isset($associationMap['sourceToTargetKeyColumns'])) {
                 $column = key($associationMap['sourceToTargetKeyColumns']);
             } else {
                 $column = $associationMap['fieldName'];
             }
         }
         array_push($columns, $column);
         array_push($values, $value);
     }
     foreach ($values as $key => $value) {
         if (NULL === $value) {
             $values[$key] = '';
         }
         if (!count($value)) {
             $values[$key] = '';
         }
     }
     self::trataAlgo($values);
     $params['xmTrilha'] = self::geraTagXml($columns, $values, $metadata, $args);
     return $params;
 }