Commit 2d28ebf8b9e0a3cfeab49e126bbb9a437ec72262

Authored by eduardo.batista
1 parent c42ceeb4
Exists in master and in 1 other branch desenv

[Feat] Adicionando QRCode do SEI.

Showing 1 changed file with 55 additions and 0 deletions   Show diff stats
MdWsSeiRest.php
@@ -269,6 +269,61 @@ class MdWsSeiRest extends SeiIntegracao @@ -269,6 +269,61 @@ class MdWsSeiRest extends SeiIntegracao
269 { 269 {
270 return null; 270 return null;
271 } 271 }
  272 +
  273 + public function adicionarElementoMenu()
  274 + {
  275 + $nomeArquivo = 'QRCODE_'.self::NOME_MODULO."_".SessaoSEI::getInstance()->getStrSiglaOrgaoSistema();
  276 + $html = CacheSEI::getInstance()->getAtributo($nomeArquivo);
  277 +
  278 + if(CacheSEI::getInstance()->getAtributo($nomeArquivo)){
  279 + return $html;
  280 + }
  281 +
  282 + $html = $this->montaCorpoHtMLQRCode($nomeArquivo);
  283 + CacheSEI::getInstance()->setAtributo($nomeArquivo, $html, CacheSEI::getInstance()->getNumTempo());
  284 +
  285 + return $html;
  286 + }
  287 +
  288 + /**
  289 + * Função que monta o html do QRCode para o menu lateral do SEI
  290 + * @param $nomeArquivo
  291 + * @return string
  292 + */
  293 + private function montaCorpoHtMLQRCode($nomeArquivo)
  294 + {
  295 + $htmlQrCode = '';
  296 + $caminhoAtual = explode("/sei/web", __DIR__);
  297 + $conteudoQrCode = ConfiguracaoSEI::getInstance()->getValor('SEI','URL')
  298 + .$caminhoAtual[1]
  299 + .'/controlador_ws.php/api/v1'
  300 + .'|'
  301 + .SessaoSEI::getInstance()->getStrSiglaOrgaoSistema();
  302 + $caminhoFisicoQrCode = DIR_SEI_TEMP.'/'.$nomeArquivo;
  303 +
  304 + InfraQRCode::gerar($conteudoQrCode, $caminhoFisicoQrCode,'L',2,1);
  305 +
  306 + $infraException = new InfraException();
  307 + if (!file_exists($caminhoFisicoQrCode)){
  308 + $infraException->lancarValidacao('Arquivo do QRCode não encontrado.');
  309 + }
  310 + if (filesize($caminhoFisicoQrCode)==0){
  311 + $infraException->lancarValidacao('Arquivo do QRCode vazio.');
  312 + }
  313 + if (($binQrCode = file_get_contents($caminhoFisicoQrCode))===false){
  314 + $infraException->lancarValidacao('Não foi possível ler o arquivo do QRCode.');
  315 + }
  316 +
  317 + $htmlQrCode .= '<ul>';
  318 + $htmlQrCode .= '<li style="list-style:none">';
  319 + $htmlQrCode .= '<p style="margin: 10px 20px"><b>Escaneie o QRCode abaixo para acessar o SEI no aplicativo:</b></p>';
  320 + $htmlQrCode .= '<img style="margin: 0% 25%" align="center" src="data:image/png;base64, '
  321 + . base64_encode($binQrCode) . '" />';
  322 + $htmlQrCode .= '</li>';
  323 + $htmlQrCode .= '</ul>';
  324 +
  325 + return $htmlQrCode;
  326 + }
272 } 327 }
273 328
274 ?> 329 ?>
275 \ No newline at end of file 330 \ No newline at end of file