Commit d9440c262543d6915f1e1120203bf36977701f45

Authored by Adriano César de Oliveira
2 parents 3677daa8 4778226d

Merge branch 'release-1.1.0' of softwarepublico.gov.br:sei/mod-sei-pen into release-1.1.0

PENIntegracao.php
@@ -5,7 +5,7 @@ class PENIntegracao extends SeiIntegracao { @@ -5,7 +5,7 @@ class PENIntegracao extends SeiIntegracao {
5 private static $strDiretorio; 5 private static $strDiretorio;
6 6
7 public function getNome() { 7 public function getNome() {
8 - return 'Módulo de Integração com o Barramento PEN'; 8 + return 'Integração Processo Eletrônico Nacional - PEN';
9 } 9 }
10 10
11 public function getVersao() { 11 public function getVersao() {
@@ -13,7 +13,7 @@ class PENIntegracao extends SeiIntegracao { @@ -13,7 +13,7 @@ class PENIntegracao extends SeiIntegracao {
13 } 13 }
14 14
15 public function getInstituicao() { 15 public function getInstituicao() {
16 - return 'MPDG - Ministério do Planejamento, Desenvolvimento e Gestão'; 16 + return 'Ministério do Planejamento - MPDG (Projeto Colaborativo no Portal do SPB)';
17 } 17 }
18 18
19 public function montarBotaoProcesso(ProcedimentoAPI $objSeiIntegracaoDTO) { 19 public function montarBotaoProcesso(ProcedimentoAPI $objSeiIntegracaoDTO) {
@@ -58,7 +58,7 @@ class PENIntegracao extends SeiIntegracao { @@ -58,7 +58,7 @@ class PENIntegracao extends SeiIntegracao {
58 //Apresenta o botão de expedir processo 58 //Apresenta o botão de expedir processo
59 if ($bolFlagAberto && $bolAcaoExpedirProcesso && $bolProcessoEstadoNormal && $objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo() != ProtocoloRN::$NA_SIGILOSO) { 59 if ($bolFlagAberto && $bolAcaoExpedirProcesso && $bolProcessoEstadoNormal && $objProcedimentoDTO->getStrStaNivelAcessoGlobalProtocolo() != ProtocoloRN::$NA_SIGILOSO) {
60 $numTabBotao = $objPaginaSEI->getProxTabBarraComandosSuperior(); 60 $numTabBotao = $objPaginaSEI->getProxTabBarraComandosSuperior();
61 - $strAcoesProcedimento .= '<a id="validar_expedir_processo" href="' . $objPaginaSEI->formatarXHTML($objSessaoSEI->assinarLink('controlador.php?acao=pen_procedimento_expedir&acao_origem=procedimento_visualizar&acao_retorno=arvore_visualizar&id_procedimento=' . $dblIdProcedimento . '&arvore=1')) . '" tabindex="' . $numTabBotao . '" class="botaoSEI"><img class="infraCorBarraSistema" src="' . $this->getDiretorioImagens() . '/pen_expedir_procedimento.gif" alt="Tramitar Externamente" title="Tramitar Externamente" /></a>'; 61 + $strAcoesProcedimento .= '<a id="validar_expedir_processo" href="' . $objPaginaSEI->formatarXHTML($objSessaoSEI->assinarLink('controlador.php?acao=pen_procedimento_expedir&acao_origem=procedimento_visualizar&acao_retorno=arvore_visualizar&id_procedimento=' . $dblIdProcedimento . '&arvore=1')) . '" tabindex="' . $numTabBotao . '" class="botaoSEI"><img class="infraCorBarraSistema" src="' . $this->getDiretorioImagens() . '/pen_expedir_procedimento.gif" alt="Envio Externo de Processo" title="Envio Externo de Processo" /></a>';
62 } 62 }
63 63
64 //Apresenta o botão da página de recibos 64 //Apresenta o botão da página de recibos
pen_map_hipotese_legal_envio_cadastrar.php
@@ -178,7 +178,7 @@ function onSubmit() { @@ -178,7 +178,7 @@ function onSubmit() {
178 var field = jQuery('select[name=id_hipotese_legal]', form); 178 var field = jQuery('select[name=id_hipotese_legal]', form);
179 179
180 if(field.val() === 'null'){ 180 if(field.val() === 'null'){
181 - alert('Nenhuma "Hipótese Legal - SEI <?php print $objSessao->getStrSiglaOrgaoUnidadeAtual(); ?>" foi selecionada'); 181 + alert('Nenhuma "Hipótese Legal - SEI <?=PaginaSEI::tratarHTML($objSessao->getStrSiglaOrgaoUnidadeAtual())?>" foi selecionada');
182 field.focus(); 182 field.focus();
183 return false; 183 return false;
184 } 184 }
@@ -186,7 +186,7 @@ function onSubmit() { @@ -186,7 +186,7 @@ function onSubmit() {
186 field = jQuery('select[name=id_barramento]', form); 186 field = jQuery('select[name=id_barramento]', form);
187 187
188 if(field.val() === 'null'){ 188 if(field.val() === 'null'){
189 - alert('Nenhum "Hipótese Legal - Tramitação PEN" foi selecionado'); 189 + alert('Nenhum "Hipótese Legal - PEN" foi selecionado');
190 field.focus(); 190 field.focus();
191 return false; 191 return false;
192 } 192 }
@@ -202,13 +202,12 @@ $objPagina-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;); @@ -202,13 +202,12 @@ $objPagina-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;);
202 <?php $objPagina->montarAreaValidacao(); ?> 202 <?php $objPagina->montarAreaValidacao(); ?>
203 <?php $objPagina->abrirAreaDados('12em'); ?> 203 <?php $objPagina->abrirAreaDados('12em'); ?>
204 204
205 - <label for="id_hipotese_legal" class="infraLabelObrigatorio input-label-first">Hipótese Legal - SEI <?php print $objSessao->getStrSiglaOrgaoUnidadeAtual(); ?>:</label>  
206 - 205 + <label for="id_hipotese_legal" class="infraLabelObrigatorio input-label-first">Hipótese Legal - SEI <?=PaginaSEI::tratarHTML($objSessao->getStrSiglaOrgaoUnidadeAtual())?> :</label>
207 <select name="id_hipotese_legal" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>> 206 <select name="id_hipotese_legal" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
208 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdHipoteseLegal(), $arrMapIdHipoteseLegal); ?> 207 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdHipoteseLegal(), $arrMapIdHipoteseLegal); ?>
209 </select> 208 </select>
210 209
211 - <label for="id_barramento" class="infraLabelObrigatorio input-label-third">Hipótese Legal - Tramitação PEN:</label> 210 + <label for="id_barramento" class="infraLabelObrigatorio input-label-third">Hipótese Legal - PEN:</label>
212 <select name="id_barramento" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>> 211 <select name="id_barramento" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
213 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdBarramento(), $arrMapIdBarramento); ?> 212 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdBarramento(), $arrMapIdBarramento); ?>
214 </select> 213 </select>
pen_map_hipotese_legal_recebimento_cadastrar.php
@@ -159,11 +159,11 @@ $objPagina-&gt;montarStyle(); @@ -159,11 +159,11 @@ $objPagina-&gt;montarStyle();
159 ?> 159 ?>
160 <style type="text/css"> 160 <style type="text/css">
161 161
162 -.input-label-first{position:absolute;left:0%;top:0%;width:25%; color: #666!important}  
163 -.input-field-first{position:absolute;left:0%;top:15%;width:25%} 162 +.input-label-first{position:absolute;left:0%;top:40%;width:25%; color: #666!important}
  163 +.input-field-first{position:absolute;left:0%;top:55%;width:25%}
164 164
165 -.input-label-third {position:absolute;left:0%;top:40%;width:25%; color:#666!important}  
166 -.input-field-third {position:absolute;left:0%;top:55%;width:25%;} 165 +.input-label-third {position:absolute;left:0%;top:00%;width:25%; color:#666!important}
  166 +.input-field-third {position:absolute;left:0%;top:15%;width:25%;}
167 167
168 </style> 168 </style>
169 <?php $objPagina->montarJavaScript(); ?> 169 <?php $objPagina->montarJavaScript(); ?>
@@ -204,16 +204,15 @@ $objPagina-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;); @@ -204,16 +204,15 @@ $objPagina-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;);
204 <?php $objPagina->montarAreaValidacao(); ?> 204 <?php $objPagina->montarAreaValidacao(); ?>
205 <?php $objPagina->abrirAreaDados('12em'); ?> 205 <?php $objPagina->abrirAreaDados('12em'); ?>
206 206
207 - <label for="id_hipotese_legal" class="infraLabelObrigatorio input-label-first">Hipótese Legal - SEI <?php print $objSessao->getStrSiglaOrgaoUnidadeAtual(); ?>:</label>  
208 -  
209 - <select name="id_hipotese_legal" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>  
210 - <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdHipoteseLegal(), $arrMapIdHipoteseLegal); ?>  
211 - </select>  
212 -  
213 <label for="id_barramento" class="infraLabelObrigatorio input-label-third">Hipótese Legal - Tramitação PEN:</label> 207 <label for="id_barramento" class="infraLabelObrigatorio input-label-third">Hipótese Legal - Tramitação PEN:</label>
214 <select name="id_barramento" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>> 208 <select name="id_barramento" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
215 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdBarramento(), $arrMapIdBarramento); ?> 209 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdBarramento(), $arrMapIdBarramento); ?>
216 </select> 210 </select>
  211 +
  212 + <label for="id_hipotese_legal" class="infraLabelObrigatorio input-label-first">Hipótese Legal - SEI <?php print $objSessao->getStrSiglaOrgaoUnidadeAtual(); ?>:</label>
  213 + <select name="id_hipotese_legal" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
  214 + <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelHipoteseLegalDTO->getNumIdHipoteseLegal(), $arrMapIdHipoteseLegal); ?>
  215 + </select>
217 216
218 <?php print $objPagina->fecharAreaDados(); ?> 217 <?php print $objPagina->fecharAreaDados(); ?>
219 </form> 218 </form>
pen_map_tipo_documento_envio_cadastrar.php
@@ -9,7 +9,7 @@ require_once dirname(__FILE__) . &#39;/../../SEI.php&#39;; @@ -9,7 +9,7 @@ require_once dirname(__FILE__) . &#39;/../../SEI.php&#39;;
9 try { 9 try {
10 10
11 session_start(); 11 session_start();
12 - 12 + $objSessao = SessaoSEI::getInstance();
13 $objPaginaSEI = PaginaSEI::getInstance(); 13 $objPaginaSEI = PaginaSEI::getInstance();
14 14
15 SessaoSEI::getInstance()->validarLink(); 15 SessaoSEI::getInstance()->validarLink();
@@ -125,11 +125,11 @@ $objPaginaSEI-&gt;montarStyle(); @@ -125,11 +125,11 @@ $objPaginaSEI-&gt;montarStyle();
125 ?> 125 ?>
126 <style type="text/css"> 126 <style type="text/css">
127 127
128 -.input-label-first{position:absolute;left:0%;top:0%;width:25%; color: #666!important}  
129 -.input-field-first{position:absolute;left:0%;top:15%;width:25%} 128 +.input-label-first{position:absolute;left:0%;top:40
  129 +.input-field-first{position:absolute;left:0%;top:55%;width:25%}
130 130
131 -.input-label-third {position:absolute;left:0%;top:40%;width:25%; color:#666!important}  
132 -.input-field-third {position:absolute;left:0%;top:55%;width:25%;} 131 +.input-label-third {position:absolute;left:0%;top:0%;width:25%; color:#666!important}
  132 +.input-field-third {position:absolute;left:0%;top:15%;width:25%;}
133 133
134 </style> 134 </style>
135 <?php $objPaginaSEI->montarJavaScript(); ?> 135 <?php $objPaginaSEI->montarJavaScript(); ?>
@@ -175,16 +175,15 @@ $objPaginaSEI-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;); @@ -175,16 +175,15 @@ $objPaginaSEI-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;);
175 <?php //$objPaginaSEI->montarAreaValidacao(); ?> 175 <?php //$objPaginaSEI->montarAreaValidacao(); ?>
176 <?php $objPaginaSEI->abrirAreaDados('12em'); ?> 176 <?php $objPaginaSEI->abrirAreaDados('12em'); ?>
177 177
178 - <label for="codigo_especie" class="infraLabelObrigatorio input-label-first">Espécie Documental:</label>  
179 -  
180 - <select name="codigo_especie" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>  
181 - <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapEnviadoDTO->getNumCodigoEspecie(), $objTipoDocMapRN->listarParesEspecie()); ?>  
182 - </select>  
183 -  
184 - <label for="id_serie" class="infraLabelObrigatorio input-label-third">Tipo de Documento:</label> 178 + <label for="id_serie" class="infraLabelObrigatorio input-label-third">Tipo de Documento - SEI <?=PaginaSEI::tratarHTML($objSessao->getStrSiglaOrgaoUnidadeAtual())?> :</label>
185 <select name="id_serie" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>> 179 <select name="id_serie" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
186 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapEnviadoDTO->getNumIdSerie(), $arrSerie); ?> 180 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapEnviadoDTO->getNumIdSerie(), $arrSerie); ?>
187 </select> 181 </select>
  182 +
  183 + <label for="codigo_especie" class="infraLabelObrigatorio input-label-first">Espécie Documental PEN:</label>
  184 + <select name="codigo_especie" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
  185 + <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapEnviadoDTO->getNumCodigoEspecie(), $objTipoDocMapRN->listarParesEspecie()); ?>
  186 + </select>
188 187
189 <?php print $objPaginaSEI->fecharAreaDados(); ?> 188 <?php print $objPaginaSEI->fecharAreaDados(); ?>
190 </form> 189 </form>
pen_map_tipo_documento_recebimento_cadastrar.php
@@ -10,6 +10,7 @@ try { @@ -10,6 +10,7 @@ try {
10 10
11 session_start(); 11 session_start();
12 12
  13 + $objSessao = SessaoSEI::getInstance();
13 $objPaginaSEI = PaginaSEI::getInstance(); 14 $objPaginaSEI = PaginaSEI::getInstance();
14 15
15 SessaoSEI::getInstance()->validarLink(); 16 SessaoSEI::getInstance()->validarLink();
@@ -175,12 +176,12 @@ $objPaginaSEI-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;); @@ -175,12 +176,12 @@ $objPaginaSEI-&gt;abrirBody($strTitulo,&#39;onload=&quot;inicializar();&quot;&#39;);
175 <?php //$objPaginaSEI->montarAreaValidacao(); ?> 176 <?php //$objPaginaSEI->montarAreaValidacao(); ?>
176 <?php $objPaginaSEI->abrirAreaDados('12em'); ?> 177 <?php $objPaginaSEI->abrirAreaDados('12em'); ?>
177 178
178 - <label for="codigo_especie" class="infraLabelObrigatorio input-label-first">Espécie Documental:</label> 179 + <label for="codigo_especie" class="infraLabelObrigatorio input-label-first">Espécie Documental PEN:</label>
179 <select name="codigo_especie" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>> 180 <select name="codigo_especie" class="infraSelect input-field-first"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
180 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapRecebidoDTO->getNumCodigoEspecie(), $arrEspecieDocumental); ?> 181 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapRecebidoDTO->getNumCodigoEspecie(), $arrEspecieDocumental); ?>
181 </select> 182 </select>
182 183
183 - <label for="id_serie" class="infraLabelObrigatorio input-label-third">Tipo de Documento:</label> 184 + <label for="id_serie" class="infraLabelObrigatorio input-label-third">Tipo de Documento - SEI <?=PaginaSEI::tratarHTML($objSessao->getStrSiglaOrgaoUnidadeAtual())?> :</label>
184 <select name="id_serie" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>> 185 <select name="id_serie" class="infraSelect input-field-third"<?php if($bolSomenteLeitura): ?> disabled="disabled" readonly="readonly"<?php endif; ?>>
185 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapRecebidoDTO->getNumIdSerie(), $objTipoDocMapRN->listarParesSerie()); ?> 186 <?php print InfraINT::montarSelectArray('', 'Selecione', $objPenRelTipoDocMapRecebidoDTO->getNumIdSerie(), $objTipoDocMapRN->listarParesSerie()); ?>
186 </select> 187 </select>
pen_procedimento_expedido_listar.php
@@ -26,7 +26,7 @@ try { @@ -26,7 +26,7 @@ try {
26 if(get_parent_class(BancoSEI::getInstance()) != 'InfraMySqli') { 26 if(get_parent_class(BancoSEI::getInstance()) != 'InfraMySqli') {
27 $objFiltroDTO->retDthConclusaoAtividade(); 27 $objFiltroDTO->retDthConclusaoAtividade();
28 } 28 }
29 - $objPaginaSEI->prepararPaginacao($objFiltroDTO, 10); 29 + $objPaginaSEI->prepararPaginacao($objFiltroDTO, 50);
30 30
31 BancoSEI::getInstance()->abrirConexao(); 31 BancoSEI::getInstance()->abrirConexao();
32 32
pen_procedimento_expedir.php
@@ -56,8 +56,8 @@ try { @@ -56,8 +56,8 @@ try {
56 56
57 case 'pen_procedimento_expedir': 57 case 'pen_procedimento_expedir':
58 58
59 - $strTitulo = 'Tramitar Externamente';  
60 - $arrComandos[] = '<button type="button" accesskey="E" onclick="enviarForm(this)" value="Tramitar" class="infraButton" style="width:8%;"><span class="infraTeclaAtalho">T</span>ramitar</button>'; 59 + $strTitulo = 'Envio Externo de Processo';
  60 + $arrComandos[] = '<button type="button" accesskey="E" onclick="enviarForm(this)" value="Enviar" class="infraButton" style="width:8%;"><span class="infraTeclaAtalho">E</span>nviar</button>';
61 $arrComandos[] = '<button type="button" accesskey="C" name="btnCancelar" value="Cancelar" onclick="location.href=\'' . $objPaginaSEI->formatarXHTML($objSessaoSEI->assinarLink('controlador.php?acao=' . $objPaginaSEI->getAcaoRetorno() . '&acao_origem=' . $_GET['acao'] . '&acao_destino=' . $_GET['acao'] . $strParametros)) . '\';" class="infraButton"><span class="infraTeclaAtalho">C</span>ancelar</button>'; 61 $arrComandos[] = '<button type="button" accesskey="C" name="btnCancelar" value="Cancelar" onclick="location.href=\'' . $objPaginaSEI->formatarXHTML($objSessaoSEI->assinarLink('controlador.php?acao=' . $objPaginaSEI->getAcaoRetorno() . '&acao_origem=' . $_GET['acao'] . '&acao_destino=' . $_GET['acao'] . $strParametros)) . '\';" class="infraButton"><span class="infraTeclaAtalho">C</span>ancelar</button>';
62 62
63 //TODO: Avaliar a necessidade de validar cada um dos parâmetros do PEN exigidos por essa funcionalidade 63 //TODO: Avaliar a necessidade de validar cada um dos parâmetros do PEN exigidos por essa funcionalidade
@@ -143,7 +143,7 @@ try { @@ -143,7 +143,7 @@ try {
143 //Tratamento da ação de expedir o procedimento 143 //Tratamento da ação de expedir o procedimento
144 if(isset($_POST['sbmExpedir'])) { 144 if(isset($_POST['sbmExpedir'])) {
145 145
146 - $strTituloPagina = "Tramitação do processo $strProtocoloProcedimentoFormatado"; 146 + $strTituloPagina = "Envio externo do processo $strProtocoloProcedimentoFormatado";
147 $objPaginaSEI->prepararBarraProgresso($strTitulo, $strTituloPagina); 147 $objPaginaSEI->prepararBarraProgresso($strTitulo, $strTituloPagina);
148 148
149 $objExpedirProcedimentoDTO = new ExpedirProcedimentoDTO(); 149 $objExpedirProcedimentoDTO = new ExpedirProcedimentoDTO();
@@ -549,7 +549,7 @@ $objPaginaSEI-&gt;montarBarraComandosSuperior($arrComandos); @@ -549,7 +549,7 @@ $objPaginaSEI-&gt;montarBarraComandosSuperior($arrComandos);
549 </div> 549 </div>
550 550
551 <div id="divRepositorioEstruturas" class="infraAreaDados" style="height: 4.5em;"> 551 <div id="divRepositorioEstruturas" class="infraAreaDados" style="height: 4.5em;">
552 - <label id="lblRepositorioEstruturas" for="selRepositorioEstruturas" accesskey="" class="infraLabelObrigatorio">Repositorio de Estruturas Organizacionais:</label> 552 + <label id="lblRepositorioEstruturas" for="selRepositorioEstruturas" accesskey="" class="infraLabelObrigatorio">Repositório de Estruturas Organizacionais:</label>
553 <select id="selRepositorioEstruturas" name="selRepositorioEstruturas" class="infraSelect" onchange="selecionarRepositorio();" tabindex="<?= $objPaginaSEI->getProxTabDados() ?>" > 553 <select id="selRepositorioEstruturas" name="selRepositorioEstruturas" class="infraSelect" onchange="selecionarRepositorio();" tabindex="<?= $objPaginaSEI->getProxTabDados() ?>" >
554 <?= $strItensSelRepositorioEstruturas ?> 554 <?= $strItensSelRepositorioEstruturas ?>
555 </select> 555 </select>
pen_procedimento_expedir_validar.php
@@ -69,7 +69,7 @@ try { @@ -69,7 +69,7 @@ try {
69 } 69 }
70 70
71 if(!array_key_exists('selRepositorioEstruturas', $_POST) || empty($_POST['selRepositorioEstruturas'])) { 71 if(!array_key_exists('selRepositorioEstruturas', $_POST) || empty($_POST['selRepositorioEstruturas'])) {
72 - $objInfraException->adicionarValidacao('Informe o Repositorio de Estruturas Organizacionais', $strProtocoloFormatado); 72 + $objInfraException->adicionarValidacao('Informe o Repositório de Estruturas Organizacionais', $strProtocoloFormatado);
73 } 73 }
74 74
75 if(!array_key_exists('hdnIdUnidade', $_POST) || empty($_POST['hdnIdUnidade'])) { 75 if(!array_key_exists('hdnIdUnidade', $_POST) || empty($_POST['hdnIdUnidade'])) {
rn/PENAgendamentoRN.php
@@ -242,22 +242,20 @@ class PENAgendamentoRN extends InfraRN { @@ -242,22 +242,20 @@ class PENAgendamentoRN extends InfraRN {
242 $cont++; 242 $cont++;
243 $servico[] = 'ProcessarPendenciasRN.php'; 243 $servico[] = 'ProcessarPendenciasRN.php';
244 } 244 }
245 -  
246 - $servicos = implode("\n", $servico);  
247 -  
248 - 245 +
  246 + $strServicos = array_map(function($item){ return "- $item"; }, $servico);
  247 + $strServicos = implode("\n", $strServicos);
249 248
250 if ($cont > 0) { 249 if ($cont > 0) {
251 - $msg = "Falha na execução. \n Os seguintes serviços não estão rodando: \n $servicos";  
252 -// LogSEI::getInstance()->gravar(); 250 + $msg = "Identificada inconsistência nos serviços de integração com o Processo Eletrônico Nacional - PEN.\n" .
  251 + "Os seguintes serviços necessários para o correto funcionamento da integração não estão ativos: \n $strServicos \n\n" .
  252 + "Favor, entrar em contato com a equipe de suporte técnico.";
253 throw new InfraException($msg, $e); 253 throw new InfraException($msg, $e);
254 } else { 254 } else {
255 LogSEI::getInstance()->gravar("Todos os serviços estão rodando."); 255 LogSEI::getInstance()->gravar("Todos os serviços estão rodando.");
256 } 256 }
257 -// $objInfraParametro = new InfraParametro(BancoSEI::getInstance());  
258 -// InfraMail::enviarConfigurado(ConfiguracaoSEI::getInstance(), $objInfraParametro->getValor('SEI_EMAIL_SISTEMA'), $objInfraParametro->getValor('SEI_EMAIL_ADMINISTRADOR'), null, null, 'Teste Agendamento SEI', 'Agendamento SEI executado com sucesso.');  
259 } catch (Exception $e) { 257 } catch (Exception $e) {
260 - throw new InfraException('Erro ao rodar verificação de status do serviços Gearmand e Supervisord', $e); 258 + throw new InfraException('Erro ao analisar status do serviços Gearmand e Supervisord', $e);
261 } 259 }
262 } 260 }
263 261
@@ -290,7 +288,7 @@ class PENAgendamentoRN extends InfraRN { @@ -290,7 +288,7 @@ class PENAgendamentoRN extends InfraRN {
290 continue; 288 continue;
291 } 289 }
292 290
293 - $objDTO->setStrNome($hipotese->nome); 291 + $objDTO->setStrNome(utf8_decode($hipotese->nome));
294 292
295 if ($hipotese->status) { 293 if ($hipotese->status) {
296 $objDTO->setStrAtivo('S'); 294 $objDTO->setStrAtivo('S');
@@ -298,12 +296,12 @@ class PENAgendamentoRN extends InfraRN { @@ -298,12 +296,12 @@ class PENAgendamentoRN extends InfraRN {
298 $objDTO->setStrAtivo('N'); 296 $objDTO->setStrAtivo('N');
299 } 297 }
300 298
301 - //Caso n?o exista a hip?tese ir? cadastra-la no sei. 299 + //Caso n?o exista a hipótese irá cadastra-la no sei.
302 if (empty($objConsulta)) { 300 if (empty($objConsulta)) {
303 301
304 $objBD->cadastrar($objDTO); 302 $objBD->cadastrar($objDTO);
305 } else { 303 } else {
306 - //Caso contr?rio apenas ir? atualizar os dados. 304 + //Caso contrário apenas irá atualizar os dados.
307 $objDTO->setNumIdHipoteseLegal($objConsulta->getNumIdHipoteseLegal()); 305 $objDTO->setNumIdHipoteseLegal($objConsulta->getNumIdHipoteseLegal());
308 $objBD->alterar($objDTO); 306 $objBD->alterar($objDTO);
309 } 307 }
@@ -315,45 +313,4 @@ class PENAgendamentoRN extends InfraRN { @@ -315,45 +313,4 @@ class PENAgendamentoRN extends InfraRN {
315 throw new InfraException('Erro no agendamento das Hipóteses Legais', $e); 313 throw new InfraException('Erro no agendamento das Hipóteses Legais', $e);
316 } 314 }
317 } 315 }
318 -  
319 } 316 }
320 -  
321 -// $client = new GearmanClient();  
322 -// $client->addServer('localhost', 4730);  
323 -// $client->setCreatedCallback("create_change");  
324 -// $client->setDataCallback("data_change");  
325 -// $client->setStatusCallback("status_change");  
326 -// $client->setCompleteCallback("complete_change");  
327 -// $client->setFailCallback("fail_change");  
328 -// $data_array =array('mydata'=>'task');  
329 -// $task= $client->addTask("reverse", "mydata", $data_array);  
330 -// $task2= $client->addTaskLow("reverse", "task", NULL);  
331 -// //$result = $client->do("reverse", "teste");  
332 -// $client->runTasks();  
333 -// echo "DONE\n" . $result;  
334 -// function create_change($task)  
335 -// {  
336 -// echo "CREATED: " . $task->jobHandle() . "\n";  
337 -// }  
338 -// function status_change($task)  
339 -// {  
340 -// echo "STATUS: " . $task->jobHandle() . " - " . $task->taskNumerator() .  
341 -// "/" . $task->taskDenominator() . "\n";  
342 -// }  
343 -// function complete_change($task)  
344 -// {  
345 -// echo "COMPLETE: " . $task->jobHandle() . ", " . $task->data() . "\n";  
346 -// }  
347 -// function fail_change($task)  
348 -// {  
349 -// echo "FAILED: " . $task->jobHandle() . "\n";  
350 -// }  
351 -// function data_change($task)  
352 -// {  
353 -// echo "DATA: " . $task->data() . "\n";  
354 -// }  
355 -// Function Client_error()  
356 -// {  
357 -// if (! $client->runTasks())  
358 -// return $client->error() ;  
359 -// }  
360 \ No newline at end of file 317 \ No newline at end of file
rn/PenAtualizadorRN.php
@@ -82,17 +82,24 @@ abstract class PenAtualizadorRN extends InfraRN { @@ -82,17 +82,24 @@ abstract class PenAtualizadorRN extends InfraRN {
82 * 82 *
83 * @return null 83 * @return null
84 */ 84 */
85 - protected function finalizar() {  
86 -  
87 - $this->logar('TEMPO TOTAL DE EXECUCAO: ' . InfraUtil::verificarTempoProcessamento($this->numSeg) . ' s'); 85 + protected function finalizar($strMsg=null, $bolErro=false){
  86 + if (!$bolErro) {
  87 + $this->numSeg = InfraUtil::verificarTempoProcessamento($this->numSeg);
  88 + $this->logar('TEMPO TOTAL DE EXECUCAO: ' . $this->numSeg . ' s');
  89 + }else{
  90 + $strMsg = 'ERRO: '.$strMsg;
  91 + }
88 92
89 - $this->objDebug->setBolLigado(false);  
90 - $this->objDebug->setBolDebugInfra(false);  
91 - $this->objDebug->setBolEcho(false); 93 + if ($strMsg!=null){
  94 + $this->logar($strMsg);
  95 + }
92 96
93 - print PHP_EOL;  
94 - die();  
95 - } 97 + InfraDebug::getInstance()->setBolLigado(false);
  98 + InfraDebug::getInstance()->setBolDebugInfra(false);
  99 + InfraDebug::getInstance()->setBolEcho(false);
  100 + $this->numSeg = 0;
  101 + die;
  102 + }
96 103
97 /** 104 /**
98 * Construtor 105 * Construtor
rn/PenAtualizarSeiRN.php
@@ -6,7 +6,8 @@ @@ -6,7 +6,8 @@
6 */ 6 */
7 class PenAtualizarSeiRN extends PenAtualizadorRN { 7 class PenAtualizarSeiRN extends PenAtualizadorRN {
8 8
9 - private $nomeParametroModulo = 'PEN_VERSAO_MODULO_SEI'; 9 + const PARAMETRO_VERSAO_MODULO_ANTIGO = 'PEN_VERSAO_MODULO_SEI';
  10 + const PARAMETRO_VERSAO_MODULO = 'VERSAO_MODULO_PEN';
10 11
11 public function __construct() { 12 public function __construct() {
12 parent::__construct(); 13 parent::__construct();
@@ -32,37 +33,33 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -32,37 +33,33 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
32 } 33 }
33 BancoSEI::getInstance()->executarSql('DROP TABLE pen_sei_teste'); 34 BancoSEI::getInstance()->executarSql('DROP TABLE pen_sei_teste');
34 35
35 -  
36 - $objInfraParametro = new InfraParametro($this->objInfraBanco);  
37 -  
38 - //$strVersaoAtual = $objInfraParametro->getValor('SEI_VERSAO', false);  
39 - $strVersaoModuloPen = $objInfraParametro->getValor($this->nomeParametroModulo, false); 36 + $objInfraParametro = new InfraParametro($this->objInfraBanco);
40 37
41 - //VERIFICANDO QUAL VERSAO DEVE SER INSTALADA NESTA EXECUCAO  
42 - if (InfraString::isBolVazia($strVersaoModuloPen)) {  
43 - //nao tem nenhuma versao ainda, instalar todas  
44 - $this->instalarV100();  
45 - $this->instalarV101();  
46 - $this->instalarV102();  
47 - } else if ($strVersaoModuloPen == '1.0.0') {  
48 - $this->instalarV101();  
49 - $this->instalarV102();  
50 - } else if ($strVersaoModuloPen == '1.0.1') {  
51 - $this->instalarV102();  
52 - } else if ($strVersaoModuloPen == '1.1.0') { 38 + // Aplicação de scripts de atualização de forma incremental
  39 + // Ausência de [break;] proposital para realizar a atualização incremental de versões
  40 + $strVersaoModuloPen = $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO, false) ?: $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO_ANTIGO, false);
  41 + switch ($strVersaoModuloPen) {
  42 + case '': $this->instalarV100(); // Nenhuma versão instalada
  43 + case '1.0.0': $this->instalarV101();
  44 + case '1.0.1': $this->instalarV110();
  45 + case '1.1.0': $this->instalarV111();
  46 +
  47 + break;
  48 + default:
  49 + $this->finalizar('VERSAO DO MÓDULO JÁ CONSTA COMO ATUALIZADA');
  50 + break;
53 } 51 }
54 52
55 - 53 + $this->finalizar('FIM');
56 InfraDebug::getInstance()->setBolDebugInfra(true); 54 InfraDebug::getInstance()->setBolDebugInfra(true);
57 } catch (Exception $e) { 55 } catch (Exception $e) {
58 -  
59 InfraDebug::getInstance()->setBolLigado(false); 56 InfraDebug::getInstance()->setBolLigado(false);
60 InfraDebug::getInstance()->setBolDebugInfra(false); 57 InfraDebug::getInstance()->setBolDebugInfra(false);
61 InfraDebug::getInstance()->setBolEcho(false); 58 InfraDebug::getInstance()->setBolEcho(false);
62 throw new InfraException('Erro atualizando VERSAO.', $e); 59 throw new InfraException('Erro atualizando VERSAO.', $e);
63 } 60 }
64 } 61 }
65 - 62 +
66 /** 63 /**
67 * Cria um novo parâmetro 64 * Cria um novo parâmetro
68 * @return int Código do Parametro gerado 65 * @return int Código do Parametro gerado
@@ -916,15 +913,9 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -916,15 +913,9 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
916 913
917 $objInfraSequencia->criarSequencia('md_pen_recibo_tramite_hash', '1', '1', '9999999999'); 914 $objInfraSequencia->criarSequencia('md_pen_recibo_tramite_hash', '1', '1', '9999999999');
918 } 915 }
919 -  
920 - /* ---------- antigo método (instalarV008R004S006WI001) ---------- */  
921 -// $objMetaBD = $this->inicializarObjMetaBanco();  
922 -// $objMetaBD->alterarColuna('md_pen_recibo_tramite', 'dth_recebimento', 'VARCHAR(60)', PenMetaBD::NNULLO);  
923 -// $objMetaBD->alterarColuna('md_pen_recibo_tramite_enviado', 'dth_recebimento', 'VARCHAR(60)', PenMetaBD::NNULLO);  
924 -// $objMetaBD->alterarColuna('md_pen_recibo_tramite_recebido', 'dth_recebimento', 'VARCHAR(60)', PenMetaBD::NNULLO);  
925 - 916 +
926 $objInfraParametroDTO = new InfraParametroDTO(); 917 $objInfraParametroDTO = new InfraParametroDTO();
927 - $objInfraParametroDTO->setStrNome($this->nomeParametroModulo); 918 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
928 $objInfraParametroDTO->setStrValor('1.0.0'); 919 $objInfraParametroDTO->setStrValor('1.0.0');
929 920
930 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 921 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
@@ -995,33 +986,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -995,33 +986,6 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
995 $objHipoteseLegalDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC); 986 $objHipoteseLegalDTO->setOrdStrNome(InfraDTO::$TIPO_ORDENACAO_ASC);
996 $objHipoteseLegalDTO->retNumIdHipoteseLegal(); 987 $objHipoteseLegalDTO->retNumIdHipoteseLegal();
997 $objHipoteseLegalDTO->retStrNome(); 988 $objHipoteseLegalDTO->retStrNome();
998 -  
999 - /* $objHipoteseLegalBD = new HipoteseLegalBD($this->inicializarObjInfraIBanco());  
1000 - $arrMapIdHipoteseLegal = InfraArray::converterArrInfraDTO($objHipoteseLegalBD->listar($objHipoteseLegalDTO), 'Nome', 'IdHipoteseLegal');  
1001 -  
1002 - if(!empty($arrMapIdHipoteseLegal)) {  
1003 -  
1004 - $objPenHipoteseLegalDTO = new PenHipoteseLegalDTO();  
1005 - $objPenHipoteseLegalBD = new PenHipoteseLegalBD($this->inicializarObjInfraIBanco());  
1006 -  
1007 - $fnCadastrar = function($numIdHipoteseLegal, $strNome = '') use($objPenHipoteseLegalDTO, $objPenHipoteseLegalBD){  
1008 -  
1009 - $objPenHipoteseLegalDTO->unSetTodos();  
1010 - $objPenHipoteseLegalDTO->setNumIdHipoteseLegal($numIdHipoteseLegal);  
1011 -  
1012 - if($objPenHipoteseLegalBD->contar($objPenHipoteseLegalDTO) == 0){  
1013 -  
1014 - $objPenHipoteseLegalDTO->setStrAtivo('S');  
1015 - $objPenHipoteseLegalDTO->setStrNome($strNome);  
1016 - $objPenHipoteseLegalBD->cadastrar($objPenHipoteseLegalDTO);  
1017 - }  
1018 - };  
1019 -  
1020 - foreach($arrMapIdHipoteseLegal as $numIdHipoteseLegal => $strNome) {  
1021 -  
1022 - $fnCadastrar($numIdHipoteseLegal, $strNome);  
1023 - }  
1024 - }*/  
1025 989
1026 $objMetaBD = $this->inicializarObjMetaBanco(); 990 $objMetaBD = $this->inicializarObjMetaBanco();
1027 991
@@ -1058,7 +1022,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1058,7 +1022,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1058 1022
1059 /* altera o parâmetro da versão de banco */ 1023 /* altera o parâmetro da versão de banco */
1060 $objInfraParametroDTO = new InfraParametroDTO(); 1024 $objInfraParametroDTO = new InfraParametroDTO();
1061 - $objInfraParametroDTO->setStrNome($this->nomeParametroModulo); 1025 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1062 $objInfraParametroDTO->setStrValor('1.0.0'); 1026 $objInfraParametroDTO->setStrValor('1.0.0');
1063 $objInfraParametroDTO->retTodos(); 1027 $objInfraParametroDTO->retTodos();
1064 1028
@@ -1069,7 +1033,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1069,7 +1033,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1069 } 1033 }
1070 1034
1071 /* Contem atualizações da versao 1.1.0 do modulo */ 1035 /* Contem atualizações da versao 1.1.0 do modulo */
1072 - protected function instalarV102() { 1036 + protected function instalarV110() {
1073 $objMetaBD = $this->objMeta; 1037 $objMetaBD = $this->objMeta;
1074 1038
1075 //Adiciona a coluna de indentificação nas hipóteses que vem do barramento 1039 //Adiciona a coluna de indentificação nas hipóteses que vem do barramento
@@ -1121,7 +1085,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1121,7 +1085,7 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1121 1085
1122 /* altera o parâmetro da versão de banco */ 1086 /* altera o parâmetro da versão de banco */
1123 $objInfraParametroDTO = new InfraParametroDTO(); 1087 $objInfraParametroDTO = new InfraParametroDTO();
1124 - $objInfraParametroDTO->setStrNome($this->nomeParametroModulo); 1088 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1125 $objInfraParametroDTO->setStrValor('1.0.1'); 1089 $objInfraParametroDTO->setStrValor('1.0.1');
1126 $objInfraParametroDTO->retTodos(); 1090 $objInfraParametroDTO->retTodos();
1127 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 1091 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
@@ -1130,4 +1094,20 @@ class PenAtualizarSeiRN extends PenAtualizadorRN { @@ -1130,4 +1094,20 @@ class PenAtualizarSeiRN extends PenAtualizadorRN {
1130 $objInfraParametroBD->alterar($objInfraParametroDTO); 1094 $objInfraParametroBD->alterar($objInfraParametroDTO);
1131 } 1095 }
1132 1096
  1097 + /* Contem atualizações da versao 1.1.1 do módulo */
  1098 + protected function instalarV111() {
  1099 +
  1100 + //Ajuste em nome da variável de versão do módulo VERSAO_MODULO_PEN
  1101 + BancoSEI::getInstance()->executarSql("update infra_parametro set nome = '" . self::PARAMETRO_VERSAO_MODULO . "' where nome = '" . self::PARAMETRO_VERSAO_MODULO_ANTIGO . "'");
  1102 +
  1103 + /* altera o parâmetro da versão de banco */
  1104 + $objInfraParametroDTO = new InfraParametroDTO();
  1105 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO);
  1106 + $objInfraParametroDTO->retTodos();
  1107 + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
  1108 + $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);
  1109 + $objInfraParametroDTO->setStrValor('1.1.1');
  1110 + $objInfraParametroBD->alterar($objInfraParametroDTO);
  1111 + }
  1112 +
1133 } 1113 }
rn/PenAtualizarSipRN.php
@@ -1,353 +0,0 @@ @@ -1,353 +0,0 @@
1 -<?php  
2 -require_once dirname(__FILE__) . '/../../../../sip/Sip.php';  
3 -  
4 -/**  
5 - * Atualizador do sistema SIP para instalar/atualizar o módulo PEN  
6 - *  
7 - * @author Join Tecnologia  
8 - */  
9 -class PenAtualizarSipRN extends PenAtualizadorRN {  
10 -  
11 - protected $versaoMinRequirida = '1.30.0';  
12 - protected $sei_versao = 'PEN_VERSAO_MODULO_SIP';  
13 -  
14 - private $arrRecurso = array();  
15 - private $arrMenu = array();  
16 -  
17 - /**  
18 - * Retorna/Cria a conexão com o banco de dados  
19 - *  
20 - * @return InfraIBanco  
21 - */  
22 - protected function inicializarObjInfraIBanco() {  
23 - if(empty($this->objBanco)) {  
24 -  
25 - $this->objBanco = BancoSip::getInstance();  
26 - }  
27 - return $this->objBanco;  
28 - }  
29 -  
30 - /**  
31 - * Retorna o ID do sistema  
32 - *  
33 - * @return int  
34 - */  
35 - protected function getNumIdSistema($strSigla = 'SIP'){  
36 -  
37 - $objDTO = new SistemaDTO();  
38 - $objDTO->setStrSigla($strSigla);  
39 - $objDTO->setNumMaxRegistrosRetorno(1);  
40 - $objDTO->retNumIdSistema();  
41 -  
42 - $objRN = new SistemaRN();  
43 - $objDTO = $objRN->consultar($objDTO);  
44 -  
45 - return (empty($objDTO)) ? '0' : $objDTO->getNumIdSistema();  
46 - }  
47 -  
48 - /**  
49 - *  
50 - * @return int Código do Menu  
51 - */  
52 - protected function getNumIdMenu($strMenu = 'Principal', $numIdSistema = 0){  
53 -  
54 - $objDTO = new MenuDTO();  
55 - $objDTO->setNumIdSistema($numIdSistema);  
56 - $objDTO->setStrNome($strMenu);  
57 - $objDTO->setNumMaxRegistrosRetorno(1);  
58 - $objDTO->retNumIdMenu();  
59 -  
60 - $objRN = new MenuRN();  
61 - $objDTO = $objRN->consultar($objDTO);  
62 -  
63 - if(empty($objDTO)){  
64 - throw new InfraException('Menu '.$strMenu.' não encontrado.');  
65 - }  
66 -  
67 - return $objDTO->getNumIdMenu();  
68 - }  
69 -  
70 - /**  
71 - *  
72 - * @return int Código do Recurso gerado  
73 - */  
74 - protected function criarRecurso($strNome = '', $strDescricao = null, $numIdSistema = 0){  
75 -  
76 - $objDTO = new RecursoDTO();  
77 - $objDTO->setNumIdSistema($numIdSistema);  
78 - $objDTO->setStrNome($strNome);  
79 - $objDTO->setNumMaxRegistrosRetorno(1);  
80 - $objDTO->retNumIdRecurso();  
81 -  
82 - $objBD = new RecursoBD($this->getObjInfraIBanco());  
83 - $objDTO = $objBD->consultar($objDTO);  
84 -  
85 - if(empty($objDTO)){  
86 -  
87 - $objDTO = new RecursoDTO();  
88 - $objDTO->setNumIdRecurso(null);  
89 - $objDTO->setStrDescricao($strDescricao);  
90 - $objDTO->setNumIdSistema($numIdSistema);  
91 - $objDTO->setStrNome($strNome);  
92 - $objDTO->setStrCaminho('controlador.php?acao='.$strNome);  
93 - $objDTO->setStrSinAtivo('S');  
94 -  
95 - $objDTO = $objBD->cadastrar($objDTO);  
96 - }  
97 -  
98 - $this->arrRecurso[] = $objDTO->getNumIdRecurso();  
99 -  
100 - return $objDTO->getNumIdRecurso();  
101 - }  
102 -  
103 - /**  
104 - * Cria um menu  
105 - *  
106 - * @return int  
107 - */  
108 - protected function criarMenu($strRotulo = '', $numSequencia = 10, $numIdItemMenuPai = null, $numIdMenu = null, $numIdRecurso = null, $numIdSistema = 0){  
109 -  
110 - $objDTO = new ItemMenuDTO();  
111 - $objDTO->setNumIdItemMenuPai($numIdItemMenuPai);  
112 - $objDTO->setNumIdSistema($numIdSistema);  
113 - $objDTO->setStrRotulo($strRotulo);  
114 - $objDTO->setNumIdRecurso($numIdRecurso);  
115 - $objDTO->setNumMaxRegistrosRetorno(1);  
116 - $objDTO->retNumIdItemMenu();  
117 -  
118 - $objBD = new ItemMenuBD($this->inicializarObjInfraIBanco());  
119 - $objDTO = $objBD->consultar($objDTO);  
120 -  
121 - if(empty($objDTO)){  
122 -  
123 - $objDTO = new ItemMenuDTO();  
124 - $objDTO->setNumIdMenu($numIdMenu);  
125 - $objDTO->setNumIdMenuPai($numIdMenu);  
126 - $objDTO->setNumIdItemMenu(null);  
127 - $objDTO->setNumIdItemMenuPai($numIdItemMenuPai);  
128 - $objDTO->setNumIdSistema($numIdSistema);  
129 - $objDTO->setNumIdRecurso($numIdRecurso);  
130 - $objDTO->setStrRotulo($strRotulo);  
131 - $objDTO->setStrDescricao(null);  
132 - $objDTO->setNumSequencia($numSequencia);  
133 - $objDTO->setStrSinNovaJanela('N');  
134 - $objDTO->setStrSinAtivo('S');  
135 -  
136 - $objDTO = $objBD->cadastrar($objDTO);  
137 - }  
138 -  
139 - if(!empty($numIdRecurso)) {  
140 -  
141 - $this->arrMenu[] = array($objDTO->getNumIdItemMenu(), $numIdMenu, $numIdRecurso);  
142 - }  
143 -  
144 - return $objDTO->getNumIdItemMenu();  
145 - }  
146 -  
147 - public function addRecursosToPerfil($numIdPerfil, $numIdSistema){  
148 -  
149 - if(!empty($this->arrRecurso)) {  
150 -  
151 - $objDTO = new RelPerfilRecursoDTO();  
152 - $objBD = new RelPerfilRecursoBD($this->inicializarObjInfraIBanco());  
153 -  
154 - foreach($this->arrRecurso as $numIdRecurso) {  
155 -  
156 - $objDTO->setNumIdSistema($numIdSistema);  
157 - $objDTO->setNumIdPerfil($numIdPerfil);  
158 - $objDTO->setNumIdRecurso($numIdRecurso);  
159 -  
160 - if($objBD->contar($objDTO) == 0) {  
161 - $objBD->cadastrar($objDTO);  
162 - }  
163 - }  
164 - }  
165 - }  
166 -  
167 - public function addMenusToPerfil($numIdPerfil, $numIdSistema){  
168 -  
169 - if(!empty($this->arrMenu)) {  
170 -  
171 - $objDTO = new RelPerfilItemMenuDTO();  
172 - $objBD = new RelPerfilItemMenuBD($this->inicializarObjInfraIBanco());  
173 -  
174 - foreach($this->arrMenu as $array) {  
175 -  
176 - list($numIdItemMenu, $numIdMenu, $numIdRecurso) = $array;  
177 -  
178 - $objDTO->setNumIdPerfil($numIdPerfil);  
179 - $objDTO->setNumIdSistema($numIdSistema);  
180 - $objDTO->setNumIdRecurso($numIdRecurso);  
181 - $objDTO->setNumIdMenu($numIdMenu);  
182 - $objDTO->setNumIdItemMenu($numIdItemMenu);  
183 -  
184 - if($objBD->contar($objDTO) == 0) {  
185 - $objBD->cadastrar($objDTO);  
186 - }  
187 - }  
188 - }  
189 - }  
190 -  
191 - public function atribuirPerfil($numIdSistema){  
192 -  
193 - $objDTO = new PerfilDTO();  
194 - $objBD = new PerfilBD($this->inicializarObjInfraIBanco());  
195 - $objRN = $this;  
196 -  
197 - // Vincula a um perfil os recursos e menus adicionados nos métodos criarMenu e criarReturso  
198 - $fnCadastrar = function($strNome, $numIdSistema) use($objDTO, $objBD, $objRN) {  
199 -  
200 - $objDTO->unSetTodos();  
201 - $objDTO->setNumIdSistema($numIdSistema);  
202 - $objDTO->setStrNome($strNome, InfraDTO::$OPER_LIKE);  
203 - $objDTO->setNumMaxRegistrosRetorno(1);  
204 - $objDTO->retNumIdPerfil();  
205 -  
206 - $objPerfilDTO = $objBD->consultar($objDTO);  
207 -  
208 - if(!empty($objPerfilDTO)) {  
209 - $objRN->addRecursosToPerfil($objPerfilDTO->getNumIdPerfil(), $numIdSistema);  
210 - $objRN->addMenusToPerfil($objPerfilDTO->getNumIdPerfil(), $numIdSistema);  
211 - }  
212 - };  
213 -  
214 - //$fnCadastrar('ADMINISTRADOR', $numIdSistema);  
215 - //$fnCadastrar('BASICO', $numIdSistema);  
216 - }  
217 -  
218 - /**  
219 - * Instala/Atualiza os módulo PEN para versão 1.0  
220 - */  
221 - protected function instalarV001(){  
222 -  
223 - $numIdSistema = $this->getNumIdSistema('SEI');  
224 - $numIdMenu = $this->getNumIdMenu('Principal', $numIdSistema);  
225 -  
226 - //----------------------------------------------------------------------  
227 - // Expedir procedimento  
228 - //----------------------------------------------------------------------  
229 - $this->criarRecurso('pen_procedimento_expedir', 'Expedir Procedimento', $numIdSistema);  
230 - $this->criarRecurso('apensados_selecionar_expedir_procedimento', 'Processos Apensados', $numIdSistema);  
231 - $numIdRecurso = $this->criarRecurso('pen_procedimento_expedido_listar', 'Processos Expedidos', $numIdSistema);  
232 - $this->criarMenu('Processos Expedidos', 55, null, $numIdMenu, $numIdRecurso, $numIdSistema);  
233 - //----------------------------------------------------------------------  
234 - // Mapeamento de documentos enviados  
235 - //----------------------------------------------------------------------  
236 - $this->criarRecurso('pen_map_tipo_documento_envio_visualizar', 'Visualização de mapeamento de documentos enviados', $numIdSistema);  
237 -  
238 - // Acha o menu existente de Tipos de Documento  
239 - $objItemMenuDTO = new ItemMenuDTO();  
240 - $objItemMenuDTO->setNumIdSistema($numIdSistema);  
241 - $objItemMenuDTO->setNumIdMenu($numIdMenu);  
242 - $objItemMenuDTO->setStrRotulo('Tipos de Documento');  
243 - $objItemMenuDTO->setNumMaxRegistrosRetorno(1);  
244 - $objItemMenuDTO->retNumIdItemMenu();  
245 -  
246 - $objItemMenuBD = new ItemMenuBD($this->inicializarObjInfraIBanco());  
247 - $objItemMenuDTO = $objItemMenuBD->consultar($objItemMenuDTO);  
248 -  
249 - if(empty($objItemMenuDTO)) {  
250 - throw new InfraException('Menu "Tipo de Documentos" não foi localizado');  
251 - }  
252 -  
253 - $numIdItemMenuPai = $objItemMenuDTO->getNumIdItemMenu();  
254 -  
255 - // Gera o submenu Mapeamento  
256 - $_numIdItemMenuPai = $this->criarMenu('Mapeamento', 50, $numIdItemMenuPai, $numIdMenu, null, $numIdSistema);  
257 -  
258 - // Gera o submenu Mapeamento > Envio  
259 - $numIdItemMenuPai = $this->criarMenu('Envio', 10, $_numIdItemMenuPai, $numIdMenu, null, $numIdSistema);  
260 -  
261 - // Gera o submenu Mapeamento > Envio > Cadastrar  
262 - $numIdRecurso = $this->criarRecurso('pen_map_tipo_documento_envio_cadastrar', 'Cadastro de mapeamento de documentos enviados', $numIdSistema);  
263 - $this->criarMenu('Cadastrar', 10, $numIdItemMenuPai, $numIdMenu, $numIdRecurso, $numIdSistema);  
264 -  
265 - // Gera o submenu Mapeamento > Envio > Listar  
266 - $numIdRecurso = $this->criarRecurso('pen_map_tipo_documento_envio_listar', 'Listagem de mapeamento de documentos enviados', $numIdSistema);  
267 - $this->criarMenu('Listar', 20, $numIdItemMenuPai, $numIdMenu, $numIdRecurso, $numIdSistema);  
268 -  
269 - // Gera o submenu Mapeamento > Recebimento  
270 - $numIdItemMenuPai = $this->criarMenu('Recebimento', 20, $_numIdItemMenuPai, $numIdMenu, null, $numIdSistema);  
271 -  
272 - // Gera o submenu Mapeamento > Recebimento > Cadastrar  
273 - $numIdRecurso = $this->criarRecurso('pen_map_tipo_documento_recebimento_cadastrar', 'Cadastro de mapeamento de documentos recebidos', $numIdSistema);  
274 - $this->criarMenu('Cadastrar', 10, $numIdItemMenuPai, $numIdMenu, $numIdRecurso, $numIdSistema);  
275 -  
276 - // Gera o submenu Mapeamento > Recebimento > Listar  
277 - $numIdRecurso = $this->criarRecurso('pen_map_tipo_documento_recebimento_listar', 'Listagem de mapeamento de documentos recebidos', $numIdSistema);  
278 - $this->criarMenu('Listar', 20, $numIdItemMenuPai, $numIdMenu, $numIdRecurso, $numIdSistema);  
279 -  
280 - //Atribui as permissões aos recursos e menus  
281 - $this->atribuirPerfil($numIdSistema);  
282 - }  
283 -  
284 - protected function instalarV002(){  
285 -  
286 - }  
287 -  
288 - protected function instalarV003R003S003IW001(){  
289 -  
290 -  
291 - $objBD = new ItemMenuBD($this->inicializarObjInfraIBanco());  
292 -  
293 - //----------------------------------------------------------------------  
294 - // Achar o root  
295 -  
296 - $numIdSistema = $this->getNumIdSistema('SEI');  
297 - $numIdMenu = $this->getNumIdMenu('Principal', $numIdSistema);  
298 -  
299 - $objDTO = new ItemMenuDTO();  
300 - $objDTO->setNumIdSistema($numIdSistema);  
301 - $objDTO->setNumIdMenu($numIdMenu);  
302 - $objDTO->setStrRotulo('Administração');  
303 - $objDTO->setNumMaxRegistrosRetorno(1);  
304 - $objDTO->retNumIdItemMenu();  
305 -  
306 - $objDTO = $objBD->consultar($objDTO);  
307 -  
308 - if(empty($objDTO)) {  
309 - throw new InfraException('Menu "Administração" não foi localizado');  
310 - }  
311 -  
312 - $numIdItemMenuRoot = $objDTO->getNumIdItemMenu();  
313 - //----------------------------------------------------------------------  
314 - // Acha o nodo do mapeamento  
315 -  
316 - $objItemMenuDTO = new ItemMenuDTO();  
317 - $objItemMenuDTO->setNumIdSistema($numIdSistema);  
318 - $objItemMenuDTO->setNumIdMenu($numIdMenu);  
319 - $objItemMenuDTO->setStrRotulo('Mapeamento');  
320 - $objItemMenuDTO->setNumSequencia(50);  
321 - $objItemMenuDTO->setNumMaxRegistrosRetorno(1);  
322 - $objItemMenuDTO->retTodos();  
323 -  
324 - $objItemMenuDTO = $objBD->consultar($objItemMenuDTO);  
325 - if(!empty($objItemMenuDTO)) {  
326 -  
327 - $numIdItemMenuMapeamento = $objItemMenuDTO->getNumIdItemMenu();  
328 -  
329 - $objDTO = new ItemMenuDTO();  
330 - $objDTO->setNumIdSistema($numIdSistema);  
331 - $objDTO->setNumIdMenu($numIdMenu);  
332 - $objDTO->setNumIdItemMenuPai($numIdItemMenuMapeamento);  
333 - $objDTO->retTodos();  
334 -  
335 - $arrObjDTO = $objBD->listar($objDTO);  
336 -  
337 - if(!empty($arrObjDTO)) {  
338 -  
339 - $numIdItemMenuPai = $this->criarMenu('Processo Eletrônico Nacional', 0, $numIdItemMenuRoot, $numIdMenu, null, $numIdSistema);  
340 - $numIdItemMenuPai = $this->criarMenu('Mapeamento de Tipos de Documento', 10, $numIdItemMenuPai, $numIdMenu, null, $numIdSistema);  
341 -  
342 - foreach($arrObjDTO as $objDTO) {  
343 -  
344 - $objDTO->setNumIdItemMenuPai($numIdItemMenuPai);  
345 -  
346 - $objBD->alterar($objDTO);  
347 - }  
348 -  
349 - $objBD->excluir($objItemMenuDTO);  
350 - }  
351 - }  
352 - }  
353 -}  
sip_atualizar_versao_modulo_pen.php
@@ -7,479 +7,20 @@ set_include_path(implode(PATH_SEPARATOR, array( @@ -7,479 +7,20 @@ set_include_path(implode(PATH_SEPARATOR, array(
7 ))); 7 )));
8 8
9 9
10 -/**  
11 - * Mapeamento dos metadados sobre a estrutura do banco de dados  
12 - *  
13 - * @author Join Tecnologia  
14 - */  
15 -class PenMetaBD extends InfraMetaBD {  
16 -  
17 - const NNULLO = 'NOT NULL';  
18 - const SNULLO = 'NULL';  
19 -  
20 - /**  
21 - *  
22 - * @return string  
23 - */  
24 - public function adicionarValorPadraoParaColuna($strNomeTabela, $strNomeColuna, $strValorPadrao, $bolRetornarQuery = false){  
25 -  
26 - $objInfraBanco = $this->getObjInfraIBanco();  
27 -  
28 - $strTableDrive = get_parent_class($objInfraBanco);  
29 - $strQuery = '';  
30 -  
31 - switch($strTableDrive) {  
32 -  
33 - case 'InfraMySqli':  
34 - $strQuery = sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` SET DEFAULT '%s'", $strNomeTabela, $strNomeColuna, $strValorPadrao);  
35 - break;  
36 -  
37 - case 'InfraSqlServer':  
38 - $strQuery = sprintf("ALTER TABLE [%s] ADD DEFAULT('%s') FOR [%s]", $strNomeTabela, $strValorPadrao, $strNomeColuna);  
39 -  
40 - case 'InfraOracle':  
41 - break;  
42 - }  
43 -  
44 - if($bolRetornarQuery === false) {  
45 -  
46 - $objInfraBanco->executarSql($strQuery);  
47 - }  
48 - else {  
49 -  
50 - return $strQuery;  
51 - }  
52 - }  
53 -  
54 - /**  
55 - * Verifica se o usuário do drive de conexão possui permissão para criar/ remover  
56 - * estruturas  
57 - *  
58 - * @return PenMetaBD  
59 - */  
60 - public function isDriverPermissao(){  
61 -  
62 - $objInfraBanco = $this->getObjInfraIBanco();  
63 -  
64 - if(count($this->obterTabelas('sei_teste'))==0){  
65 - $objInfraBanco->executarSql('CREATE TABLE sei_teste (id '.$this->tipoNumero().' NULL)');  
66 - }  
67 -  
68 - $objInfraBanco->executarSql('DROP TABLE sei_teste');  
69 -  
70 - return $this;  
71 - }  
72 -  
73 - /**  
74 - * Verifica se o banco do SEI é suportador pelo atualizador  
75 - *  
76 - * @throws InfraException  
77 - * @return PenMetaBD  
78 - */  
79 - public function isDriverSuportado(){  
80 -  
81 - $strTableDrive = get_parent_class($this->getObjInfraIBanco());  
82 -  
83 - switch($strTableDrive) {  
84 -  
85 - case 'InfraMySqli':  
86 - // Fix para bug de MySQL versão inferior ao 5.5 o default engine  
87 - // é MyISAM e não tem suporte a FOREING KEYS  
88 - $version = $this->getObjInfraIBanco()->consultarSql('SELECT VERSION() as versao');  
89 - $version = $version[0]['versao'];  
90 - $arrVersion = explode('.', $version);  
91 -  
92 - if($arrVersion[0].$arrVersion[1] < 56){  
93 - $this->getObjInfraIBanco()->executarSql('@SET STORAGE_ENGINE=InnoDB');  
94 - }  
95 - case 'InfraSqlServer':  
96 - case 'InfraOracle':  
97 - break;  
98 -  
99 - default:  
100 - throw new InfraException('BANCO DE DADOS NAO SUPORTADO: ' . $strTableDrive);  
101 -  
102 - }  
103 -  
104 - return $this;  
105 - }  
106 -  
107 - /**  
108 - * Verifica se a versão sistema é compativel com a versão do módulo PEN  
109 - *  
110 - * @throws InfraException  
111 - * @return PenMetaBD  
112 - */  
113 - public function isVersaoSuportada($strRegexVersaoSistema, $strVerMinRequirida){  
114 -  
115 - $numVersaoRequerida = intval(preg_replace('/\D+/', '', $strVerMinRequirida));  
116 - $numVersaoSistema = intval(preg_replace('/\D+/', '', $strRegexVersaoSistema));  
117 -  
118 - if($numVersaoRequerida > $numVersaoSistema){  
119 - throw new InfraException('VERSAO DO FRAMEWORK PHP INCOMPATIVEL (VERSAO ATUAL '.$strRegexVersaoSistema.', VERSAO REQUERIDA '.$strVerMinRequirida.')');  
120 - }  
121 -  
122 - return $this;  
123 - }  
124 -  
125 - /**  
126 - * Apaga a chave primária da tabela  
127 - *  
128 - * @throws InfraException  
129 - * @return PenMetaBD  
130 - */  
131 - public function removerChavePrimaria($strNomeTabela, $strNomeChave){  
132 -  
133 - if($this->isChaveExiste($strNomeTabela, $strNomeChave)) {  
134 -  
135 - $strTableDrive = get_parent_class($this->getObjInfraIBanco());  
136 -  
137 - switch($strTableDrive) {  
138 -  
139 - case 'InfraMySqli':  
140 - $this->getObjInfraIBanco()->executarSql('ALTER TABLE '.$strNomeTabela.' DROP PRIMARY KEY');  
141 - break;  
142 -  
143 - case 'InfraSqlServer':  
144 - $this->getObjInfraIBanco()->executarSql('ALTER TABLE '.$strNomeTabela.' DROP CONSTRAINT '.$strNomeChave);  
145 - break;  
146 -  
147 - case 'InfraOracle':  
148 - break;  
149 - }  
150 - }  
151 - return $this;  
152 - }  
153 -  
154 - public function isChaveExiste($strNomeTabela = '', $strNomeChave = ''){  
155 -  
156 - $objInfraBanco = $this->getObjInfraIBanco();  
157 - $strTableDrive = get_parent_class($objInfraBanco);  
158 -  
159 - switch($strTableDrive) {  
160 -  
161 - case 'InfraMySqli':  
162 - $strSql = " SELECT COUNT(CONSTRAINT_NAME) AS EXISTE  
163 - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS  
164 - WHERE CONSTRAINT_SCHEMA = '".$objInfraBanco->getBanco()."'  
165 - AND TABLE_NAME = '".$strNomeTabela."'  
166 - AND CONSTRAINT_NAME = '".$strNomeChave."'";  
167 - break;  
168 -  
169 - case 'InfraSqlServer':  
170 -  
171 - $strSql = " SELECT COUNT(CONSTRAINT_NAME) AS EXISTE  
172 - FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS  
173 - WHERE CONSTRAINT_CATALOG = '".$objInfraBanco->getBanco()."'  
174 - AND TABLE_NAME = '".$strNomeTabela."'  
175 - AND CONSTRAINT_NAME = '".$strNomeChave."'";  
176 - break;  
177 -  
178 - case 'InfraOracle':  
179 - $strSql = "SELECT 0 AS EXISTE";  
180 - break;  
181 - }  
182 -  
183 - $strSql = preg_replace('/\s+/', ' ', $strSql);  
184 - $arrDados = $objInfraBanco->consultarSql($strSql); 10 +class PenAtualizarSipRN extends InfraRN {
185 11
186 - return (intval($arrDados[0]['EXISTE']) > 0) ? true : false;  
187 - }  
188 -  
189 - public function adicionarChaveUnica($strNomeTabela = '', $arrNomeChave = array()){  
190 -  
191 - $this->getObjInfraIBanco()  
192 - ->executarSql('ALTER TABLE '.$strNomeTabela.' ADD CONSTRAINT UK_'.$strNomeTabela.' UNIQUE('.implode(', ', $arrNomeChave).')');  
193 - }  
194 -  
195 - public function renomearTabela($strNomeTabelaAtual, $strNomeTabelaNovo){  
196 -  
197 - if($this->isTabelaExiste($strNomeTabelaAtual)) {  
198 -  
199 - $objInfraBanco = $this->getObjInfraIBanco();  
200 -  
201 - $strTableDrive = get_parent_class($objInfraBanco);  
202 - $strQuery = '';  
203 -  
204 - switch ($strTableDrive) {  
205 -  
206 - case 'InfraMySqli':  
207 - $strQuery = sprintf("ALTER TABLE `%s` RENAME TO `%s`", $strNomeTabelaAtual, $strNomeTabelaNovo);  
208 - break;  
209 -  
210 - case 'InfraSqlServer':  
211 - $strQuery = sprintf("sp_rename '%s', '%s'", $strNomeTabelaAtual, $strNomeTabelaNovo);  
212 -  
213 - case 'InfraOracle':  
214 - $strQuery = sprintf("RENAME TABLE %s TO %s", $strNomeTabelaAtual, $strNomeTabelaNovo);  
215 - break;  
216 - }  
217 -  
218 - $objInfraBanco->executarSql($strQuery);  
219 - }  
220 - }  
221 -  
222 -  
223 - /**  
224 - * Verifica se uma tabela existe no banco  
225 - *  
226 - * @throws InfraException  
227 - * @return bool  
228 - */  
229 - public function isTabelaExiste($strNomeTabela = ''){  
230 -  
231 - $objInfraBanco = $this->getObjInfraIBanco();  
232 - $strTableDrive = get_parent_class($objInfraBanco);  
233 -  
234 - switch($strTableDrive) {  
235 -  
236 - case 'InfraMySqli':  
237 - $strSql = "SELECT COUNT(TABLE_NAME) AS EXISTE  
238 - FROM INFORMATION_SCHEMA.TABLES  
239 - WHERE TABLE_SCHEMA = '".$objInfraBanco->getBanco()."'  
240 - AND TABLE_NAME = '".$strNomeTabela."'";  
241 - break;  
242 -  
243 - case 'InfraSqlServer':  
244 -  
245 - $strSql = "SELECT COUNT(TABLE_NAME) AS EXISTE  
246 - FROM INFORMATION_SCHEMA.TABLES  
247 - WHERE TABLE_CATALOG = '".$objInfraBanco->getBanco()."'  
248 - AND TABLE_NAME = '".$strNomeTabela."'";  
249 - break;  
250 -  
251 - case 'InfraOracle':  
252 - $strSql = "SELECT 0 AS EXISTE";  
253 - break;  
254 - }  
255 -  
256 - $strSql = preg_replace('/\s+/', ' ', $strSql);  
257 - $arrDados = $objInfraBanco->consultarSql($strSql);  
258 -  
259 - return (intval($arrDados[0]['EXISTE']) > 0) ? true : false;  
260 - }  
261 -  
262 - public function isColuna($strNomeTabela = '', $strNomeColuna = ''){  
263 -  
264 - $objInfraBanco = $this->getObjInfraIBanco();  
265 - $strTableDrive = get_parent_class($objInfraBanco);  
266 -  
267 - switch($strTableDrive) {  
268 -  
269 - case 'InfraMySqli':  
270 - $strSql = "SELECT COUNT(TABLE_NAME) AS EXISTE  
271 - FROM INFORMATION_SCHEMA.COLUMNS  
272 - WHERE TABLE_SCHEMA = '".$objInfraBanco->getBanco()."'  
273 - AND TABLE_NAME = '".$strNomeTabela."'  
274 - AND COLUMN_NAME = '".$strNomeColuna."'";  
275 - break;  
276 -  
277 - case 'InfraSqlServer':  
278 -  
279 - $strSql = "SELECT COUNT(COLUMN_NAME) AS EXISTE  
280 - FROM INFORMATION_SCHEMA.COLUMNS  
281 - WHERE TABLE_CATALOG = '".$objInfraBanco->getBanco()."'  
282 - AND TABLE_NAME = '".$strNomeTabela."'  
283 - AND COLUMN_NAME = '".$strNomeColuna."'";  
284 - break;  
285 -  
286 - case 'InfraOracle':  
287 - $strSql = "SELECT 0 AS EXISTE";  
288 - break;  
289 - }  
290 -  
291 - $strSql = preg_replace('/\s+/', ' ', $strSql);  
292 - $arrDados = $objInfraBanco->consultarSql($strSql);  
293 -  
294 - return (intval($arrDados[0]['EXISTE']) > 0) ? true : false;  
295 -  
296 -  
297 - }  
298 -  
299 - /**  
300 - * Cria a estrutura da tabela no padrão ANSI  
301 - *  
302 - * @throws InfraException  
303 - * @return PenMetaBD  
304 - */  
305 - public function criarTabela($arrSchema = array()){  
306 -  
307 - $strNomeTabela = $arrSchema['tabela'];  
308 -  
309 -  
310 - if($this->isTabelaExiste($strNomeTabela)) {  
311 - return $this;  
312 - }  
313 -  
314 - $objInfraBanco = $this->getObjInfraIBanco();  
315 - $arrColunas = array();  
316 - $arrStrQuery = array();  
317 -  
318 - foreach($arrSchema['cols'] as $strNomeColuna => $arrColunaConfig) {  
319 -  
320 - list($strTipoDado, $strValorPadrao) = $arrColunaConfig;  
321 -  
322 - if($strValorPadrao != self::SNULLO && $strValorPadrao != self::NNULLO) {  
323 -  
324 - $arrStrQuery[] = $this->adicionarValorPadraoParaColuna($strNomeTabela, $strNomeColuna, $strValorPadrao, true);  
325 - $strValorPadrao = self::NNULLO;  
326 - }  
327 -  
328 - $arrColunas[] = $strNomeColuna.' '.$strTipoDado.' '.$strValorPadrao;  
329 - }  
330 -  
331 - $objInfraBanco->executarSql('CREATE TABLE '.$strNomeTabela.' ('.implode(', ', $arrColunas).')');  
332 -  
333 - if(!empty($arrSchema['pk'])) {  
334 -  
335 - $this->adicionarChavePrimaria($strNomeTabela, 'pk_'.$strNomeTabela, $arrSchema['pk']);  
336 -  
337 - if(count($arrSchema['pk']) > 1) {  
338 -  
339 - foreach($arrSchema['pk'] as $strPk) {  
340 -  
341 - $objInfraBanco->executarSql('CREATE INDEX idx_'.$strNomeTabela.'_'.$strPk.' ON '.$strNomeTabela.'('.$strPk.')');  
342 - }  
343 - }  
344 - }  
345 -  
346 - if(array_key_exists('uk', $arrSchema) && !empty($arrSchema['uk'])) {  
347 -  
348 - $this->adicionarChaveUnica($strNomeTabela, $arrSchema['uk']);  
349 - }  
350 -  
351 - if(!empty($arrSchema['fks'])) {  
352 -  
353 - foreach($arrSchema['fks'] as $strTabelaOrigem => $array) {  
354 -  
355 - $strNomeFK = 'fk_'.$strNomeTabela.'_'.$strTabelaOrigem;  
356 - $arrCamposOrigem = (array)array_shift($array);  
357 - $arrCampos = $arrCamposOrigem;  
358 -  
359 - if(!empty($array)) {  
360 - $arrCampos = (array)array_shift($array);  
361 - }  
362 -  
363 - $this->adicionarChaveEstrangeira($strNomeFK, $strNomeTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem);  
364 - }  
365 - }  
366 -  
367 - if(!empty($arrStrQuery)) {  
368 -  
369 - foreach($arrStrQuery as $strQuery) {  
370 - $objInfraBanco->executarSql($strQuery);  
371 - }  
372 - }  
373 -  
374 - return $this;  
375 - }  
376 -  
377 - /**  
378 - * Apagar a estrutura da tabela no banco de dados  
379 - *  
380 - * @throws InfraException  
381 - * @return PenMetaBD  
382 - */  
383 - public function removerTabela($strNomeTabela = ''){  
384 -  
385 - $this->getObjInfraIBanco()->executarSql('DROP TABLE '.$strNomeTabela);  
386 - return $this;  
387 - }  
388 -  
389 - public function adicionarChaveEstrangeira($strNomeFK, $strTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem) {  
390 -  
391 - if(!$this->isChaveExiste($strTabela, $strNomeFK)) {  
392 - parent::adicionarChaveEstrangeira($strNomeFK, $strTabela, $arrCampos, $strTabelaOrigem, $arrCamposOrigem);  
393 - }  
394 - return $this;  
395 - }  
396 -  
397 - public function adicionarChavePrimaria($strTabela, $strNomePK, $arrCampos) {  
398 -  
399 - if(!$this->isChaveExiste($strTabela, $strNomePK)) {  
400 - parent::adicionarChavePrimaria($strTabela, $strNomePK, $arrCampos);  
401 - }  
402 - return $this;  
403 - }  
404 -  
405 - public function alterarColuna($strTabela, $strColuna, $strTipo, $strNull = '') {  
406 - parent::alterarColuna($strTabela, $strColuna, $strTipo, $strNull);  
407 - return $this;  
408 - }  
409 -  
410 - public function excluirIndice($strTabela, $strIndex) {  
411 - if($this->isChaveExiste($strTabela, $strFk)) {  
412 - parent::excluirIndice($strTabela, $strIndex);  
413 - }  
414 - return $this;  
415 - }  
416 -  
417 - public function excluirChaveEstrangeira($strTabela, $strFk) {  
418 - if($this->isChaveExiste($strTabela, $strFk)) {  
419 - parent::excluirChaveEstrangeira($strTabela, $strFk);  
420 - }  
421 - return $this;  
422 - }  
423 -}  
424 -  
425 -abstract class PenAtualizadorRN extends InfraRN {  
426 -  
427 - protected $sip_versao;  
428 -  
429 - /**  
430 - * @var string Versão mínima requirida pelo sistema para instalação do PEN  
431 - */  
432 - protected $versaoMinRequirida;  
433 -  
434 - /**  
435 - * @var InfraIBanco Instância da classe de persistência com o banco de dados  
436 - */  
437 - protected $objBanco;  
438 -  
439 - /**  
440 - * @var InfraMetaBD Instância do metadata do banco de dados  
441 - */  
442 - protected $objMeta;  
443 -  
444 - /**  
445 - * @var InfraDebug Instância do debuger  
446 - */  
447 - protected $objDebug;  
448 -  
449 - /**  
450 - * @var integer Tempo de execução do script  
451 - */  
452 - protected $numSeg = 0;  
453 -  
454 - protected $objInfraBanco ;  
455 -  
456 - protected function inicializarObjInfraIBanco() {  
457 -  
458 - if (empty($this->objInfraBanco)) {  
459 - $this->objInfraBanco = BancoSip::getInstance();  
460 - $this->objInfraBanco->abrirConexao();  
461 - }  
462 -  
463 - return $this->objInfraBanco;  
464 - } 12 + protected $versaoMinRequirida = '1.30.0';
  13 + const PARAMETRO_VERSAO_MODULO_ANTIGO = 'PEN_VERSAO_MODULO_SIP';
  14 + const PARAMETRO_VERSAO_MODULO = 'VERSAO_MODULO_PEN';
  15 + private $arrRecurso = array();
  16 + private $arrMenu = array();
465 17
466 - /**  
467 - * Inicia a conexão com o banco de dados  
468 - */  
469 - protected function inicializarObjMetaBanco() {  
470 - if (empty($this->objMeta)) {  
471 - $this->objMeta = new PenMetaBD($this->inicializarObjInfraIBanco());  
472 - }  
473 - return $this->objMeta; 18 + public function __construct(){
  19 + parent::__construct();
474 } 20 }
475 21
476 - /**  
477 - * Adiciona uma mensagem ao output para o usuário  
478 - *  
479 - * @return null  
480 - */  
481 - protected function logar($strMsg) {  
482 - $this->objDebug->gravar($strMsg); 22 + protected function inicializarObjInfraIBanco(){
  23 + return BancoSip::getInstance();
483 } 24 }
484 25
485 /** 26 /**
@@ -489,70 +30,29 @@ abstract class PenAtualizadorRN extends InfraRN { @@ -489,70 +30,29 @@ abstract class PenAtualizadorRN extends InfraRN {
489 */ 30 */
490 protected function inicializar($strTitulo) { 31 protected function inicializar($strTitulo) {
491 32
492 - $this->numSeg = InfraUtil::verificarTempoProcessamento();  
493 -  
494 - $this->logar($strTitulo);  
495 - }  
496 -  
497 - /**  
498 - * Finaliza o script informando o tempo de execução.  
499 - *  
500 - * @return null  
501 - */  
502 - protected function finalizar() {  
503 -  
504 - $this->logar('TEMPO TOTAL DE EXECUCAO: ' . InfraUtil::verificarTempoProcessamento($this->numSeg) . ' s');  
505 -  
506 - $this->objDebug->setBolLigado(false);  
507 - $this->objDebug->setBolDebugInfra(false);  
508 - $this->objDebug->setBolEcho(false); 33 + session_start();
  34 + SessaoSip::getInstance(false);
509 35
510 - print PHP_EOL;  
511 - die();  
512 - }  
513 -  
514 - /**  
515 - * Construtor  
516 - *  
517 - * @param array $arrArgs Argumentos enviados pelo script  
518 - */  
519 - public function __construct() {  
520 -  
521 - parent::__construct();  
522 ini_set('max_execution_time', '0'); 36 ini_set('max_execution_time', '0');
523 ini_set('memory_limit', '-1'); 37 ini_set('memory_limit', '-1');
524 @ini_set('zlib.output_compression', '0'); 38 @ini_set('zlib.output_compression', '0');
525 @ini_set('implicit_flush', '1'); 39 @ini_set('implicit_flush', '1');
526 ob_implicit_flush(); 40 ob_implicit_flush();
527 41
528 - $this->inicializarObjInfraIBanco();  
529 - $this->inicializarObjMetaBanco();  
530 -  
531 $this->objDebug = InfraDebug::getInstance(); 42 $this->objDebug = InfraDebug::getInstance();
532 $this->objDebug->setBolLigado(true); 43 $this->objDebug->setBolLigado(true);
533 $this->objDebug->setBolDebugInfra(true); 44 $this->objDebug->setBolDebugInfra(true);
534 $this->objDebug->setBolEcho(true); 45 $this->objDebug->setBolEcho(true);
535 $this->objDebug->limpar(); 46 $this->objDebug->limpar();
536 - }  
537 -}  
538 47
539 -class PenAtualizarSipRN extends PenAtualizadorRN { 48 + $this->numSeg = InfraUtil::verificarTempoProcessamento();
  49 + $this->logar($strTitulo);
  50 + }
540 51
541 - protected $versaoMinRequirida = '1.30.0';  
542 - protected $sip_versao = 'PEN_VERSAO_MODULO_SIP';  
543 - private $arrRecurso = array();  
544 - private $arrMenu = array();  
545 -  
546 - public function atualizarVersao() { 52 + protected function atualizarVersaoConectado() {
547 try { 53 try {
548 $this->inicializar('INICIANDO ATUALIZACAO DO MODULO PEN NO SIP VERSAO 1.0.0'); 54 $this->inicializar('INICIANDO ATUALIZACAO DO MODULO PEN NO SIP VERSAO 1.0.0');
549 55
550 - //testando versao do framework  
551 -// $numVersaoInfraRequerida = '1.415';  
552 -// if (VERSAO_INFRA >= $numVersaoInfraRequerida) {  
553 -// $this->finalizar('VERSAO DO FRAMEWORK PHP INCOMPATIVEL (VERSAO ATUAL ' . VERSAO_INFRA . ', VERSAO REQUERIDA ' . $numVersaoInfraRequerida . ')', true);  
554 -// }  
555 -  
556 //testando se esta usando BDs suportados 56 //testando se esta usando BDs suportados
557 if (!(BancoSip::getInstance() instanceof InfraMySql) && 57 if (!(BancoSip::getInstance() instanceof InfraMySql) &&
558 !(BancoSip::getInstance() instanceof InfraSqlServer) && 58 !(BancoSip::getInstance() instanceof InfraSqlServer) &&
@@ -560,10 +60,9 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -560,10 +60,9 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
560 60
561 $this->finalizar('BANCO DE DADOS NAO SUPORTADO: ' . get_parent_class(BancoSip::getInstance()), true); 61 $this->finalizar('BANCO DE DADOS NAO SUPORTADO: ' . get_parent_class(BancoSip::getInstance()), true);
562 } 62 }
563 -  
564 - 63 +
565 //testando permissoes de criações de tabelas 64 //testando permissoes de criações de tabelas
566 - $objInfraMetaBD = new InfraMetaBD($this->objInfraBanco); 65 + $objInfraMetaBD = new InfraMetaBD(BancoSip::getInstance());
567 66
568 if (count($objInfraMetaBD->obterTabelas('pen_sip_teste')) == 0) { 67 if (count($objInfraMetaBD->obterTabelas('pen_sip_teste')) == 0) {
569 BancoSip::getInstance()->executarSql('CREATE TABLE pen_sip_teste (id ' . $objInfraMetaBD->tipoNumero() . ' null)'); 68 BancoSip::getInstance()->executarSql('CREATE TABLE pen_sip_teste (id ' . $objInfraMetaBD->tipoNumero() . ' null)');
@@ -571,43 +70,28 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -571,43 +70,28 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
571 BancoSip::getInstance()->executarSql('DROP TABLE pen_sip_teste'); 70 BancoSip::getInstance()->executarSql('DROP TABLE pen_sip_teste');
572 71
573 72
574 - $objInfraParametro = new InfraParametro($this->objInfraBanco); 73 + $objInfraParametro = new InfraParametro(BancoSip::getInstance());
  74 +
  75 + // Aplicação de scripts de atualização de forma incremental
  76 + // Ausência de [break;] proposital para realizar a atualização incremental de versões
  77 + $strVersaoModuloPen = $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO, false) ?: $objInfraParametro->getValor(self::PARAMETRO_VERSAO_MODULO_ANTIGO, false);
  78 + switch ($strVersaoModuloPen) {
  79 + //case '' - Nenhuma versão instalada
  80 + case '': $this->instalarV100();
  81 + case '1.0.0': $this->instalarV101();
  82 + case '1.0.1': $this->instalarV102();
  83 + case '1.0.2': $this->instalarV103();
  84 + case '1.0.3': $this->instalarV104();
  85 + case '1.0.4': $this->instalarV111();
  86 +
  87 + break;
  88 + default:
  89 + $this->finalizar('VERSAO DO MÓDULO JÁ CONSTA COMO ATUALIZADA');
  90 + break;
575 91
576 - //$strVersaoAtual = $objInfraParametro->getValor('SEI_VERSAO', false);  
577 - $strVersaoModuloPen = $objInfraParametro->getValor($this->sip_versao, false);  
578 -  
579 - //VERIFICANDO QUAL VERSAO DEVE SER INSTALADA NESTA EXECUCAO  
580 - if (InfraString::isBolVazia($strVersaoModuloPen)) {  
581 - $this->instalarV100();  
582 - $this->instalarV101();  
583 - $this->instalarV102();  
584 - $this->instalarV103();  
585 - $this->instalarV104();  
586 - } else {  
587 - switch ($strVersaoModuloPen) {  
588 - case '1.0.0':  
589 - $this->instalarV101();  
590 - $this->instalarV102();  
591 - $this->instalarV103();  
592 - $this->instalarV104();  
593 - break;  
594 -  
595 - case '1.0.1':  
596 - $this->instalarV102();  
597 - $this->instalarV103();  
598 - $this->instalarV104();  
599 - break;  
600 -  
601 - case '1.0.2': //Remover depois de usar  
602 - $this->instalarV103();  
603 - $this->instalarV104();  
604 - break;  
605 - case '1.0.3': //Remover depois de usar  
606 - $this->instalarV104();  
607 - break;  
608 - }  
609 } 92 }
610 93
  94 + $this->finalizar('FIM');
611 InfraDebug::getInstance()->setBolDebugInfra(true); 95 InfraDebug::getInstance()->setBolDebugInfra(true);
612 } catch (Exception $e) { 96 } catch (Exception $e) {
613 97
@@ -617,35 +101,30 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -617,35 +101,30 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
617 throw new InfraException('Erro atualizando VERSAO.', $e); 101 throw new InfraException('Erro atualizando VERSAO.', $e);
618 } 102 }
619 } 103 }
620 -  
621 - /**  
622 - * Inicia o script criando um contator interno do tempo de execução  
623 - *  
624 - * @return null  
625 - */  
626 - protected function inicializar($strTitulo) {  
627 -  
628 - $this->numSeg = InfraUtil::verificarTempoProcessamento();  
629 -  
630 - $this->logar($strTitulo);  
631 - }  
632 - 104 +
633 /** 105 /**
634 * Finaliza o script informando o tempo de execução. 106 * Finaliza o script informando o tempo de execução.
635 * 107 *
636 * @return null 108 * @return null
637 */ 109 */
638 - protected function finalizar() {  
639 -  
640 - $this->logar('TEMPO TOTAL DE EXECUCAO: ' . InfraUtil::verificarTempoProcessamento($this->numSeg) . ' s'); 110 + protected function finalizar($strMsg=null, $bolErro=false){
  111 + if (!$bolErro) {
  112 + $this->numSeg = InfraUtil::verificarTempoProcessamento($this->numSeg);
  113 + $this->logar('TEMPO TOTAL DE EXECUCAO: ' . $this->numSeg . ' s');
  114 + }else{
  115 + $strMsg = 'ERRO: '.$strMsg;
  116 + }
641 117
642 - $this->objDebug->setBolLigado(false);  
643 - $this->objDebug->setBolDebugInfra(false);  
644 - $this->objDebug->setBolEcho(false); 118 + if ($strMsg!=null){
  119 + $this->logar($strMsg);
  120 + }
645 121
646 - print PHP_EOL;  
647 - die();  
648 - } 122 + InfraDebug::getInstance()->setBolLigado(false);
  123 + InfraDebug::getInstance()->setBolDebugInfra(false);
  124 + InfraDebug::getInstance()->setBolEcho(false);
  125 + $this->numSeg = 0;
  126 + die;
  127 + }
649 128
650 /** 129 /**
651 * Adiciona uma mensagem ao output para o usuário 130 * Adiciona uma mensagem ao output para o usuário
@@ -697,7 +176,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -697,7 +176,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
697 } 176 }
698 177
699 /** 178 /**
700 - * 179 + * Cria novo recurso no SIP
701 * @return int Código do Recurso gerado 180 * @return int Código do Recurso gerado
702 */ 181 */
703 protected function criarRecurso($strNome = '', $strDescricao = null, $numIdSistema = 0) { 182 protected function criarRecurso($strNome = '', $strDescricao = null, $numIdSistema = 0) {
@@ -729,6 +208,44 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -729,6 +208,44 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
729 return $objDTO->getNumIdRecurso(); 208 return $objDTO->getNumIdRecurso();
730 } 209 }
731 210
  211 + protected function renomearRecurso($numIdSistema, $strNomeAtual, $strNomeNovo){
  212 +
  213 + $objRecursoDTO = new RecursoDTO();
  214 + $objRecursoDTO->setBolExclusaoLogica(false);
  215 + $objRecursoDTO->retNumIdRecurso();
  216 + $objRecursoDTO->retStrCaminho();
  217 + $objRecursoDTO->setNumIdSistema($numIdSistema);
  218 + $objRecursoDTO->setStrNome($strNomeAtual);
  219 +
  220 + $objRecursoRN = new RecursoRN();
  221 + $objRecursoDTO = $objRecursoRN->consultar($objRecursoDTO);
  222 +
  223 + if ($objRecursoDTO!=null){
  224 + $objRecursoDTO->setStrNome($strNomeNovo);
  225 + $objRecursoDTO->setStrCaminho(str_replace($strNomeAtual,$strNomeNovo,$objRecursoDTO->getStrCaminho()));
  226 + $objRecursoRN->alterar($objRecursoDTO);
  227 + }
  228 + }
  229 +
  230 + protected function consultarRecurso($numIdSistema, $strNomeRecurso){
  231 +
  232 + $numIdRecurso = null;
  233 + $objRecursoDTO = new RecursoDTO();
  234 + $objRecursoDTO->setBolExclusaoLogica(false);
  235 + $objRecursoDTO->setNumIdSistema($numIdSistema);
  236 + $objRecursoDTO->setStrNome($strNomeRecurso);
  237 + $objRecursoDTO->retNumIdRecurso();
  238 +
  239 + $objRecursoRN = new RecursoRN();
  240 + $objRecursoDTO = $objRecursoRN->consultar($objRecursoDTO);
  241 +
  242 + if ($objRecursoDTO == null){
  243 + throw new InfraException("Recurso com nome {$strNomeRecurso} não pode ser localizado.");
  244 + }
  245 +
  246 + return $objRecursoDTO->getNumIdRecurso();
  247 + }
  248 +
732 /** 249 /**
733 * Cria um menu 250 * Cria um menu
734 * 251 *
@@ -744,7 +261,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -744,7 +261,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
744 $objDTO->setNumMaxRegistrosRetorno(1); 261 $objDTO->setNumMaxRegistrosRetorno(1);
745 $objDTO->retNumIdItemMenu(); 262 $objDTO->retNumIdItemMenu();
746 263
747 - $objBD = new ItemMenuBD($this->objInfraBanco); 264 + $objBD = new ItemMenuBD(BancoSip::getInstance());
748 $objDTO = $objBD->consultar($objDTO); 265 $objDTO = $objBD->consultar($objDTO);
749 266
750 if (empty($objDTO)) { 267 if (empty($objDTO)) {
@@ -778,7 +295,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -778,7 +295,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
778 if (!empty($this->arrRecurso)) { 295 if (!empty($this->arrRecurso)) {
779 296
780 $objDTO = new RelPerfilRecursoDTO(); 297 $objDTO = new RelPerfilRecursoDTO();
781 - $objBD = new RelPerfilRecursoBD($this->objInfraBanco); 298 + $objBD = new RelPerfilRecursoBD(BancoSip::getInstance());
782 299
783 foreach ($this->arrRecurso as $numIdRecurso) { 300 foreach ($this->arrRecurso as $numIdRecurso) {
784 301
@@ -798,7 +315,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -798,7 +315,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
798 if (!empty($this->arrMenu)) { 315 if (!empty($this->arrMenu)) {
799 316
800 $objDTO = new RelPerfilItemMenuDTO(); 317 $objDTO = new RelPerfilItemMenuDTO();
801 - $objBD = new RelPerfilItemMenuBD($this->objInfraBanco); 318 + $objBD = new RelPerfilItemMenuBD(BancoSip::getInstance());
802 319
803 foreach ($this->arrMenu as $array) { 320 foreach ($this->arrMenu as $array) {
804 321
@@ -819,7 +336,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -819,7 +336,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
819 336
820 public function atribuirPerfil($numIdSistema) { 337 public function atribuirPerfil($numIdSistema) {
821 $objDTO = new PerfilDTO(); 338 $objDTO = new PerfilDTO();
822 - $objBD = new PerfilBD($this->objInfraBanco); 339 + $objBD = new PerfilBD(BancoSip::getInstance());
823 $objRN = $this; 340 $objRN = $this;
824 341
825 // Vincula a um perfil os recursos e menus adicionados nos métodos criarMenu e criarReturso 342 // Vincula a um perfil os recursos e menus adicionados nos métodos criarMenu e criarReturso
@@ -870,7 +387,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -870,7 +387,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
870 $objItemMenuDTO->setNumMaxRegistrosRetorno(1); 387 $objItemMenuDTO->setNumMaxRegistrosRetorno(1);
871 $objItemMenuDTO->retNumIdItemMenu(); 388 $objItemMenuDTO->retNumIdItemMenu();
872 389
873 - $objItemMenuBD = new ItemMenuBD($this->objInfraBanco); 390 + $objItemMenuBD = new ItemMenuBD(BancoSip::getInstance());
874 $objItemMenuDTO = $objItemMenuBD->consultar($objItemMenuDTO); 391 $objItemMenuDTO = $objItemMenuBD->consultar($objItemMenuDTO);
875 392
876 if (empty($objItemMenuDTO)) { 393 if (empty($objItemMenuDTO)) {
@@ -908,7 +425,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -908,7 +425,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
908 $this->atribuirPerfil($numIdSistema); 425 $this->atribuirPerfil($numIdSistema);
909 426
910 // ---------- antigo método (instalarV003R003S003IW001) ---------- // 427 // ---------- antigo método (instalarV003R003S003IW001) ---------- //
911 - $objBD = new ItemMenuBD($this->objInfraBanco); 428 + $objBD = new ItemMenuBD(BancoSip::getInstance());
912 429
913 // Achar o root 430 // Achar o root
914 $numIdSistema = $this->getNumIdSistema('SEI'); 431 $numIdSistema = $this->getNumIdSistema('SEI');
@@ -969,7 +486,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -969,7 +486,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
969 } 486 }
970 487
971 $objInfraParametroDTO = new InfraParametroDTO(); 488 $objInfraParametroDTO = new InfraParametroDTO();
972 - $objInfraParametroDTO->setStrNome($this->sip_versao); 489 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
973 $objInfraParametroDTO->setStrValor('1.0.0'); 490 $objInfraParametroDTO->setStrValor('1.0.0');
974 491
975 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 492 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
@@ -1084,7 +601,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -1084,7 +601,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
1084 601
1085 /* altera o parâmetro da versão de banco */ 602 /* altera o parâmetro da versão de banco */
1086 $objInfraParametroDTO = new InfraParametroDTO(); 603 $objInfraParametroDTO = new InfraParametroDTO();
1087 - $objInfraParametroDTO->setStrNome($this->sip_versao); 604 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1088 $objInfraParametroDTO->retTodos(); 605 $objInfraParametroDTO->retTodos();
1089 606
1090 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 607 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
@@ -1142,7 +659,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -1142,7 +659,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
1142 659
1143 /* altera o parâmetro da versão de banco */ 660 /* altera o parâmetro da versão de banco */
1144 $objInfraParametroDTO = new InfraParametroDTO(); 661 $objInfraParametroDTO = new InfraParametroDTO();
1145 - $objInfraParametroDTO->setStrNome($this->sip_versao); 662 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1146 $objInfraParametroDTO->retTodos(); 663 $objInfraParametroDTO->retTodos();
1147 664
1148 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 665 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
@@ -1271,7 +788,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -1271,7 +788,7 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
1271 788
1272 /* altera o parâmetro da versão de banco */ 789 /* altera o parâmetro da versão de banco */
1273 $objInfraParametroDTO = new InfraParametroDTO(); 790 $objInfraParametroDTO = new InfraParametroDTO();
1274 - $objInfraParametroDTO->setStrNome($this->sip_versao); 791 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1275 $objInfraParametroDTO->retTodos(); 792 $objInfraParametroDTO->retTodos();
1276 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 793 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
1277 $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO); 794 $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);
@@ -1350,13 +867,71 @@ class PenAtualizarSipRN extends PenAtualizadorRN { @@ -1350,13 +867,71 @@ class PenAtualizarSipRN extends PenAtualizadorRN {
1350 867
1351 /* altera o parâmetro da versão de banco */ 868 /* altera o parâmetro da versão de banco */
1352 $objInfraParametroDTO = new InfraParametroDTO(); 869 $objInfraParametroDTO = new InfraParametroDTO();
1353 - $objInfraParametroDTO->setStrNome($this->sip_versao); 870 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO_ANTIGO);
1354 $objInfraParametroDTO->retTodos(); 871 $objInfraParametroDTO->retTodos();
1355 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco()); 872 $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
1356 $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO); 873 $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);
1357 $objInfraParametroDTO->setStrValor('1.0.4'); 874 $objInfraParametroDTO->setStrValor('1.0.4');
1358 $objInfraParametroBD->alterar($objInfraParametroDTO); 875 $objInfraParametroBD->alterar($objInfraParametroDTO);
1359 } 876 }
  877 +
  878 + /**
  879 + * Instala/Atualiza os módulo PEN para versão 1.1.1
  880 + */
  881 + protected function instalarV111() {
  882 + $numIdSistema = $this->getNumIdSistema('SEI');
  883 +
  884 + //Ajuste em nome da variável de versão do módulo VERSAO_MODULO_PEN
  885 + BancoSIP::getInstance()->executarSql("update infra_parametro set nome = '" . self::PARAMETRO_VERSAO_MODULO . "' where nome = '" . self::PARAMETRO_VERSAO_MODULO_ANTIGO . "'");
  886 +
  887 + //Adequação em nome de recursos do módulo
  888 + $this->renomearRecurso($numIdSistema, 'apensados_selecionar_expedir_procedimento', 'pen_apensados_selecionar_expedir_procedimento');
  889 +
  890 + //Atualização com recursos não adicionados automaticamente em versões anteriores
  891 + $this->arrRecurso = array_merge($this->arrRecurso, array(
  892 + $this->consultarRecurso($numIdSistema, "pen_map_tipo_documento_envio_alterar"),
  893 + $this->consultarRecurso($numIdSistema, "pen_map_tipo_documento_envio_excluir"),
  894 + $this->consultarRecurso($numIdSistema, "pen_map_tipo_documento_recebimento_alterar"),
  895 + $this->consultarRecurso($numIdSistema, "pen_map_tipo_documento_recebimento_excluir"),
  896 + $this->consultarRecurso($numIdSistema, "pen_map_tipo_documento_recebimento_visualizar"),
  897 + $this->consultarRecurso($numIdSistema, "pen_parametros_configuracao_alterar")
  898 + ));
  899 +
  900 + $this->atribuirPerfil($numIdSistema);
  901 +
  902 + $objPerfilRN = new PerfilRN();
  903 + $objPerfilDTO = new PerfilDTO();
  904 + $objPerfilDTO->retNumIdPerfil();
  905 + $objPerfilDTO->setNumIdSistema($numIdSistema);
  906 + $objPerfilDTO->setStrNome('Administrador');
  907 + $objPerfilDTO = $objPerfilRN->consultar($objPerfilDTO);
  908 + if ($objPerfilDTO == null){
  909 + throw new InfraException('Perfil Administrador do sistema SEI não encontrado.');
  910 + }
  911 +
  912 + $numIdPerfilSeiAdministrador = $objPerfilDTO->getNumIdPerfil();
  913 +
  914 + $objRelPerfilRecursoDTO = new RelPerfilRecursoDTO();
  915 + $objRelPerfilRecursoDTO->retTodos();
  916 + $objRelPerfilRecursoDTO->setNumIdSistema($numIdSistema);
  917 + $objRelPerfilRecursoDTO->setNumIdPerfil($numIdPerfilSeiAdministrador);
  918 + $arrRecursosRemoverAdministrador = array(
  919 + $this->consultarRecurso($numIdSistema, "pen_procedimento_expedido_listar"),
  920 + $this->consultarRecurso($numIdSistema, "pen_procedimento_expedir"),
  921 + );
  922 + $objRelPerfilRecursoDTO->setNumIdRecurso($arrRecursosRemoverAdministrador, InfraDTO::$OPER_IN);
  923 + $objRelPerfilRecursoRN = new RelPerfilRecursoRN();
  924 + $objRelPerfilRecursoRN->excluir($objRelPerfilRecursoRN->listar($objRelPerfilRecursoDTO));
  925 +
  926 + /* Corrigir a versão do módulo no banco de dados */
  927 + $objInfraParametroDTO = new InfraParametroDTO();
  928 + $objInfraParametroDTO->setStrNome(self::PARAMETRO_VERSAO_MODULO);
  929 + $objInfraParametroDTO->retTodos();
  930 + $objInfraParametroBD = new InfraParametroBD($this->inicializarObjInfraIBanco());
  931 + $objInfraParametroDTO = $objInfraParametroBD->consultar($objInfraParametroDTO);
  932 + $objInfraParametroDTO->setStrValor('1.1.1');
  933 + $objInfraParametroBD->alterar($objInfraParametroDTO);
  934 + }
1360 } 935 }
1361 936
1362 try { 937 try {