<?php
//
   include_once('app_Login_session.php');
           include_once("../_lib/lib/php/fix.php");
   @ini_set('session.cookie_httponly', 1);
   @ini_set('session.use_only_cookies', 1);
   @ini_set('session.cookie_secure', 0);
   @session_start() ;
       if (!function_exists("sc_check_mobile"))
       {
           include_once("../_lib/lib/php/nm_check_mobile.php");
       }
       $_SESSION['scriptcase']['device_mobile'] = sc_check_mobile();
       $_SESSION['scriptcase']['proc_mobile']   = $_SESSION['scriptcase']['device_mobile'];
       if (!isset($_SESSION['scriptcase']['display_mobile']))
       {
           $_SESSION['scriptcase']['display_mobile'] = true;
       }
       if ($_SESSION['scriptcase']['device_mobile'])
       {
           if ($_SESSION['scriptcase']['display_mobile'] && isset($_POST['_sc_force_mobile']) && 'out' == $_POST['_sc_force_mobile'])
           {
               $_SESSION['scriptcase']['display_mobile'] = false;
           }
           elseif (!$_SESSION['scriptcase']['display_mobile'] && isset($_POST['_sc_force_mobile']) && 'in' == $_POST['_sc_force_mobile'])
           {
               $_SESSION['scriptcase']['display_mobile'] = true;
           }
       }
        if (isset($_GET['_sc_force_mobile'])) {
            $_SESSION['scriptcase']['force_mobile'] = 'Y' == $_GET['_sc_force_mobile'];
        }
        if (isset($_SESSION['scriptcase']['force_mobile'])) {
            if ($_SESSION['scriptcase']['force_mobile']) {
                $_SESSION['scriptcase']['device_mobile'] = true;
            }
            $_SESSION['scriptcase']['display_mobile'] = $_SESSION['scriptcase']['force_mobile'];
        }

   $_SESSION['scriptcase']['app_Login']['error_buffer'] = '';

   $_SESSION['scriptcase']['app_Login']['glo_nm_perfil']          = "pandemic_alerts_connection";
   $_SESSION['scriptcase']['app_Login']['glo_nm_path_prod']       = "";
   $_SESSION['scriptcase']['app_Login']['glo_nm_path_imagens']    = "";
   $_SESSION['scriptcase']['app_Login']['glo_nm_path_imag_temp']  = "";
   $_SESSION['scriptcase']['app_Login']['glo_nm_path_cache']  = "";
   $_SESSION['scriptcase']['app_Login']['glo_nm_path_doc']        = "";
   $NM_dir_atual = getcwd();
   if (empty($NM_dir_atual))
   {
       $str_path_sys  = (isset($_SERVER['SCRIPT_FILENAME'])) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['ORIG_PATH_TRANSLATED'];
       $str_path_sys  = str_replace("\\", '/', $str_path_sys);
   }
   else
   {
       $sc_nm_arquivo = explode("/", $_SERVER['PHP_SELF']);
       $str_path_sys  = str_replace("\\", "/", getcwd()) . "/" . $sc_nm_arquivo[count($sc_nm_arquivo)-1];
   }
   //check publication with the prod
   $str_path_apl_url = $_SERVER['PHP_SELF'];
   $str_path_apl_url = str_replace("\\", '/', $str_path_apl_url);
   $str_path_apl_url = substr($str_path_apl_url, 0, strrpos($str_path_apl_url, "/"));
   $str_path_apl_url = substr($str_path_apl_url, 0, strrpos($str_path_apl_url, "/")+1);
   $str_path_apl_dir = substr($str_path_sys, 0, strrpos($str_path_sys, "/"));
   $str_path_apl_dir = substr($str_path_apl_dir, 0, strrpos($str_path_apl_dir, "/")+1);
   //check prod
   if(empty($_SESSION['scriptcase']['app_Login']['glo_nm_path_prod']))
   {
           /*check prod*/$_SESSION['scriptcase']['app_Login']['glo_nm_path_prod'] = $str_path_apl_url . "_lib/prod";
   }
   //check img
   if(empty($_SESSION['scriptcase']['app_Login']['glo_nm_path_imagens']))
   {
           /*check img*/$_SESSION['scriptcase']['app_Login']['glo_nm_path_imagens'] = $str_path_apl_url . "_lib/file/img";
   }
   //check tmp
   if(empty($_SESSION['scriptcase']['app_Login']['glo_nm_path_imag_temp']))
   {
           /*check tmp*/$_SESSION['scriptcase']['app_Login']['glo_nm_path_imag_temp'] = $str_path_apl_url . "_lib/tmp";
   }
   //check cache
   if(empty($_SESSION['scriptcase']['app_Login']['glo_nm_path_cache']))
   {
           /*check cache*/$_SESSION['scriptcase']['app_Login']['glo_nm_path_cache'] = $str_path_apl_dir . "_lib/file/cache";
   }
   //check doc
   if(empty($_SESSION['scriptcase']['app_Login']['glo_nm_path_doc']))
   {
           /*check doc*/$_SESSION['scriptcase']['app_Login']['glo_nm_path_doc'] = $str_path_apl_dir . "_lib/file/doc";
   }
   //end check publication with the prod
//
class app_Login_ini
{
   var $nm_cod_apl;
   var $nm_nome_apl;
   var $nm_seguranca;
   var $nm_grupo;
   var $nm_grupo_versao;
   var $nm_autor;
   var $nm_versao_sc;
   var $nm_tp_lic_sc;
   var $nm_dt_criacao;
   var $nm_hr_criacao;
   var $nm_autor_alt;
   var $nm_dt_ult_alt;
   var $nm_hr_ult_alt;
   var $nm_timestamp;
   var $cor_bg_table;
   var $border_grid;
   var $cor_bg_grid;
   var $cor_cab_grid;
   var $cor_borda;
   var $cor_txt_cab_grid;
   var $cab_fonte_tipo;
   var $cab_fonte_tamanho;
   var $rod_fonte_tipo;
   var $rod_fonte_tamanho;
   var $cor_rod_grid;
   var $cor_txt_rod_grid;
   var $cor_barra_nav;
   var $cor_titulo;
   var $cor_txt_titulo;
   var $titulo_fonte_tipo;
   var $titulo_fonte_tamanho;
   var $cor_grid_impar;
   var $cor_grid_par;
   var $cor_txt_grid;
   var $texto_fonte_tipo;
   var $texto_fonte_tamanho;
   var $cor_lin_grupo;
   var $cor_txt_grupo;
   var $grupo_fonte_tipo;
   var $grupo_fonte_tamanho;
   var $cor_lin_sub_tot;
   var $cor_txt_sub_tot;
   var $sub_tot_fonte_tipo;
   var $sub_tot_fonte_tamanho;
   var $cor_lin_tot;
   var $cor_txt_tot;
   var $tot_fonte_tipo;
   var $tot_fonte_tamanho;
   var $cor_link_cab;
   var $cor_link_dados;
   var $img_fun_pag;
   var $img_fun_cab;
   var $img_fun_rod;
   var $img_fun_tit;
   var $img_fun_gru;
   var $img_fun_tot;
   var $img_fun_sub;
   var $img_fun_imp;
   var $img_fun_par;
   var $root;
   var $server;
   var $sc_protocolo;
   var $path_prod;
   var $path_link;
   var $path_aplicacao;
   var $path_embutida;
   var $path_botoes;
   var $path_img_global;
   var $path_img_modelo;
   var $path_icones;
   var $path_imagens;
   var $path_imag_cab;
   var $path_imag_temp;
   var $path_libs;
   var $path_doc;
   var $str_lang;
   var $str_schema_all;
   var $str_google_fonts;
   var $str_conf_reg;
   var $path_cep;
   var $path_secure;
   var $path_js;
   var $path_adodb;
   var $path_grafico;
   var $path_atual;
   var $Gd_missing;
   var $sc_site_ssl;
   var $nm_cont_lin;
   var $nm_limite_lin;
   var $nm_limite_lin_prt;
   var $nm_falta_var;
   var $nm_falta_var_db;
   var $nm_tpbanco;
   var $nm_servidor;
   var $nm_usuario;
   var $nm_senha;
   var $nm_database_encoding;
   var $nm_arr_db_extra_args = array();
   var $nm_con_db2 = array();
   var $nm_con_persistente;
   var $nm_con_use_schema;
   var $nm_tabela;
   var $nm_col_dinamica   = array();
   var $nm_order_dinamico = array();
   var $nm_hidden_pages   = array();
   var $nm_page_names     = array();
   var $nm_page_blocks    = array();
   var $nm_block_page     = array();
   var $nm_hidden_blocos  = array();
   var $sc_tem_trans_banco;
   var $nm_bases_all;
   var $nm_bases_access;
   var $nm_bases_db2;
   var $nm_bases_ibase;
   var $nm_bases_informix;
   var $nm_bases_mssql;
   var $nm_bases_mysql;
   var $nm_bases_postgres;
   var $nm_bases_oracle;
   var $nm_bases_sqlite;
   var $nm_bases_sybase;
   var $nm_bases_vfp;
   var $nm_bases_odbc;
   var $nm_bases_progress;
   var $sc_page;
   var $sc_lig_md5 = array();
   var $sc_lig_target = array();
   var $sc_lig_iframe = array();
   var $force_db_utf8 = true;
//
   function init()
   {
       global
             $nm_url_saida, $nm_apl_dependente, $script_case_init;

      @ini_set('magic_quotes_runtime', 0);
      $this->sc_page = $script_case_init;
      $_SESSION['scriptcase']['sc_num_page'] = $script_case_init;
      $_SESSION['scriptcase']['sc_ctl_ajax'] = 'part';
      $_SESSION['scriptcase']['sc_cnt_sql']  = 0;
      $this->sc_charset['UTF-8'] = 'utf-8';
      $this->sc_charset['ISO-2022-JP'] = 'iso-2022-jp';
      $this->sc_charset['ISO-2022-KR'] = 'iso-2022-kr';
      $this->sc_charset['ISO-8859-1'] = 'iso-8859-1';
      $this->sc_charset['ISO-8859-2'] = 'iso-8859-2';
      $this->sc_charset['ISO-8859-3'] = 'iso-8859-3';
      $this->sc_charset['ISO-8859-4'] = 'iso-8859-4';
      $this->sc_charset['ISO-8859-5'] = 'iso-8859-5';
      $this->sc_charset['ISO-8859-6'] = 'iso-8859-6';
      $this->sc_charset['ISO-8859-7'] = 'iso-8859-7';
      $this->sc_charset['ISO-8859-8'] = 'iso-8859-8';
      $this->sc_charset['ISO-8859-8-I'] = 'iso-8859-8-i';
      $this->sc_charset['ISO-8859-9'] = 'iso-8859-9';
      $this->sc_charset['ISO-8859-10'] = 'iso-8859-10';
      $this->sc_charset['ISO-8859-13'] = 'iso-8859-13';
      $this->sc_charset['ISO-8859-14'] = 'iso-8859-14';
      $this->sc_charset['ISO-8859-15'] = 'iso-8859-15';
      $this->sc_charset['WINDOWS-1250'] = 'windows-1250';
      $this->sc_charset['WINDOWS-1251'] = 'windows-1251';
      $this->sc_charset['WINDOWS-1252'] = 'windows-1252';
      $this->sc_charset['TIS-620'] = 'tis-620';
      $this->sc_charset['WINDOWS-1253'] = 'windows-1253';
      $this->sc_charset['WINDOWS-1254'] = 'windows-1254';
      $this->sc_charset['WINDOWS-1255'] = 'windows-1255';
      $this->sc_charset['WINDOWS-1256'] = 'windows-1256';
      $this->sc_charset['WINDOWS-1257'] = 'windows-1257';
      $this->sc_charset['KOI8-R'] = 'koi8-r';
      $this->sc_charset['BIG-5'] = 'big5';
      $this->sc_charset['EUC-CN'] = 'EUC-CN';
      $this->sc_charset['GB18030'] = 'GB18030';
      $this->sc_charset['GB2312'] = 'gb2312';
      $this->sc_charset['EUC-JP'] = 'euc-jp';
      $this->sc_charset['SJIS'] = 'shift-jis';
      $this->sc_charset['EUC-KR'] = 'euc-kr';
      $_SESSION['scriptcase']['charset_entities']['UTF-8'] = 'UTF-8';
      $_SESSION['scriptcase']['charset_entities']['ISO-8859-1'] = 'ISO-8859-1';
      $_SESSION['scriptcase']['charset_entities']['ISO-8859-5'] = 'ISO-8859-5';
      $_SESSION['scriptcase']['charset_entities']['ISO-8859-15'] = 'ISO-8859-15';
      $_SESSION['scriptcase']['charset_entities']['WINDOWS-1251'] = 'cp1251';
      $_SESSION['scriptcase']['charset_entities']['WINDOWS-1252'] = 'cp1252';
      $_SESSION['scriptcase']['charset_entities']['BIG-5'] = 'BIG5';
      $_SESSION['scriptcase']['charset_entities']['EUC-CN'] = 'GB2312';
      $_SESSION['scriptcase']['charset_entities']['GB2312'] = 'GB2312';
      $_SESSION['scriptcase']['charset_entities']['SJIS'] = 'Shift_JIS';
      $_SESSION['scriptcase']['charset_entities']['EUC-JP'] = 'EUC-JP';
      $_SESSION['scriptcase']['charset_entities']['KOI8-R'] = 'KOI8-R';
      $_SESSION['scriptcase']['trial_version'] = 'N';
      $_SESSION['sc_session'][$this->sc_page]['app_Login']['decimal_db'] = "."; 

      $this->nm_cod_apl      = "app_Login"; 
      $this->nm_nome_apl     = "Login - Initial Application"; 
      $this->nm_seguranca    = ""; 
      $this->nm_grupo        = "Pandemic_Alerts"; 
      $this->nm_grupo_versao = "2"; 
      $this->nm_autor        = "nadir"; 
      $this->nm_script_by    = "netmake"; 
      $this->nm_script_type  = "PHP"; 
      $this->nm_versao_sc    = "v9"; 
      $this->nm_tp_lic_sc    = "ep_bronze"; 
      $this->nm_dt_criacao   = "20231214"; 
      $this->nm_hr_criacao   = "110522"; 
      $this->nm_autor_alt    = "nadir"; 
      $this->nm_dt_ult_alt   = "20251110"; 
      $this->nm_hr_ult_alt   = "230953"; 
      list($NM_usec, $NM_sec) = explode(" ", microtime()); 
      $this->nm_timestamp    = (float) $NM_sec; 
      $this->nm_app_version  = "1.1.0"; 
// 
      $this->border_grid           = ""; 
      $this->cor_bg_grid           = ""; 
      $this->cor_bg_table          = ""; 
      $this->cor_borda             = ""; 
      $this->cor_cab_grid          = ""; 
      $this->cor_txt_pag           = ""; 
      $this->cor_link_pag          = ""; 
      $this->pag_fonte_tipo        = ""; 
      $this->pag_fonte_tamanho     = ""; 
      $this->cor_txt_cab_grid      = ""; 
      $this->cab_fonte_tipo        = ""; 
      $this->cab_fonte_tamanho     = ""; 
      $this->rod_fonte_tipo        = ""; 
      $this->rod_fonte_tamanho     = ""; 
      $this->cor_rod_grid          = ""; 
      $this->cor_txt_rod_grid      = ""; 
      $this->cor_barra_nav         = ""; 
      $this->cor_titulo            = ""; 
      $this->cor_txt_titulo        = ""; 
      $this->titulo_fonte_tipo     = ""; 
      $this->titulo_fonte_tamanho  = ""; 
      $this->cor_grid_impar        = ""; 
      $this->cor_grid_par          = ""; 
      $this->cor_txt_grid          = ""; 
      $this->texto_fonte_tipo      = ""; 
      $this->texto_fonte_tamanho   = ""; 
      $this->cor_lin_grupo         = ""; 
      $this->cor_txt_grupo         = ""; 
      $this->grupo_fonte_tipo      = ""; 
      $this->grupo_fonte_tamanho   = ""; 
      $this->cor_lin_sub_tot       = ""; 
      $this->cor_txt_sub_tot       = ""; 
      $this->sub_tot_fonte_tipo    = ""; 
      $this->sub_tot_fonte_tamanho = ""; 
      $this->cor_lin_tot           = ""; 
      $this->cor_txt_tot           = ""; 
      $this->tot_fonte_tipo        = ""; 
      $this->tot_fonte_tamanho     = ""; 
      $this->cor_link_cab          = ""; 
      $this->cor_link_dados        = ""; 
      $this->img_fun_pag           = ""; 
      $this->img_fun_cab           = ""; 
      $this->img_fun_rod           = ""; 
      $this->img_fun_tit           = ""; 
      $this->img_fun_gru           = ""; 
      $this->img_fun_tot           = ""; 
      $this->img_fun_sub           = ""; 
      $this->img_fun_imp           = ""; 
      $this->img_fun_par           = ""; 
// 
      $NM_dir_atual = getcwd();
      if (empty($NM_dir_atual))
      {
          $str_path_sys          = (isset($_SERVER['SCRIPT_FILENAME'])) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['ORIG_PATH_TRANSLATED'];
          $str_path_sys          = str_replace("\\", '/', $str_path_sys);
      }
      else
      {
          $sc_nm_arquivo         = explode("/", $_SERVER['PHP_SELF']);
          $str_path_sys          = str_replace("\\", "/", getcwd()) . "/" . $sc_nm_arquivo[count($sc_nm_arquivo)-1];
      }
      //check publication with the prod
      $str_path_apl_url = $_SERVER['PHP_SELF'];
      $str_path_apl_url = str_replace("\\", '/', $str_path_apl_url);
      $str_path_apl_url = substr($str_path_apl_url, 0, strrpos($str_path_apl_url, "/"));
      $str_path_apl_url = substr($str_path_apl_url, 0, strrpos($str_path_apl_url, "/")+1);
      $str_path_apl_dir = substr($str_path_sys, 0, strrpos($str_path_sys, "/"));
      $str_path_apl_dir = substr($str_path_apl_dir, 0, strrpos($str_path_apl_dir, "/")+1);
// 
      $this->sc_site_ssl     = (isset($_SERVER['HTTP_REFERER']) && strtolower(substr($_SERVER['HTTP_REFERER'], 0, 5)) == 'https') ? true : false;
      $this->sc_protocolo    = ($this->sc_site_ssl) ? 'https://' : 'http://';
      $this->path_prod       = $_SESSION['scriptcase']['app_Login']['glo_nm_path_prod'];
      $this->path_imagens    = $_SESSION['scriptcase']['app_Login']['glo_nm_path_imagens'];
      $this->path_imag_temp  = $_SESSION['scriptcase']['app_Login']['glo_nm_path_imag_temp'];
      $this->path_cache      = $_SESSION['scriptcase']['app_Login']['glo_nm_path_cache'];
      $this->path_doc        = $_SESSION['scriptcase']['app_Login']['glo_nm_path_doc'];
      if (!isset($_SESSION['scriptcase']['str_lang']) || empty($_SESSION['scriptcase']['str_lang']))
      {
          $_SESSION['scriptcase']['str_lang'] = "fr";
      }
      if (!isset($_SESSION['scriptcase']['str_conf_reg']) || empty($_SESSION['scriptcase']['str_conf_reg']))
      {
          $_SESSION['scriptcase']['str_conf_reg'] = "fr_fr";
      }
      $this->str_lang        = $_SESSION['scriptcase']['str_lang'];
      $this->str_conf_reg    = $_SESSION['scriptcase']['str_conf_reg'];
      $this->str_schema_all  = (isset($_SESSION['scriptcase']['str_schema_all']) && !empty($_SESSION['scriptcase']['str_schema_all'])) ? $_SESSION['scriptcase']['str_schema_all'] : "Sc9_Rhino/Sc9_Rhino";
      $this->str_google_fonts  = isset($str_google_fonts)?$str_google_fonts:'';
      $this->server          = (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST'];
      if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && !$this->sc_site_ssl )
      {
          $this->server         .= ":" . $_SERVER['SERVER_PORT'];
      }
      $this->server_pdf      = $this->sc_protocolo . $this->server;
      $this->server          = "";
      $this->sc_protocolo    = "";
      $str_path_web          = $_SERVER['PHP_SELF'];
      $str_path_web          = str_replace("\\", '/', $str_path_web);
      $str_path_web          = str_replace('//', '/', $str_path_web);
      $this->root            = substr($str_path_sys, 0, -1 * strlen($str_path_web));
      $this->path_aplicacao  = substr($str_path_sys, 0, strrpos($str_path_sys, '/'));
      $this->path_aplicacao  = substr($this->path_aplicacao, 0, strrpos($this->path_aplicacao, '/')) . '/app_Login';
      $this->path_embutida   = substr($this->path_aplicacao, 0, strrpos($this->path_aplicacao, '/') + 1);
      $this->path_aplicacao .= '/';
      $this->path_link       = substr($str_path_web, 0, strrpos($str_path_web, '/'));
      $this->path_link       = substr($this->path_link, 0, strrpos($this->path_link, '/')) . '/';
      $this->path_help       = $this->path_link . "_lib/webhelp/";
      $this->path_lang       = "../_lib/lang/";
      $this->path_lang_js    = "../_lib/js/";
      $this->path_botoes     = $this->path_link . "_lib/img";
      $this->path_img_global = $this->path_link . "_lib/img";
      $this->path_img_modelo = $this->path_link . "_lib/img";
      $this->path_icones     = $this->path_link . "_lib/img";
      $this->path_imag_cab   = $this->path_link . "_lib/img";
      $this->path_btn        = $this->root . $this->path_link . "_lib/buttons/";
      $this->path_css        = $this->root . $this->path_link . "_lib/css/";
      $this->path_lib_php    = $this->root . $this->path_link . "_lib/lib/php/";
      $this->url_lib_js      = $this->path_link . "_lib/lib/js/";
      $this->url_lib         = $this->path_link . '/_lib/';
      $this->url_third       = $this->path_prod . '/third/';
      $this->path_cep        = $this->path_prod . "/cep";
      $this->path_cor        = $this->path_prod . "/cor";
      $this->path_js         = $this->path_prod . "/lib/js";
      $this->path_libs       = $this->root . $this->path_prod . "/lib/php";
      $this->path_third      = $this->root . $this->path_prod . "/third";
      $this->path_secure     = $this->root . $this->path_prod . "/secure";
      $this->path_adodb      = $this->root . $this->path_prod . "/third/adodb";

      $_SESSION['scriptcase']['dir_temp'] = $this->root . $this->path_imag_temp;
      if (isset($_SESSION['scriptcase']['app_Login']['session_timeout']['lang'])) {
          $this->str_lang = $_SESSION['scriptcase']['app_Login']['session_timeout']['lang'];
      }
      elseif (!isset($_SESSION['scriptcase']['app_Login']['actual_lang']) || $_SESSION['scriptcase']['app_Login']['actual_lang'] != $this->str_lang) {
          $_SESSION['scriptcase']['app_Login']['actual_lang'] = $this->str_lang;
          setcookie('sc_actual_lang_Pandemic_Alerts',$this->str_lang,'0','/');
      }
      global $inicial_app_Login;
      if (isset($_SESSION['scriptcase']['user_logout']))
      {
          foreach ($_SESSION['scriptcase']['user_logout'] as $ind => $parms)
          {
              if (isset($_SESSION[$parms['V']]) && $_SESSION[$parms['V']] == $parms['U'])
              {
                  $nm_apl_dest = $parms['R'];
                  $dir = explode("/", $nm_apl_dest);
                  if (count($dir) == 1)
                  {
                      $nm_apl_dest = str_replace(".php", "", $nm_apl_dest);
                      $nm_apl_dest = $this->path_link . SC_dir_app_name($nm_apl_dest) . "/" . $nm_apl_dest . ".php";
                  }
                  unset($_SESSION['scriptcase']['user_logout'][$ind]);
                  if (isset($inicial_app_Login->contr_app_Login->NM_ajax_flag) && $inicial_app_Login->contr_app_Login->NM_ajax_flag)
                  {
                      $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['action']  = $nm_apl_dest;
                      $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['target']  = $parms['T'];
                      $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['metodo']  = "post";
                      $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['script_case_init']  = $this->sc_page;
                      app_Login_pack_ajax_response();
                      exit;
                  }
?>
                  <html>
                  <body>
                  <form name="FRedirect" method="POST" action="<?php echo $nm_apl_dest; ?>" target="<?php echo $parms['T']; ?>">
                  </form>
                  <script>
                   document.FRedirect.submit();
                  </script>
                  </body>
                  </html>
<?php
                  exit;
              }
          }
      }
      $str_path = substr($this->path_prod, 0, strrpos($this->path_prod, '/') + 1); 
      if (!is_file($this->root . $str_path . 'devel/class/xmlparser/nmXmlparserIniSys.class.php'))
      {
          unset($_SESSION['scriptcase']['nm_sc_retorno']);
          unset($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']);
      }
      include($this->path_lang . $this->str_lang . ".lang.php");
      include($this->path_lang . "config_region.php");
      include($this->path_lang . "lang_config_region.php");
      $_SESSION['scriptcase']['charset'] = "UTF-8";
      ini_set('default_charset', $_SESSION['scriptcase']['charset']);
      $_SESSION['scriptcase']['charset_html']  = (isset($this->sc_charset[$_SESSION['scriptcase']['charset']])) ? $this->sc_charset[$_SESSION['scriptcase']['charset']] : $_SESSION['scriptcase']['charset'];

      asort($this->Nm_lang_conf_region);
      foreach ($this->Nm_lang_conf_region as $ind => $dados)
      {
         if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($dados))
         {
             $this->Nm_lang_conf_region[$ind] = sc_convert_encoding($dados, $_SESSION['scriptcase']['charset'], "UTF-8");
         }
      }
      if (isset($this->Nm_lang['lang_errm_dbcn_conn']))
      {
          $_SESSION['scriptcase']['db_conn_error'] = $this->Nm_lang['lang_errm_dbcn_conn'];
      }
      if (!function_exists("mb_convert_encoding"))
      {
          echo "<div><font size=6>" . $this->Nm_lang['lang_othr_prod_xtmb'] . "</font></div>";exit;
      } 
      elseif (!function_exists("sc_convert_encoding"))
      {
          echo "<div><font size=6>" . $this->Nm_lang['lang_othr_prod_xtsc'] . "</font></div>";exit;
      } 
      foreach ($this->Nm_conf_reg[$this->str_conf_reg] as $ind => $dados)
      {
          if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($dados))
          {
              $this->Nm_conf_reg[$this->str_conf_reg][$ind] = sc_convert_encoding($dados, $_SESSION['scriptcase']['charset'], "UTF-8");
          }
      }
      foreach ($this->Nm_lang as $ind => $dados)
      {
          if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($ind))
          {
              $ind = sc_convert_encoding($ind, $_SESSION['scriptcase']['charset'], "UTF-8");
              $this->Nm_lang[$ind] = $dados;
          }
          if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($dados))
          {
              $this->Nm_lang[$ind] = sc_convert_encoding($dados, $_SESSION['scriptcase']['charset'], "UTF-8");
          }
      }
      if (isset($_SESSION['scriptcase']['app_Login']['session_timeout']['redir'])) {
          $SS_cod_html  = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

';
          $SS_cod_html .= "<HTML>\r\n";
          $SS_cod_html .= " <HEAD>\r\n";
          $SS_cod_html .= "  <TITLE></TITLE>\r\n";
          $SS_cod_html .= "   <META http-equiv=\"Content-Type\" content=\"text/html; charset=" . $_SESSION['scriptcase']['charset_html'] . "\"/>\r\n";
          if ($_SESSION['scriptcase']['proc_mobile']) {
              $SS_cod_html .= "   <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>\r\n";
          }
          $SS_cod_html .= "   <META http-equiv=\"Expires\" content=\"Fri, Jan 01 1900 00:00:00 GMT\"/>\r\n";
          $SS_cod_html .= "    <META http-equiv=\"Pragma\" content=\"no-cache\"/>\r\n";
          if ($_SESSION['scriptcase']['app_Login']['session_timeout']['redir_tp'] == "R") {
              $SS_cod_html .= "  </HEAD>\r\n";
              $SS_cod_html .= "   <body>\r\n";
          }
          else {
              $SS_cod_html .= "    <link rel=\"shortcut icon\" href=\"../_lib/img/sys__NM__img__NM__emergency_2785811.png\">\r\n";
              $SS_cod_html .= "    <link rel=\"stylesheet\" type=\"text/css\" href=\"../_lib/css/" . $this->str_schema_all . "_form.css\"/>\r\n";
              $SS_cod_html .= "    <link rel=\"stylesheet\" type=\"text/css\" href=\"../_lib/css/" . $this->str_schema_all . "_form" . $_SESSION['scriptcase']['reg_conf']['css_dir'] . ".css\"/>\r\n";
              $SS_cod_html .= "  </HEAD>\r\n";
              $SS_cod_html .= "   <body class=\"scFormPage\">\r\n";
              $SS_cod_html .= "    <table align=\"center\"><tr><td style=\"padding: 0\"><div class=\"scFormBorder\">\r\n";
              $SS_cod_html .= "    <table width='100%' cellspacing=0 cellpadding=0><tr><td class=\"scFormDataOdd\" style=\"padding: 15px 30px; text-align: center\">\r\n";
              $SS_cod_html .= $this->Nm_lang['lang_errm_expired_session'] . "\r\n";
              $SS_cod_html .= "     <form name=\"Fsession_redir\" method=\"post\"\r\n";
              $SS_cod_html .= "           target=\"_self\">\r\n";
              $SS_cod_html .= "           <input type=\"button\" name=\"sc_sai_seg\" value=\"OK\" onclick=\"sc_session_redir('" . $_SESSION['scriptcase']['app_Login']['session_timeout']['redir'] . "');\">\r\n";
              $SS_cod_html .= "     </form>\r\n";
              $SS_cod_html .= "    </td></tr></table>\r\n";
              $SS_cod_html .= "    </div></td></tr></table>\r\n";
          }
          $SS_cod_html .= "    <script type=\"text/javascript\">\r\n";
          if ($_SESSION['scriptcase']['app_Login']['session_timeout']['redir_tp'] == "R") {
              $SS_cod_html .= "      sc_session_redir('" . $_SESSION['scriptcase']['app_Login']['session_timeout']['redir'] . "');\r\n";
          }
          $SS_cod_html .= "      function sc_session_redir(url_redir)\r\n";
          $SS_cod_html .= "      {\r\n";
          $SS_cod_html .= "         if (window.parent && window.parent.document != window.document && typeof window.parent.sc_session_redir === 'function')\r\n";
          $SS_cod_html .= "         {\r\n";
          $SS_cod_html .= "            window.parent.sc_session_redir(url_redir);\r\n";
          $SS_cod_html .= "         }\r\n";
          $SS_cod_html .= "         else\r\n";
          $SS_cod_html .= "         {\r\n";
          $SS_cod_html .= "             if (window.opener && typeof window.opener.sc_session_redir === 'function')\r\n";
          $SS_cod_html .= "             {\r\n";
          $SS_cod_html .= "                 window.close();\r\n";
          $SS_cod_html .= "                 window.opener.sc_session_redir(url_redir);\r\n";
          $SS_cod_html .= "             }\r\n";
          $SS_cod_html .= "             else\r\n";
          $SS_cod_html .= "             {\r\n";
          $SS_cod_html .= "                 window.location = url_redir;\r\n";
          $SS_cod_html .= "             }\r\n";
          $SS_cod_html .= "         }\r\n";
          $SS_cod_html .= "      }\r\n";
          $SS_cod_html .= "    </script>\r\n";
          $SS_cod_html .= " </body>\r\n";
          $SS_cod_html .= "</HTML>\r\n";
          unset($_SESSION['scriptcase']['app_Login']['session_timeout']);
          unset($_SESSION['sc_session']);
      }
      if (isset($SS_cod_html) && isset($_GET['nmgp_opcao']) && (substr($_GET['nmgp_opcao'], 0, 14) == "ajax_aut_comp_" || substr($_GET['nmgp_opcao'], 0, 13) == "ajax_autocomp"))
      {
          unset($_SESSION['sc_session']);
          $oJson = new Services_JSON();
          echo $oJson->encode("ss_time_out");
          exit;
      }
      elseif (isset($SS_cod_html) && isset($_POST['nmgp_opcao']) && ($_POST['nmgp_opcao'] == "ajax_dyn_refresh_field" || $_POST['nmgp_opcao'] == "ajax_add_dyn_search" || $_POST['nmgp_opcao'] == "ajax_ch_bi_dyn_search"))
      {
          unset($_SESSION['sc_session']);
          $this->Arr_result = array();
          $this->Arr_result['ss_time_out'] = true;
          $oJson = new Services_JSON();
          echo $oJson->encode($this->Arr_result);
          exit;
      }
      elseif (isset($SS_cod_html) && isset($_POST['rs']) && !is_array($_POST['rs']) && 'ajax_' == substr($_POST['rs'], 0, 5) && isset($_POST['rsargs']) && !empty($_POST['rsargs']))
      {
          $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['action']  = "app_Login.php";
          $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['target']  = "_self";
          $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['metodo']  = "post";
          $inicial_app_Login->contr_app_Login->NM_ajax_info['redir']['script_case_init']  = $this->sc_page;
          app_Login_pack_ajax_response();
          exit;
      }
      elseif (isset($SS_cod_html))
      {
          echo $SS_cod_html;
          exit;
      }
      if (isset($_SESSION['sc_session']['SC_parm_violation']) && !isset($_SESSION['scriptcase']['app_Login']['session_timeout']['redir']))
      {
          unset($_SESSION['sc_session']['SC_parm_violation']);
          echo "<html>";
          echo "<body>";
          echo "<table align=\"center\" width=\"50%\" border=1 height=\"50px\">";
          echo "<tr>";
          echo "   <td align=\"center\">";
          echo "       <b><font size=4>" . $this->Nm_lang['lang_errm_ajax_data'] . "</font>";
          echo "   </b></td>";
          echo " </tr>";
          echo "</table>";
          echo "</body>";
          echo "</html>";
          exit;
      }
      $PHP_ver = str_replace(".", "", phpversion()); 
      if (substr($PHP_ver, 0, 3) < 434)
      {
          echo "<div><font size=6>" . $this->Nm_lang['lang_othr_prod_phpv'] . "</font></div>";exit;
      }
      if (file_exists($this->path_libs . "/ver.dat"))
      {
          $SC_ver = file($this->path_libs . "/ver.dat"); 
          $SC_ver = str_replace(".", "", $SC_ver[0]); 
          if (substr($SC_ver, 0, 5) < 40015)
          {
              echo "<div><font size=6>" . $this->Nm_lang['lang_othr_prod_incp'] . "</font></div>";exit;
          } 
      } 
      if (-1 != version_compare(phpversion(), '5.0.0'))
      {
         $this->path_grafico    = $this->root . $this->path_prod . "/third/jpgraph5/src";
      }
      else
      {
          $this->path_grafico    = $this->root . $this->path_prod . "/third/jpgraph4/src";
      }
      $_SESSION['sc_session'][$this->sc_page]['app_Login']['path_doc'] = $this->path_doc; 
      $_SESSION['scriptcase']['nm_path_prod'] = $this->root . $this->path_prod . "/"; 
      $_SESSION['scriptcase']['nm_root_cep']  = $this->root; 
      $_SESSION['scriptcase']['nm_path_cep']  = $this->path_cep; 
      if (empty($this->path_imag_cab))
      {
          $this->path_imag_cab = $this->path_img_global;
      }
      if (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu'])) {
          $_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu'] = "";
      }
      if (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'])) {
          $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] = "";
      }
      if (!is_dir($this->root . $this->path_prod))
      {
          $str_message = "<html>

<head>
    <title>{var_str_title}</title>
    <style>
        body {
            margin: 0px;
            padding: 0px;
            overflow-x: hidden;
            min-width: 320px;
            background: #FFFFFF;
            font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
            font-size: 14px;
            line-height: 1.4285em;
            color: rgba(0, 0, 0, 0.87);
            font-smoothing: antialiased;
        }

        html,
        body {
            height: 100%;
        }

        body {
            margin: 0;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        user agent stylesheet body {
            display: block;
            margin: 8px;
        }

        html {
            font-size: 14px;
        }

        html {
            line-height: 1.15;
            -ms-text-size-adjust: 100%;
            -webkit-text-size-adjust: 100%;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        ::selection {
            background-color: #CCE2FF;
            color: rgba(0, 0, 0, 0.87);
        }

        .ui.container {
            width: 933px;
            min-width: 992px;
            max-width: 1199px;
            margin-left: auto !important;
            margin-right: auto !important;
        }

        .ui.container {
            display: block;
            max-width: 100% !important;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        .ui.message:last-child {
            margin-bottom: 0em;
        }

        .ui.message:first-child {
            margin-top: 0em;
        }

        .ui.message {
            font-size: 1em;
        }

        .ui.message {
            position: relative;
            min-height: 1em;
            margin: 1em 0em;
            background: #F8F8F9;
            padding: 1em 1.5em;
            line-height: 1.4285em;
            color: rgba(0, 0, 0, 0.87);
            transition: opacity 0.1s ease, color 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
            border-radius: 0.28571429rem;
            box-shadow: 0px 0px 0px 1px rgba(34, 36, 38, 0.22) inset, 0px 0px 0px 0px rgba(0, 0, 0, 0);
        }

        article,
        aside,
        footer,
        header,
        nav,
        section {
            display: block;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        .ui.message> :last-child {
            margin-bottom: 0em;
        }

        .ui.message> :first-child {
            margin-top: 0em;
        }

        .ui.message .header+p {
            margin-top: 0.25em;
        }

        .ui.message p {
            opacity: 0.85;
            margin: 0.75em 0em;
        }

        p {
            margin: 0em 0em 1em;
            line-height: 1.4285em;
        }

        .ui.message .header:not(.ui) {
            font-size: 1.14285714em;
        }

        .ui.message .header {
            display: block;
            font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
            font-weight: bold;
            margin: -0.14285714em 0em 1.2rem 0em;
        }

        .ui.button {
            cursor: pointer;
            display: inline-block;
            min-height: 1em;
            outline: 0;
            border: none;
            vertical-align: baseline;
            background: #e0e1e2 none;
            color: rgba(0, 0, 0, .6);
            font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
            margin: 0 .25em 0 0;
            padding: .78571429em 1.5em .78571429em;
            text-transform: none;
            text-shadow: none;
            font-weight: 700;
            line-height: 1em;
            font-style: normal;
            text-align: center;
            text-decoration: none;
            border-radius: .28571429rem;
            box-shadow: 0 0 0 1px transparent inset, 0 0 0 0 rgba(34, 36, 38, .15) inset;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            transition: opacity .1s ease, background-color .1s ease, color .1s ease, box-shadow .1s ease, background .1s ease;
            will-change: '';
            -webkit-tap-highlight-color: transparent;
        }
        
        .ui.button,
        .ui.buttons .button,
        .ui.buttons .or {
            font-size: 1rem;
            flex-flow: row nowrap;
            justify-content: center;
            align-items: center;
            column-gap: .5rem;
            display: flex;
        }
        
        .ui.primary.button,
        .ui.primary.buttons .button {
            background-color: #2185d0;
            color: #fff;
            text-shadow: none;
            background-image: none;
        }
        
        .ui.primary.button {
            box-shadow: 0 0 0 0 rgba(34, 36, 38, .15) inset;
        }

        [type=reset], [type=submit], button, html [type=button] {
            -webkit-appearance: button;
        }

        .icon{
            position: relative;
            width: 1.2rem;
            height: 1.2rem;
            display: block;
            color: inherit;
            background-repeat: no-repeat;
        }

        .icon.database{
            background-image: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\" fill=\"%23FFFFFF\"><path d=\"M448 80v48c0 44.2-100.3 80-224 80S0 172.2 0 128V80C0 35.8 100.3 0 224 0S448 35.8 448 80zM393.2 214.7c20.8-7.4 39.9-16.9 54.8-28.6V288c0 44.2-100.3 80-224 80S0 332.2 0 288V186.1c14.9 11.8 34 21.2 54.8 28.6C99.7 230.7 159.5 240 224 240s124.3-9.3 169.2-25.3zM0 346.1c14.9 11.8 34 21.2 54.8 28.6C99.7 390.7 159.5 400 224 400s124.3-9.3 169.2-25.3c20.8-7.4 39.9-16.9 54.8-28.6V432c0 44.2-100.3 80-224 80S0 476.2 0 432V346.1z\"/></svg>');
        }
    </style>
</head>

<body>
    <div class='ui container' style='padding-top:2rem'>
        <section class='ui message'>
            <div class='content'>
                <div class='header'>
                    <h1 class='ui header'>{var_str_title}</h1>
                </div>
                <p>{var_str_message}</p>
                <p>{var_str_message_conn}</p>
                {v_str_btn_inside}
            </div>
        </section>
    </div>";
          $str_message_end = "</body>
</html>";
          $str_message = str_replace('{var_str_title}', $this->Nm_lang['lang_errm_cmlb_nfndtitle'], $str_message);
          $str_message = str_replace('{var_str_message}', $this->Nm_lang['lang_errm_cmlb_nfnd'], $str_message);
          $str_message = str_replace('{v_str_btn_inside}', '', $str_message);
          echo $str_message;
          if (!$_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu'] && (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan']) || $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'] != 'app_Login')) 
          { 
              if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno'])) 
              { 
?>
                  <input type="button" id="sai" onClick="window.location='<?php echo $_SESSION['scriptcase']['nm_sc_retorno'] ?>'; return false" class="scButton_default" value="<?php echo $this->Nm_lang['lang_btns_back'] ?>" title="<?php echo $this->Nm_lang['lang_btns_back_hint'] ?>" style="<?php echo $sCondStyle; ?>vertical-align: middle;display: ''">

<?php
              } 
              else 
              { 
?>
                  <input type="button" id="sai" onClick="window.location='<?php echo $nm_url_saida ?>'; return false" class="scButton_default" value="<?php echo $this->Nm_lang['lang_btns_exit'] ?>" title="<?php echo $this->Nm_lang['lang_btns_exit_hint'] ?>" style="<?php echo $sCondStyle; ?>vertical-align: middle;display: ''">

<?php
              } 
          } 
          echo $str_message_end;
          exit ;
      }

      $this->path_atual  = getcwd();
      $opsys = strtolower(php_uname());

      global $under_dashboard, $dashboard_app, $own_widget, $parent_widget, $compact_mode, $remove_margin, $remove_border;
      if (!isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['under_dashboard']))
      {
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['under_dashboard'] = false;
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['dashboard_app']   = '';
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['own_widget']      = '';
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['parent_widget']   = '';
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['compact_mode']    = false;
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['remove_margin']   = false;
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['remove_border']   = false;
      }
      if (isset($_GET['under_dashboard']) && 1 == $_GET['under_dashboard'])
      {
          if (isset($_GET['own_widget']) && 'dbifrm_widget' == substr($_GET['own_widget'], 0, 13)) {
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['own_widget'] = $_GET['own_widget'];
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['under_dashboard'] = true;
              if (isset($_GET['dashboard_app'])) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['dashboard_app'] = $_GET['dashboard_app'];
              }
              if (isset($_GET['parent_widget'])) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['parent_widget'] = $_GET['parent_widget'];
              }
              if (isset($_GET['compact_mode'])) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['compact_mode'] = 1 == $_GET['compact_mode'];
              }
              if (isset($_GET['remove_margin'])) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['remove_margin'] = 1 == $_GET['remove_margin'];
              }
              if (isset($_GET['remove_border'])) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['remove_border'] = 1 == $_GET['remove_border'];
              }
          }
      }
      elseif (isset($under_dashboard) && 1 == $under_dashboard)
      {
          if (isset($own_widget) && 'dbifrm_widget' == substr($own_widget, 0, 13)) {
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['own_widget'] = $own_widget;
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['under_dashboard'] = true;
              if (isset($dashboard_app)) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['dashboard_app'] = $dashboard_app;
              }
              if (isset($parent_widget)) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['parent_widget'] = $parent_widget;
              }
              if (isset($compact_mode)) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['compact_mode'] = 1 == $compact_mode;
              }
              if (isset($remove_margin)) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['remove_margin'] = 1 == $remove_margin;
              }
              if (isset($remove_border)) {
                  $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['remove_border'] = 1 == $remove_border;
              }
          }
      }
      if (!isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['maximized']))
      {
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['maximized'] = false;
      }
      if (isset($_GET['maximized']))
      {
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['maximized'] = 1 == $_GET['maximized'];
      }
      if ($_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['under_dashboard'])
      {
          $sTmpDashboardApp = $_SESSION['sc_session'][$this->sc_page]['app_Login']['dashboard_info']['dashboard_app'];
          if ('' != $sTmpDashboardApp && isset($_SESSION['scriptcase']['dashboard_targets'][$sTmpDashboardApp]["app_Login"]))
          {
              foreach ($_SESSION['scriptcase']['dashboard_targets'][$sTmpDashboardApp]["app_Login"] as $sTmpTargetLink => $sTmpTargetWidget)
              {
                  if (isset($this->sc_lig_target[$sTmpTargetLink]))
                  {
                      if (isset($this->sc_lig_iframe[$this->sc_lig_target[$sTmpTargetLink]]))
                      {
                          $this->sc_lig_iframe[$this->sc_lig_target[$sTmpTargetLink]] = $sTmpTargetWidget;
                      }
                      $this->sc_lig_target[$sTmpTargetLink] = $sTmpTargetWidget;
                  }
              }
          }
      }
        global $link_compact_mode, $link_remove_margin, $link_remove_border;
        if (isset($link_compact_mode) && 'ok' == $link_compact_mode) {
            if (!isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info'])) {
                $_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info'] = array();
            }
            $_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info']['compact_mode'] = true;
        }
        if (isset($link_remove_margin) && 'ok' == $link_remove_margin) {
            if (!isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info'])) {
                $_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info'] = array();
            }
            $_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info']['remove_margin'] = true;
        }
        if (isset($link_remove_border) && 'ok' == $link_remove_border) {
            if (!isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info'])) {
                $_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info'] = array();
            }
            $_SESSION['sc_session'][$this->sc_page]['app_Login']['link_info']['remove_border'] = true;
        }

      $this->nm_cont_lin       = 0;
      $this->nm_limite_lin     = 0;
      $this->nm_limite_lin_prt = 0;
// 
      include_once($this->path_adodb . "/adodb.inc.php");
      $this->sc_Include($this->path_libs . "/nm_sec_prod.php", "F", "nm_reg_prod");
      $this->sc_Include($this->path_libs . "/nm_ini_perfil.php", "F", "perfil_lib");
      if(function_exists('set_php_timezone'))  set_php_timezone('app_Login'); 
      $this->sc_Include($this->path_lib_php . "/nm_data.class.php", "C", "nm_data") ; 
      $this->sc_Include($this->path_lib_php . "/nm_edit.php", "F", "nmgp_Form_Num_Val") ; 
      $this->sc_Include($this->path_lib_php . "/nm_conv_dados.php", "F", "nm_conv_limpa_dado") ; 
      $this->sc_Include($this->path_lib_php . "/nm_functions.php", "", "") ; 
      $this->sc_Include($this->path_lib_php . "/nm_api.php", "", "") ; 
      $this->sc_Include($this->path_lib_php . "/fix.php", "", "") ; 
      $this->nm_data = new nm_data("fr");
      global $inicial_app_Login, $NM_run_iframe;
      if ((isset($inicial_app_Login->contr_app_Login->NM_ajax_flag) && $inicial_app_Login->contr_app_Login->NM_ajax_flag) || (isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['embutida_call']) && $_SESSION['sc_session'][$this->sc_page]['app_Login']['embutida_call']) || $NM_run_iframe == 1)
      {
           $_SESSION['scriptcase']['sc_ctl_ajax'] = 'part';
      }
      perfil_lib($this->path_libs);
      if (!isset($_SESSION['sc_session'][$this->sc_page]['SC_Check_Perfil']))
      {
          if(function_exists("nm_check_perfil_exists")) nm_check_perfil_exists($this->path_libs, $this->path_prod);
          $_SESSION['sc_session'][$this->sc_page]['SC_Check_Perfil'] = true;
      }
      if (function_exists("nm_check_pdf_server")) $this->server_pdf = nm_check_pdf_server($this->path_libs, $this->server_pdf);
      if (!isset($_SESSION['scriptcase']['sc_num_img']) || empty($_SESSION['scriptcase']['sc_num_img']))
      { 
          $_SESSION['scriptcase']['sc_num_img'] = 1; 
      } 
      $this->Export_img_zip = false;;
      $this->Img_export_zip  = array();
      $this->regionalDefault();
      $this->sc_tem_trans_banco = false;
      $this->nm_bases_access     = array("access", "ado_access", "ace_access");
      $this->nm_bases_db2        = array("db2", "db2_odbc", "odbc_db2", "odbc_db2v6", "pdo_db2_odbc", "pdo_ibm");
      $this->nm_bases_ibase      = array("ibase", "firebird", "pdo_firebird", "borland_ibase");
      $this->nm_bases_informix   = array("informix", "informix72", "pdo_informix");
      $this->nm_bases_mssql      = array("mssql", "ado_mssql", "adooledb_mssql", "odbc_mssql", "mssqlnative", "pdo_sqlsrv", "pdo_dblib", "azure_mssql", "azure_ado_mssql", "azure_adooledb_mssql", "azure_odbc_mssql", "azure_mssqlnative", "azure_pdo_sqlsrv", "azure_pdo_dblib", "googlecloud_mssql", "googlecloud_ado_mssql", "googlecloud_adooledb_mssql", "googlecloud_odbc_mssql", "googlecloud_mssqlnative", "googlecloud_pdo_sqlsrv", "googlecloud_pdo_dblib", "amazonrds_mssql", "amazonrds_ado_mssql", "amazonrds_adooledb_mssql", "amazonrds_odbc_mssql", "amazonrds_mssqlnative", "amazonrds_pdo_sqlsrv", "amazonrds_pdo_dblib");
      $this->nm_bases_mysql      = array("mysql", "mysqlt", "mysqli", "maxsql", "pdo_mysql", "azure_mysql", "azure_mysqlt", "azure_mysqli", "azure_maxsql", "azure_pdo_mysql", "googlecloud_mysql", "googlecloud_mysqlt", "googlecloud_mysqli", "googlecloud_maxsql", "googlecloud_pdo_mysql", "amazonrds_mysql", "amazonrds_mysqlt", "amazonrds_mysqli", "amazonrds_maxsql", "amazonrds_pdo_mysql");
      $this->nm_bases_postgres   = array("postgres", "postgres64", "postgres7", "pdo_pgsql", "azure_postgres", "azure_postgres64", "azure_postgres7", "azure_pdo_pgsql", "googlecloud_postgres", "googlecloud_postgres64", "googlecloud_postgres7", "googlecloud_pdo_pgsql", "amazonrds_postgres", "amazonrds_postgres64", "amazonrds_postgres7", "amazonrds_pdo_pgsql");
      $this->nm_bases_oracle     = array("oci8", "oci805", "oci8po", "odbc_oracle", "oracle", "pdo_oracle", "oraclecloud_oci8", "oraclecloud_oci805", "oraclecloud_oci8po", "oraclecloud_odbc_oracle", "oraclecloud_oracle", "oraclecloud_pdo_oracle", "amazonrds_oci8", "amazonrds_oci805", "amazonrds_oci8po", "amazonrds_odbc_oracle", "amazonrds_oracle", "amazonrds_pdo_oracle");
      $this->nm_bases_sqlite     = array("sqlite", "sqlite3", "pdosqlite");
      $this->nm_bases_sybase     = array("sybase", "pdo_sybase_odbc", "pdo_sybase_dblib");
      $this->nm_bases_vfp        = array("vfp");
      $this->nm_bases_odbc       = array("odbc");
      $this->nm_bases_progress   = array("progress", "pdo_progress_odbc");
      $this->nm_bases_all        = array_merge($this->nm_bases_access, $this->nm_bases_db2, $this->nm_bases_ibase, $this->nm_bases_informix, $this->nm_bases_mssql, $this->nm_bases_mysql, $this->nm_bases_postgres, $this->nm_bases_oracle, $this->nm_bases_sqlite, $this->nm_bases_sybase, $this->nm_bases_vfp, $this->nm_bases_odbc, $this->nm_bases_progress);
      $_SESSION['scriptcase']['nm_bases_security']  = "enc_nm_enc_v1DcBwDQFaZ1BYHQFaHuzGVIBsDuFqHMFGDcJUZSBOD1rwHuFGDMveHEFiDWXCHMFGD9NmH9X7Z1BYHuFaHuNOZSrCH5FqDoXGHQJmZ1BiHAN7HQJwDEBODkFeH5FYVoFGHQJKDQFaHIvsVWJsDMvOV9FeDWXKVENUHQBsZ1BiHANOZMB/DENOVkJ3DuFaHIFUHQJKDQJsZ1vCV5FGHuNOV9FeDWXCDoraD9XOZ1X7Z1BeD5F7DErKVkXeV5FaVoBiD9FYH9X7HABYHuFaHuNOZSrCH5FqDoXGHQJmZ1FUZ1BeD5NUDErKHEBUDWF/DoFUHQNmDQJsZ1rwD5XGHuvmVcBOV5BmDoJsD9XOZ1F7HIveD5BqHgBeHEFiV5B3DoF7D9XsDuFaHAveVWBOHuvmZSJqDWJeVErqHQBsZ1BiD1rwHuJsDEvsZSXeDuFYHIJsD9XsZ9JeD1BeD5F7DMvmVcFeV5X/VEBiDcNmZSBOHAN7HuBOHgBOHEJqDurmVoFGHQXsDQFaD1veHQJwDMvmDkBsHEFGDoXGHQXOZSBqDSNOHuFUHgrKDkXKH5FGVoFGHQJeDQB/HAveHuraHgrwVcFeH5XKVoBqD9BsZ1F7DSrYD5rqDMrYZSJ3V5B7ZuJsHQNwDQB/HANKV5BODMBYVcBUH5B3DoXGDcNmZSBqHArYHuBqHgNKZSJ3DuXKVoFGDcXGH9BiHIBeHQXGDMBOVcBUDuFGDoXGDcNmZSBOHArYHuFGHgNOVkJ3DurmDoF7D9XsDQJsDSBYV5FGHgNKDkBsV5X/VEBiHQXGH9BOHIBOZMBqHgNOZSJ3DuX/VoFGHQFYZSBiHABYHuJeDMvsV9BUH5B3DoXGDcFYZ1FGD1NaZMBqDMvCHArsHEB7VoFGHQBiZ9XGDSzGVWJsDMvOVIBsDurGVoBqD9BsZ1F7DSrYD5rqDMrYZSJ3DurmZuJsDcXGZSBiHArYHQB/DMBOVcB/H5B7DoXGHQNwZSBqHANOHuBqHgNKVkJ3V5B7VoFGHQJKZSFUHANOHuNUHgvOV9BUDWBmDoXGHQBqZ1FGD1vsZMB/HgBeHArCH5BmDoF7D9XsDQJsDSBYV5FGHgNKDkBsHEX/VEBiHQXGH9BOD1zGD5XGHgNOHENiHEB7VoFGHQJeDQBqHIrwHQJeHgrwZSJqDWBmDoXGHQXGZ1FGZ1NOHuFaHgvsVkJ3DWB3VoFGHQNwDQBqD1BeHQJsDMBYZSNiH5XKVoBqD9BsZ1F7DSrYD5rqDMrYZSJ3HEB7ZuJsHQXODQBqHANOHQFaDMrYVcXKDuFGDoXGHQNwZSBqHABYHuBqHgrKDkB/DurmVoFGHQNwH9BiDSN7HurqDMBOVcXKDWB3DoXGHQXOZSBOHArYHQBOHgNKVkJqDWB3DoF7D9XsDQJsDSBYV5FGHgNKDkBsHEX/VEBiDcNmZSBqHArYHQNUHgBeHEJqDuXKVoFGHQXOZSFUDSN7HQBODMzGVcFeDWXKDoXGDcFYZ1BOHAN7HQJeHgBeHArCDuX/VoFGHQNmDQFaD1veHQXGHgrwVIB/H5B7VoBqD9BsZ1F7DSrYD5rqDMrYZSJGH5FYDoF7DcXOZSFGHAveV5FUHuBYVcFKDur/VoJwHQBsZ1BiDSvmD5FaHgvsVkXeDWFqZuFaHQNmDQX7HArYD5B/HgrKV9FiV5X7VErqHQBqZkFUZ1BeZMBODEvsZSJGDuFaDoJeD9XsZSX7Z1rwVWJsDMrwDkFCH5FqVoBqD9XOZSB/DSrYD5BqDEvsHEFiH5FYDoraD9NwZSX7D1vOV5JwHgNKDkBODuFqDoFGDcBqVIJwD1rwD5JeDMBYZSJqV5FaVoJeD9XsZSFGD1BeVWJsHgrYDkBsV5F/HMFUHQBsZ1FGDSrYHuFGHgvCHArCDuFYHIFUHQNmH9BiZ1rwHuJeDMBYDkBsDWXCDoJsDcBwH9B/Z1rYHQJwHgveDkXKDWBmDoJeHQXOZ9XGHANKV5BODMvOZSNiH5FqHMBiD9BsVIraD1rwV5X7HgBeHErCHEFqVoB/HQFYZSFGD1NKV5BqHgrwZSJqH5FqHMB/HQBiZSBqD1rKHQBODMBYHArCDWF/VoBiDcJUZSX7Z1BYHuFaDMBYV9FeV5X7HMBOHQJmZkFGZ1rYHQBiHgBOHEFKDWF/HIX7HQXsDuFaZ1N7HuX7DMvmV9FeV5FYHIFGDcFYZkFGD1rKHQJsHgBeHEFiV5B3DoF7D9XsDuFaHANKVWBqDMrwZSNiDWB3VEB/";
      $this->prep_conect();
      if (isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['initialize']) && $_SESSION['sc_session'][$this->sc_page]['app_Login']['initialize'])  
      { 
          $this->conectDB();
      }
   }

   function init2()
   {
      if (isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['initialize']) && $_SESSION['sc_session'][$this->sc_page]['app_Login']['initialize'])  
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['app_Login']['initialize'] = false;
          $this->Db->Close(); 
      } 
      $this->conectDB();
      if (!in_array(strtolower($this->nm_tpbanco), $this->nm_bases_all))
      {
          echo "<tr>";
          echo "   <td bgcolor=\"\">";
          echo "       <b><font size=\"4\">" . $this->Nm_lang['lang_errm_dbcn_nspt'] . "</font>";
          echo "  " . $perfil_trab;
          echo "   </b></td>";
          echo " </tr>";
          echo "</table>";
          if (!$_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu'] && (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan']) || $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'] != 'app_Login')) 
          { 
              if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno'])) 
              { 
                  echo "<a href='" . $_SESSION['scriptcase']['nm_sc_retorno'] . "' target='_self'><img border='0' src='" . $this->path_botoes . "/nm_scriptcase9_Rhino_bvoltar.gif' title='" . $this->Nm_lang['lang_btns_rtrn_scrp_hint'] . "' align=absmiddle></a> \n" ; 
              } 
              else 
              { 
                  echo "<a href='$nm_url_saida' target='_self'><img border='0' src='" . $this->path_botoes . "/nm_scriptcase9_Rhino_bsair.gif' title='" . $this->Nm_lang['lang_btns_exit_appl_hint'] . "' align=absmiddle></a> \n" ; 
              } 
          } 
          exit ;
      } 
      $this->Nm_accent_access    = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_db2       = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_ibase     = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_informix  = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_mssql     = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_mysql     = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_postgres  = array('cmp_i'=>"unaccent(",'cmp_f'=>")",'cmp_apos'=>"",'arg_i'=>"' || unaccent('",'arg_f'=>"') || '",'arg_apos'=>"");
      $this->Nm_accent_oracle    = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_sqlite    = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_sybase    = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_vfp       = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_odbc      = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");
      $this->Nm_accent_progress  = array('cmp_i'=>"",'cmp_f'=>"",'cmp_apos'=>"",'arg_i'=>"",'arg_f'=>"",'arg_apos'=>"");

      $this->Nm_accent_no = array('cmp_i'=>'','cmp_f'=>'','cmp_apos'=>'','arg_i'=>'','arg_f'=>'','arg_apos'=>'');
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_access)) {
          $this->Nm_accent_yes = $this->Nm_accent_access;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_db2)) {
          $this->Nm_accent_yes = $this->Nm_accent_db2;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_ibase)) {
          $this->Nm_accent_yes = $this->Nm_accent_ibase;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_informix)) {
          $this->Nm_accent_yes = $this->Nm_accent_informix;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_mssql)) {
          $this->Nm_accent_yes = $this->Nm_accent_mssql;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_mysql)) {
          $this->Nm_accent_yes = $this->Nm_accent_mysql;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_postgres)) {
          $this->Nm_accent_yes = $this->Nm_accent_postgres;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_oracle)) {
          $this->Nm_accent_yes = $this->Nm_accent_oracle;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_sqlite)) {
          $this->Nm_accent_yes = $this->Nm_accent_sqlite;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_sybase)) {
          $this->Nm_accent_yes = $this->Nm_accent_sybase;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_vfp)) {
          $this->Nm_accent_yes = $this->Nm_accent_vfp;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_odbc)) {
          $this->Nm_accent_yes = $this->Nm_accent_odbc;
      }
      elseif (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_progress)) {
          $this->Nm_accent_yes = $this->Nm_accent_progress;
      }
      else {
          $this->Nm_accent_yes = $this->Nm_accent_no;
      }
   }
   function prep_conect()
   {
      $con_devel             =  (isset($_SESSION['scriptcase']['app_Login']['glo_nm_conexao'])) ? $_SESSION['scriptcase']['app_Login']['glo_nm_conexao'] : ""; 
      $perfil_trab           = ""; 
      $this->nm_falta_var    = ""; 
      $this->nm_falta_var_db = ""; 
      $nm_crit_perfil        = false;
      if (isset($_SESSION['scriptcase']['sc_connection']) && !empty($_SESSION['scriptcase']['sc_connection']))
      {
          foreach ($_SESSION['scriptcase']['sc_connection'] as $NM_con_orig => $NM_con_dest)
          {
              if (isset($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']) && $_SESSION['scriptcase']['app_Login']['glo_nm_conexao'] == $NM_con_orig)
              {
/*NM*/            $_SESSION['scriptcase']['app_Login']['glo_nm_conexao'] = $NM_con_dest;
              }
              if (isset($_SESSION['scriptcase']['app_Login']['glo_nm_perfil']) && $_SESSION['scriptcase']['app_Login']['glo_nm_perfil'] == $NM_con_orig)
              {
/*NM*/            $_SESSION['scriptcase']['app_Login']['glo_nm_perfil'] = $NM_con_dest;
              }
              if (isset($_SESSION['scriptcase']['app_Login']['glo_con_' . $NM_con_orig]))
              {
                  $_SESSION['scriptcase']['app_Login']['glo_con_' . $NM_con_orig] = $NM_con_dest;
              }
          }
      }
      if (isset($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']) && !empty($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']))
      {
          db_conect_devel($con_devel, $this->root . $this->path_prod, 'Pandemic_Alerts', 2, $this->force_db_utf8); 
          if (empty($_SESSION['scriptcase']['glo_tpbanco']) && empty($_SESSION['scriptcase']['glo_banco']))
          {
              $nm_crit_perfil = true;
          }
      }
      if (isset($_SESSION['scriptcase']['app_Login']['glo_nm_perfil']) && !empty($_SESSION['scriptcase']['app_Login']['glo_nm_perfil']))
      {
          $perfil_trab = $_SESSION['scriptcase']['app_Login']['glo_nm_perfil'];
      }
      elseif (isset($_SESSION['scriptcase']['glo_perfil']) && !empty($_SESSION['scriptcase']['glo_perfil']))
      {
          $perfil_trab = $_SESSION['scriptcase']['glo_perfil'];
      }
      if (!empty($perfil_trab))
      {
          $_SESSION['scriptcase']['glo_senha_protect'] = "";
          carrega_perfil($perfil_trab, $this->path_libs, "S");
          if (empty($_SESSION['scriptcase']['glo_senha_protect']))
          {
              $nm_crit_perfil = true;
          }
      }
      else
      {
          $perfil_trab = $con_devel;
      }
// 
      if (!isset($_SESSION['scriptcase']['glo_tpbanco']))
      {
          if (!$nm_crit_perfil)
          {
              $this->nm_falta_var_db .= "glo_tpbanco; ";
          }
      }
      else
      {
          $this->nm_tpbanco = $_SESSION['scriptcase']['glo_tpbanco']; 
      }
      if (!isset($_SESSION['scriptcase']['glo_servidor']))
      {
          if (!$nm_crit_perfil)
          {
              $this->nm_falta_var_db .= "glo_servidor; ";
          }
      }
      else
      {
          $this->nm_servidor = $_SESSION['scriptcase']['glo_servidor']; 
      }
      if (!isset($_SESSION['scriptcase']['glo_banco']))
      {
          if (!$nm_crit_perfil)
          {
              $this->nm_falta_var_db .= "glo_banco; ";
          }
      }
      else
      {
          $this->nm_banco = $_SESSION['scriptcase']['glo_banco']; 
      }
      if (!isset($_SESSION['scriptcase']['glo_usuario']))
      {
          if (!$nm_crit_perfil)
          {
              $this->nm_falta_var_db .= "glo_usuario; ";
          }
      }
      else
      {
          $this->nm_usuario = $_SESSION['scriptcase']['glo_usuario']; 
      }
      if (!isset($_SESSION['scriptcase']['glo_senha']))
      {
          if (!$nm_crit_perfil)
          {
              $this->nm_falta_var_db .= "glo_senha; ";
          }
      }
      else
      {
          $this->nm_senha = $_SESSION['scriptcase']['glo_senha']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db2_autocommit']))
      {
          $this->nm_con_db2['db2_autocommit'] = $_SESSION['scriptcase']['glo_db2_autocommit']; 
      }
      if (isset($_SESSION['scriptcase']['glo_database_encoding']))
      {
          $this->nm_database_encoding = $_SESSION['scriptcase']['glo_database_encoding']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db2_i5_lib']))
      {
          $this->nm_con_db2['db2_i5_lib'] = $_SESSION['scriptcase']['glo_db2_i5_lib']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db2_i5_naming']))
      {
          $this->nm_con_db2['db2_i5_naming'] = $_SESSION['scriptcase']['glo_db2_i5_naming']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db2_i5_commit']))
      {
          $this->nm_con_db2['db2_i5_commit'] = $_SESSION['scriptcase']['glo_db2_i5_commit']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db2_i5_query_optimize']))
      {
          $this->nm_con_db2['db2_i5_query_optimize'] = $_SESSION['scriptcase']['glo_db2_i5_query_optimize']; 
      }
      if (isset($_SESSION['scriptcase']['glo_use_persistent']))
      {
          $this->nm_con_persistente = $_SESSION['scriptcase']['glo_use_persistent']; 
      }
      if (isset($_SESSION['scriptcase']['glo_use_schema']))
      {
          $this->nm_con_use_schema = $_SESSION['scriptcase']['glo_use_schema']; 
      }
      $this->nm_arr_db_extra_args = array(); 
      if (isset($_SESSION['scriptcase']['glo_use_ssl']))
      {
          $this->nm_arr_db_extra_args['use_ssl'] = $_SESSION['scriptcase']['glo_use_ssl']; 
      }
      if (isset($_SESSION['scriptcase']['glo_mysql_ssl_key']))
      {
          $this->nm_arr_db_extra_args['mysql_ssl_key'] = $_SESSION['scriptcase']['glo_mysql_ssl_key']; 
      }
      if (isset($_SESSION['scriptcase']['glo_mysql_ssl_cert']))
      {
          $this->nm_arr_db_extra_args['mysql_ssl_cert'] = $_SESSION['scriptcase']['glo_mysql_ssl_cert']; 
      }
      if (isset($_SESSION['scriptcase']['glo_mysql_ssl_capath']))
      {
          $this->nm_arr_db_extra_args['mysql_ssl_capath'] = $_SESSION['scriptcase']['glo_mysql_ssl_capath']; 
      }
      if (isset($_SESSION['scriptcase']['glo_mysql_ssl_ca']))
      {
          $this->nm_arr_db_extra_args['mysql_ssl_ca'] = $_SESSION['scriptcase']['glo_mysql_ssl_ca']; 
      }
      if (isset($_SESSION['scriptcase']['glo_mysql_ssl_cipher']))
      {
          $this->nm_arr_db_extra_args['mysql_ssl_cipher'] = $_SESSION['scriptcase']['glo_mysql_ssl_cipher']; 
      }
      if (isset($_SESSION['scriptcase']['oracle_type']))
      {
          $this->nm_arr_db_extra_args['oracle_type'] = $_SESSION['scriptcase']['oracle_type']; 
      }
      if (isset($_SESSION['scriptcase']['mssql_encrypt']))
      {
          $this->nm_arr_db_extra_args['mssql_encrypt'] = $_SESSION['scriptcase']['mssql_encrypt']; 
      }
      if (isset($_SESSION['scriptcase']['mssql_trustservercertificate']))
      {
          $this->nm_arr_db_extra_args['mssql_trustservercertificate'] = $_SESSION['scriptcase']['mssql_trustservercertificate']; 
      }
      if (isset($_SESSION['scriptcase']['mssql_truststore']))
      {
          $this->nm_arr_db_extra_args['mssql_truststore'] = $_SESSION['scriptcase']['mssql_truststore']; 
      }
      if (isset($_SESSION['scriptcase']['mssql_truststorepassword']))
      {
          $this->nm_arr_db_extra_args['mssql_truststorepassword'] = $_SESSION['scriptcase']['mssql_truststorepassword']; 
      }
      if (isset($_SESSION['scriptcase']['mssql_hostnameincertificate']))
      {
          $this->nm_arr_db_extra_args['mssql_hostnameincertificate'] = $_SESSION['scriptcase']['mssql_hostnameincertificate']; 
      }
      $this->date_delim  = "'";
      $this->date_delim1 = "'";
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_access))
      {
          $this->date_delim  = "#";
          $this->date_delim1 = "#";
      }
      if (isset($_SESSION['scriptcase']['glo_decimal_db']) && !empty($_SESSION['scriptcase']['glo_decimal_db']))
      {
         $_SESSION['sc_session'][$this->sc_page]['app_Login']['decimal_db'] = $_SESSION['scriptcase']['glo_decimal_db']; 
      }
      if (isset($_SESSION['scriptcase']['glo_date_separator']) && !empty($_SESSION['scriptcase']['glo_date_separator']))
      {
          $SC_temp = trim($_SESSION['scriptcase']['glo_date_separator']);
          if (strlen($SC_temp) == 2)
          {
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date']  = substr($SC_temp, 0, 1); 
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date1'] = substr($SC_temp, 1, 1); 
          }
          else
          {
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date']  = $SC_temp; 
              $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date1'] = $SC_temp; 
          }
          $this->date_delim  = $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date'];
          $this->date_delim1 = $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date1'];
      }
      if (empty($this->nm_tabela))
      {
          $this->nm_tabela = ""; 
      }
// 
      if (!empty($this->nm_falta_var) || !empty($this->nm_falta_var_db) || $nm_crit_perfil)
      {
          $str_message = "<html>

<head>
    <title>{var_str_title}</title>
    <style>
        body {
            margin: 0px;
            padding: 0px;
            overflow-x: hidden;
            min-width: 320px;
            background: #FFFFFF;
            font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
            font-size: 14px;
            line-height: 1.4285em;
            color: rgba(0, 0, 0, 0.87);
            font-smoothing: antialiased;
        }

        html,
        body {
            height: 100%;
        }

        body {
            margin: 0;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        user agent stylesheet body {
            display: block;
            margin: 8px;
        }

        html {
            font-size: 14px;
        }

        html {
            line-height: 1.15;
            -ms-text-size-adjust: 100%;
            -webkit-text-size-adjust: 100%;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        ::selection {
            background-color: #CCE2FF;
            color: rgba(0, 0, 0, 0.87);
        }

        .ui.container {
            width: 933px;
            min-width: 992px;
            max-width: 1199px;
            margin-left: auto !important;
            margin-right: auto !important;
        }

        .ui.container {
            display: block;
            max-width: 100% !important;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        .ui.message:last-child {
            margin-bottom: 0em;
        }

        .ui.message:first-child {
            margin-top: 0em;
        }

        .ui.message {
            font-size: 1em;
        }

        .ui.message {
            position: relative;
            min-height: 1em;
            margin: 1em 0em;
            background: #F8F8F9;
            padding: 1em 1.5em;
            line-height: 1.4285em;
            color: rgba(0, 0, 0, 0.87);
            transition: opacity 0.1s ease, color 0.1s ease, background 0.1s ease, box-shadow 0.1s ease;
            border-radius: 0.28571429rem;
            box-shadow: 0px 0px 0px 1px rgba(34, 36, 38, 0.22) inset, 0px 0px 0px 0px rgba(0, 0, 0, 0);
        }

        article,
        aside,
        footer,
        header,
        nav,
        section {
            display: block;
        }

        *,
        *:before,
        *:after {
            box-sizing: inherit;
        }

        .ui.message> :last-child {
            margin-bottom: 0em;
        }

        .ui.message> :first-child {
            margin-top: 0em;
        }

        .ui.message .header+p {
            margin-top: 0.25em;
        }

        .ui.message p {
            opacity: 0.85;
            margin: 0.75em 0em;
        }

        p {
            margin: 0em 0em 1em;
            line-height: 1.4285em;
        }

        .ui.message .header:not(.ui) {
            font-size: 1.14285714em;
        }

        .ui.message .header {
            display: block;
            font-family: 'Lato', 'Helvetica Neue', Arial, Helvetica, sans-serif;
            font-weight: bold;
            margin: -0.14285714em 0em 1.2rem 0em;
        }

        .ui.button {
            cursor: pointer;
            display: inline-block;
            min-height: 1em;
            outline: 0;
            border: none;
            vertical-align: baseline;
            background: #e0e1e2 none;
            color: rgba(0, 0, 0, .6);
            font-family: Lato, 'Helvetica Neue', Arial, Helvetica, sans-serif;
            margin: 0 .25em 0 0;
            padding: .78571429em 1.5em .78571429em;
            text-transform: none;
            text-shadow: none;
            font-weight: 700;
            line-height: 1em;
            font-style: normal;
            text-align: center;
            text-decoration: none;
            border-radius: .28571429rem;
            box-shadow: 0 0 0 1px transparent inset, 0 0 0 0 rgba(34, 36, 38, .15) inset;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            transition: opacity .1s ease, background-color .1s ease, color .1s ease, box-shadow .1s ease, background .1s ease;
            will-change: '';
            -webkit-tap-highlight-color: transparent;
        }
        
        .ui.button,
        .ui.buttons .button,
        .ui.buttons .or {
            font-size: 1rem;
            flex-flow: row nowrap;
            justify-content: center;
            align-items: center;
            column-gap: .5rem;
            display: flex;
        }
        
        .ui.primary.button,
        .ui.primary.buttons .button {
            background-color: #2185d0;
            color: #fff;
            text-shadow: none;
            background-image: none;
        }
        
        .ui.primary.button {
            box-shadow: 0 0 0 0 rgba(34, 36, 38, .15) inset;
        }

        [type=reset], [type=submit], button, html [type=button] {
            -webkit-appearance: button;
        }

        .icon{
            position: relative;
            width: 1.2rem;
            height: 1.2rem;
            display: block;
            color: inherit;
            background-repeat: no-repeat;
        }

        .icon.database{
            background-image: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 448 512\" fill=\"%23FFFFFF\"><path d=\"M448 80v48c0 44.2-100.3 80-224 80S0 172.2 0 128V80C0 35.8 100.3 0 224 0S448 35.8 448 80zM393.2 214.7c20.8-7.4 39.9-16.9 54.8-28.6V288c0 44.2-100.3 80-224 80S0 332.2 0 288V186.1c14.9 11.8 34 21.2 54.8 28.6C99.7 230.7 159.5 240 224 240s124.3-9.3 169.2-25.3zM0 346.1c14.9 11.8 34 21.2 54.8 28.6C99.7 390.7 159.5 400 224 400s124.3-9.3 169.2-25.3c20.8-7.4 39.9-16.9 54.8-28.6V432c0 44.2-100.3 80-224 80S0 476.2 0 432V346.1z\"/></svg>');
        }
    </style>
</head>

<body>
    <div class='ui container' style='padding-top:2rem'>
        <section class='ui message'>
            <div class='content'>
                <div class='header'>
                    <h1 class='ui header'>{var_str_title}</h1>
                </div>
                <p>{var_str_message}</p>
                <p>{var_str_message_conn}</p>
                {v_str_btn_inside}
            </div>
        </section>
    </div>";
          $str_message_end = "</body>
</html>";
          $str_message = str_replace('{var_str_title}', $this->Nm_lang['lang_errm_dbcn_create'], $str_message);
          if (empty($this->nm_falta_var_db))
          {
              if (!empty($this->nm_falta_var))
              {
                  $str_message = str_replace('{var_str_message}', $this->Nm_lang['lang_errm_glob'] . $this->nm_falta_var, $str_message);
              }
              if ($nm_crit_perfil)
              {
                  $str_message = str_replace('{var_str_message}', $this->Nm_lang['lang_errm_dbcn_nfnd'] . ' ' . $perfil_trab, $str_message);
                  $str_message = str_replace('{v_str_btn_inside}', "<button class='ui button primary' style='font-size: 16px!important;'><a href='" . $this->path_prod . "' style='color: white;text-decoration:none'><i class='icon database' style='float: left;padding-right: .5rem;'></i>". $this->Nm_lang['lang_errm_dbcn_create'] ."</a></button>", $str_message);
              }
          }
          else
          {
              $str_message = str_replace('{var_str_message}', $this->Nm_lang['lang_errm_dbcn_data'], $str_message);
          }
          $str_message = str_replace('{v_str_btn_inside}', '', $str_message);
          echo $str_message;
          if (!$_SESSION['sc_session'][$this->sc_page]['app_Login']['iframe_menu'] && (!isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['sc_outra_jan']) || $_SESSION['sc_session'][$this->sc_page]['app_Login']['sc_outra_jan'] != 'app_Login')) 
          { 
              if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno'])) 
              { 
?>
                  <input type="button" id="sai" onClick="window.location='<?php echo $_SESSION['scriptcase']['nm_sc_retorno'] ?>'; return false" class="scButton_default" value="<?php echo $this->Nm_lang['lang_btns_back'] ?>" title="<?php echo $this->Nm_lang['lang_btns_back_hint'] ?>" style="<?php echo $sCondStyle; ?>vertical-align: middle;display: ''">

<?php
              } 
              elseif(!empty($nm_url_saida)) 
              { 
?>
                  <input type="button" id="sai" onClick="window.location='<?php echo $nm_url_saida ?>'; return false" class="scButton_default" value="<?php echo $this->Nm_lang['lang_btns_exit'] ?>" title="<?php echo $this->Nm_lang['lang_btns_exit_hint'] ?>" style="<?php echo $sCondStyle; ?>vertical-align: middle;display: ''">

<?php
              } 
          } 
          echo $str_message_end;
          exit ;
      }

      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_db2) && $this->force_db_utf8) {
          putenv('DB2CODEPAGE=1208');
      }

      if (isset($_SESSION['scriptcase']['glo_db_master_usr']) && !empty($_SESSION['scriptcase']['glo_db_master_usr']))
      {
          $this->nm_usuario = $_SESSION['scriptcase']['glo_db_master_usr']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db_master_pass']) && !empty($_SESSION['scriptcase']['glo_db_master_pass']))
      {
          $this->nm_senha = $_SESSION['scriptcase']['glo_db_master_pass']; 
      }
      if (isset($_SESSION['scriptcase']['glo_db_master_cript']) && !empty($_SESSION['scriptcase']['glo_db_master_cript']))
      {
          $_SESSION['scriptcase']['glo_senha_protect'] = $_SESSION['scriptcase']['glo_db_master_cript']; 
      }
  } 
// 
  function conectDB()
  {
      $glo_senha_protect = (isset($_SESSION['scriptcase']['glo_senha_protect'])) ? $_SESSION['scriptcase']['glo_senha_protect'] : "S";
      if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno']) && isset($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']) && !empty($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']))
      { 
          $this->Db = db_conect_devel($_SESSION['scriptcase']['app_Login']['glo_nm_conexao'], $this->root . $this->path_prod, 'Pandemic_Alerts', 1, $this->force_db_utf8); 
      } 
      else 
      { 
         if (!isset($this->nm_con_persistente))
         {
            $this->nm_con_persistente = 'N';
         }
         if (!isset($this->nm_con_db2))
         {
            $this->nm_con_db2 = '';
         }
         if (!isset($this->nm_database_encoding))
         {
            $this->nm_database_encoding = '';
         }
         if ($this->force_db_utf8)
         {
            $this->nm_database_encoding = 'utf8';
         }
         if (!isset($this->nm_arr_db_extra_args))
         {
            $this->nm_arr_db_extra_args = array();
         }
         $this->Db = db_conect($this->nm_tpbanco, $this->nm_servidor, $this->nm_usuario, $this->nm_senha, $this->nm_banco, $glo_senha_protect, "S", $this->nm_con_persistente, $this->nm_con_db2, $this->nm_database_encoding, $this->nm_arr_db_extra_args); 
      } 
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_ibase))
      {
          if (function_exists('ibase_timefmt'))
          {
              ibase_timefmt('%Y-%m-%d %H:%M:%S');
          } 
      } 
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_sybase))
      {
          $this->Db->fetchMode = ADODB_FETCH_BOTH;
          $this->Db->Execute("set dateformat ymd");
          $this->Db->Execute("set quoted_identifier ON");
      } 
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_db2))
      {
          $this->Db->fetchMode = ADODB_FETCH_NUM;
      } 
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_mssql))
      {
          $this->Db->Execute("set dateformat ymd");
      } 
      if (in_array(strtolower($this->nm_tpbanco), $this->nm_bases_oracle))
      {
          $this->Db->Execute("alter session set nls_date_format         = 'yyyy-mm-dd hh24:mi:ss'");
          $this->Db->Execute("alter session set nls_timestamp_format    = 'yyyy-mm-dd hh24:mi:ss'");
          $this->Db->Execute("alter session set nls_timestamp_tz_format = 'yyyy-mm-dd hh24:mi:ss'");
          $this->Db->Execute("alter session set nls_time_format         = 'hh24:mi:ss'");
          $this->Db->Execute("alter session set nls_time_tz_format      = 'hh24:mi:ss'");
          $this->Db->Execute("alter session set nls_numeric_characters  = '.,'");
          $_SESSION['sc_session'][$this->sc_page]['app_Login']['decimal_db'] = "."; 
      } 
  }

  function setConnectionHash() {
    if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno']) && isset($_SESSION['scriptcase']['app_Login']['glo_nm_conexao']) && !empty($_SESSION['scriptcase']['app_Login']['glo_nm_conexao'])) {
      list($connectionDbms, $connectionHost, $connectionUser, $connectionPassword, $connectionDatabase) = db_conect_devel($_SESSION['scriptcase']['app_Login']['glo_nm_conexao'], $this->root . $this->path_prod, 'Pandemic_Alerts', 1, $this->force_db_utf8);
    }
    else {
      $connectionDbms     = $this->nm_tpbanco;
      $connectionHost     = $this->nm_servidor;
      $connectionUser     = $this->nm_usuario;
      $connectionPassword = $this->nm_senha;
      $connectionDatabase = $this->nm_banco;
    }

    $this->connectionHash = "{$connectionDbms}_SC_" . md5("{$connectionHost}_SC_{$connectionUser}_SC_{$connectionPassword}_SC_{$connectionDatabase}");
  } // setConnectionHash
// 

   function regionalDefault($sConfReg = '')
   {
      if ('' == $sConfReg)
      {
         $sConfReg = $this->str_conf_reg;
      }

      $_SESSION['scriptcase']['reg_conf']['date_format']           = (isset($this->Nm_conf_reg[$sConfReg]['data_format']))              ?  $this->Nm_conf_reg[$sConfReg]['data_format']                  : "ddmmyyyy";
      $_SESSION['scriptcase']['reg_conf']['date_sep']              = (isset($this->Nm_conf_reg[$sConfReg]['data_sep']))                 ?  $this->Nm_conf_reg[$sConfReg]['data_sep']                     : "/";
      $_SESSION['scriptcase']['reg_conf']['date_week_ini']         = (isset($this->Nm_conf_reg[$sConfReg]['prim_dia_sema']))            ?  $this->Nm_conf_reg[$sConfReg]['prim_dia_sema']                : "SU";
      $_SESSION['scriptcase']['reg_conf']['time_format']           = (isset($this->Nm_conf_reg[$sConfReg]['hora_format']))              ?  $this->Nm_conf_reg[$sConfReg]['hora_format']                  : "hhiiss";
      $_SESSION['scriptcase']['reg_conf']['time_sep']              = (isset($this->Nm_conf_reg[$sConfReg]['hora_sep']))                 ?  $this->Nm_conf_reg[$sConfReg]['hora_sep']                     : ":";
      $_SESSION['scriptcase']['reg_conf']['time_pos_ampm']         = (isset($this->Nm_conf_reg[$sConfReg]['hora_pos_ampm']))            ?  $this->Nm_conf_reg[$sConfReg]['hora_pos_ampm']                : "right_without_space";
      $_SESSION['scriptcase']['reg_conf']['time_simb_am']          = (isset($this->Nm_conf_reg[$sConfReg]['hora_simbolo_am']))          ?  $this->Nm_conf_reg[$sConfReg]['hora_simbolo_am']              : "am";
      $_SESSION['scriptcase']['reg_conf']['time_simb_pm']          = (isset($this->Nm_conf_reg[$sConfReg]['hora_simbolo_pm']))          ?  $this->Nm_conf_reg[$sConfReg]['hora_simbolo_pm']              : "pm";
      $_SESSION['scriptcase']['reg_conf']['simb_neg']              = (isset($this->Nm_conf_reg[$sConfReg]['num_sinal_neg']))            ?  $this->Nm_conf_reg[$sConfReg]['num_sinal_neg']                : "-";
      $_SESSION['scriptcase']['reg_conf']['grup_num']              = (isset($this->Nm_conf_reg[$sConfReg]['num_sep_agr']))              ?  $this->Nm_conf_reg[$sConfReg]['num_sep_agr']                  : ".";
      $_SESSION['scriptcase']['reg_conf']['dec_num']               = (isset($this->Nm_conf_reg[$sConfReg]['num_sep_dec']))              ?  $this->Nm_conf_reg[$sConfReg]['num_sep_dec']                  : ",";
      $_SESSION['scriptcase']['reg_conf']['neg_num']               = (isset($this->Nm_conf_reg[$sConfReg]['num_format_num_neg']))       ?  $this->Nm_conf_reg[$sConfReg]['num_format_num_neg']           : 2;
      $_SESSION['scriptcase']['reg_conf']['monet_simb']            = (isset($this->Nm_conf_reg[$sConfReg]['unid_mont_simbolo']))        ?  $this->Nm_conf_reg[$sConfReg]['unid_mont_simbolo']            : "$";
      $_SESSION['scriptcase']['reg_conf']['monet_f_pos']           = (isset($this->Nm_conf_reg[$sConfReg]['unid_mont_format_num_pos'])) ?  $this->Nm_conf_reg[$sConfReg]['unid_mont_format_num_pos']     : 3;
      $_SESSION['scriptcase']['reg_conf']['monet_f_neg']           = (isset($this->Nm_conf_reg[$sConfReg]['unid_mont_format_num_neg'])) ?  $this->Nm_conf_reg[$sConfReg]['unid_mont_format_num_neg']     : 13;
      $_SESSION['scriptcase']['reg_conf']['grup_val']              = (isset($this->Nm_conf_reg[$sConfReg]['unid_mont_sep_agr']))        ?  $this->Nm_conf_reg[$sConfReg]['unid_mont_sep_agr']            : ".";
      $_SESSION['scriptcase']['reg_conf']['dec_val']               = (isset($this->Nm_conf_reg[$sConfReg]['unid_mont_sep_dec']))        ?  $this->Nm_conf_reg[$sConfReg]['unid_mont_sep_dec']            : ",";
      $_SESSION['scriptcase']['reg_conf']['num_group_digit']       = (isset($this->Nm_conf_reg[$sConfReg]['num_group_digit']))          ?  $this->Nm_conf_reg[$sConfReg]['num_group_digit']              : "1";
      $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'] = (isset($this->Nm_conf_reg[$sConfReg]['unid_mont_group_digit']))    ?  $this->Nm_conf_reg[$sConfReg]['unid_mont_group_digit']        : "1";
      $_SESSION['scriptcase']['reg_conf']['html_dir']              = (isset($this->Nm_conf_reg[$sConfReg]['ger_ltr_rtl']))              ?  " DIR='" . $this->Nm_conf_reg[$sConfReg]['ger_ltr_rtl'] . "'" : "";
      $_SESSION['scriptcase']['reg_conf']['css_dir']               = (isset($this->Nm_conf_reg[$sConfReg]['ger_ltr_rtl']))              ?  $this->Nm_conf_reg[$sConfReg]['ger_ltr_rtl'] : "LTR";
      if ('' == $_SESSION['scriptcase']['reg_conf']['num_group_digit'])
      {
          $_SESSION['scriptcase']['reg_conf']['num_group_digit'] = '1';
      }
      if ('' == $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'])
      {
          $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'] = '1';
      }
   }
   function sc_change_language($sLang)
   {
      $sRegion = "";
      $iPos = strpos($sLang, ';');
      if (false !== $iPos)
      {
          $sRegion = substr($sLang, $iPos + 1);
          $sLang   = substr($sLang, 0, $iPos);
      }
      if (@is_file($this->path_lang . $sLang . '.lang.php'))
      {
          $_SESSION['scriptcase']['str_lang'] = $sLang;
          $this->str_lang                = $sLang;
          include($this->path_lang . $sLang . '.lang.php');
          $_SESSION['scriptcase']['charset'] = "UTF-8";
          foreach ($this->Nm_lang as $ind => $dados)
          {
              if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($ind))
              {
                  $ind = sc_convert_encoding($ind, $_SESSION['scriptcase']['charset'], "UTF-8");
                  $this->Nm_lang[$ind] = $dados;
              }
              if ($_SESSION['scriptcase']['charset'] != 'UTF-8' && NM_is_utf8($dados))
              {
                  $this->Nm_lang[$ind] = sc_convert_encoding($dados, $_SESSION['scriptcase']['charset'], 'UTF-8');
              }
          }
      }
      if (!empty($sRegion))
      {
          $this->sc_change_regional($sRegion);
      }
   } // sc_change_language

   function  sc_change_regional($sRegion)
   {
      $iPos = strpos($sRegion, ';');
      if (false !== $iPos)
      {
          $sRegion = substr($sRegion, $iPos + 1);
      }
      if (isset($this->Nm_conf_reg[$sRegion]))
      {
          $_SESSION['scriptcase']['str_conf_reg'] = $sRegion;
          $this->str_conf_reg                     = $sRegion;
          include($this->path_lang . 'config_region.php');
          foreach ($this->Nm_conf_reg[$sRegion] as $ind => $dados)
          {
              if ($_SESSION['scriptcase']['charset'] != 'UTF-8' && NM_is_utf8($dados))
              {
                  $this->Nm_conf_reg[$sRegion][$ind] = sc_convert_encoding($dados, $_SESSION['scriptcase']['charset'], 'UTF-8');
              }
          }
          $this->regionalDefault();
      }
   } // sc_change_regional

   function sc_Include($path, $tp, $name)
   {
       if ((empty($tp) && empty($name)) || ($tp == "F" && !function_exists($name)) || ($tp == "C" && !class_exists($name)))
       {
           include_once($path);
       }
   } // sc_Include
   function sc_Sql_Protect($var, $tp, $conex="")
   {
       if (empty($conex) || $conex == "pandemic_alerts_connection")
       {
           $TP_banco = $_SESSION['scriptcase']['glo_tpbanco'];
       }
       else
       {
           eval ("\$TP_banco = \$this->nm_con_" . $conex . "['tpbanco'];");
       }
       if ($tp == "date")
       {
           $delim  = "'";
           $delim1 = "'";
           if (in_array(strtolower($TP_banco), $this->nm_bases_access))
           {
               $delim  = "#";
               $delim1 = "#";
           }
           if (isset($_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date']) && !empty($_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date']))
           {
               $delim  = $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date'];
               $delim1 = $_SESSION['sc_session'][$this->sc_page]['app_Login']['SC_sep_date1'];
           }
           return $delim . $var . $delim1;
       }
       else
       {
           return $var;
       }
   } // sc_Sql_Protect
function api_login()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
$_web_mobile_user = 'web.mobile';
$_web_mobile_pwd =  '@!Ghyui120BvH.';

$url = 'http://' . $_SERVER['HTTP_HOST'] . $this->path_link . "" . SC_dir_app_name('app_login_ws') . "/app_login_ws.php?script_case_init=" . $this->form_encode_input($this->sc_page) . "&nmgp_url_saida=" . $this->nm_location;

$url = 'http://localhost/mdoalerts/app_login_ws/app_login_ws.php';




$ch = curl_init($url);

$request = array(
    'user_name' => $_web_mobile_user,
	'pwd' => $_web_mobile_pwd,
	
);


$payload = json_encode(array("user" => $request));

curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_HEADER, 1);


$result = curl_exec($ch);

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($result, 0, $header_size);
$body = substr($result, $header_size);

$uuid_results = json_decode($body,true);



curl_close($ch);		

if ($uuid_results[0]['error']!="0"){

	return '';
}
else{

	$token = $uuid_results[0]['token'];
	return $token;
}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function fb_return()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_facebook_name)) {$this->sc_temp_facebook_name = (isset($_SESSION['facebook_name'])) ? $_SESSION['facebook_name'] : "";}
if (!isset($this->sc_temp_facebook_email)) {$this->sc_temp_facebook_email = (isset($_SESSION['facebook_email'])) ? $_SESSION['facebook_email'] : "";}
if (!isset($this->sc_temp_facebook_user)) {$this->sc_temp_facebook_user = (isset($_SESSION['facebook_user'])) ? $_SESSION['facebook_user'] : "";}
if (!isset($this->sc_temp_facebook_error_msg)) {$this->sc_temp_facebook_error_msg = (isset($_SESSION['facebook_error_msg'])) ? $_SESSION['facebook_error_msg'] : "";}
if (!isset($this->sc_temp_facebook_error_code)) {$this->sc_temp_facebook_error_code = (isset($_SESSION['facebook_error_code'])) ? $_SESSION['facebook_error_code'] : "";}
  
if(!empty($this->sc_temp_facebook_error_code))
{
	
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'urlencode($this->sc_temp_facebook_error_msg)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'urlencode($this->sc_temp_facebook_error_msg)';
 }
;
}
else
{
	$this->get_social("facebook", $this->sc_temp_facebook_user, $this->sc_temp_facebook_email, $this->sc_temp_facebook_name);
}
if (isset($this->sc_temp_facebook_error_code)) { $_SESSION['facebook_error_code'] = $this->sc_temp_facebook_error_code;}
if (isset($this->sc_temp_facebook_error_msg)) { $_SESSION['facebook_error_msg'] = $this->sc_temp_facebook_error_msg;}
if (isset($this->sc_temp_facebook_user)) { $_SESSION['facebook_user'] = $this->sc_temp_facebook_user;}
if (isset($this->sc_temp_facebook_email)) { $_SESSION['facebook_email'] = $this->sc_temp_facebook_email;}
if (isset($this->sc_temp_facebook_name)) { $_SESSION['facebook_name'] = $this->sc_temp_facebook_name;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_settings()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

$check_sql = "SELECT set_name, set_value  FROM public.sec_settings";

 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


if (isset($this->rs[0][0]))     
{
    foreach($this->rs as $f ){
        $_SESSION[ 'sett_'. $f[0] ] = $f[1];
    }
}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_social($resource, $user_id, $email, $name)
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_usr_email)) {$this->sc_temp_usr_email = (isset($_SESSION['usr_email'])) ? $_SESSION['usr_email'] : "";}
if (!isset($this->sc_temp_usr_name)) {$this->sc_temp_usr_name = (isset($_SESSION['usr_name'])) ? $_SESSION['usr_name'] : "";}
if (!isset($this->sc_temp_usr_login)) {$this->sc_temp_usr_login = (isset($_SESSION['usr_login'])) ? $_SESSION['usr_login'] : "";}
  
if(empty($user_id)) return;

	$sql = "SELECT 
				active, 
				\"name\",
				login
			FROM public.sec_users 
				WHERE email = ". $this->Db->qstr($email).
		" OR login = (
		SELECT
			login
		FROM
			public.sec_users_social
		WHERE
			resource = '". $resource ."'
			AND resource_id = ". $this->Db->qstr($user_id) .")";
	

	 
      $nm_select = $sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	if(count($this->rs) == 0)
	{
		
		$this->NM_gera_log_insert("User", 'login Fail',  $this->Nm_lang['lang_login_fail']  . $resource. "_".$user_id);
		
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .=  $this->Nm_lang['lang_error_login'] ;
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] =  $this->Nm_lang['lang_error_login'] ;
 }
;
	}
	else if($this->rs[0][0] == 'Y')
	{
		$usr_login		= $this->rs[0][2];
		$usr_name		= $this->rs[0][1];
		$usr_email		= $email;
		 if (isset($usr_login)) {$this->sc_temp_usr_login = $usr_login;}
;
		 if (isset($usr_name)) {$this->sc_temp_usr_name = $usr_name;}
;
		 if (isset($usr_email)) {$this->sc_temp_usr_email = $usr_email;}
;
		$this->sc_validate_success();
	}
	else
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .=  $this->Nm_lang['lang_error_not_active'] ;
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] =  $this->Nm_lang['lang_error_not_active'] ;
 }
;
		if (isset($this->Campos_Mens_erro) && !empty($this->Campos_Mens_erro))
{
 if (isset($this->sc_temp_usr_login)) { $_SESSION['usr_login'] = $this->sc_temp_usr_login;}
 if (isset($this->sc_temp_usr_name)) { $_SESSION['usr_name'] = $this->sc_temp_usr_name;}
 if (isset($this->sc_temp_usr_email)) { $_SESSION['usr_email'] = $this->sc_temp_usr_email;}
    $_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
    return;
}
}
if (isset($this->sc_temp_usr_login)) { $_SESSION['usr_login'] = $this->sc_temp_usr_login;}
if (isset($this->sc_temp_usr_name)) { $_SESSION['usr_name'] = $this->sc_temp_usr_name;}
if (isset($this->sc_temp_usr_email)) { $_SESSION['usr_email'] = $this->sc_temp_usr_email;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function go_return()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_google_name)) {$this->sc_temp_google_name = (isset($_SESSION['google_name'])) ? $_SESSION['google_name'] : "";}
if (!isset($this->sc_temp_google_email)) {$this->sc_temp_google_email = (isset($_SESSION['google_email'])) ? $_SESSION['google_email'] : "";}
if (!isset($this->sc_temp_google_user)) {$this->sc_temp_google_user = (isset($_SESSION['google_user'])) ? $_SESSION['google_user'] : "";}
if (!isset($this->sc_temp_google_error_msg)) {$this->sc_temp_google_error_msg = (isset($_SESSION['google_error_msg'])) ? $_SESSION['google_error_msg'] : "";}
if (!isset($this->sc_temp_google_error_code)) {$this->sc_temp_google_error_code = (isset($_SESSION['google_error_code'])) ? $_SESSION['google_error_code'] : "";}
  
if(!empty($this->sc_temp_google_error_code))
{
	
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'urlencode($this->sc_temp_google_error_msg)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'urlencode($this->sc_temp_google_error_msg)';
 }
;
}
else
{
	$this->get_social("google", $this->sc_temp_google_user, $this->sc_temp_google_email, $this->sc_temp_google_name);
}
if (isset($this->sc_temp_google_error_code)) { $_SESSION['google_error_code'] = $this->sc_temp_google_error_code;}
if (isset($this->sc_temp_google_error_msg)) { $_SESSION['google_error_msg'] = $this->sc_temp_google_error_msg;}
if (isset($this->sc_temp_google_user)) { $_SESSION['google_user'] = $this->sc_temp_google_user;}
if (isset($this->sc_temp_google_email)) { $_SESSION['google_email'] = $this->sc_temp_google_email;}
if (isset($this->sc_temp_google_name)) { $_SESSION['google_name'] = $this->sc_temp_google_name;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function has_priv($param)
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
return ($param == 'Y' ? 'on' : 'off');

$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function link_user($resource, $usr_id, $email, $name)
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_usr_email)) {$this->sc_temp_usr_email = (isset($_SESSION['usr_email'])) ? $_SESSION['usr_email'] : "";}
if (!isset($this->sc_temp_usr_priv_admin)) {$this->sc_temp_usr_priv_admin = (isset($_SESSION['usr_priv_admin'])) ? $_SESSION['usr_priv_admin'] : "";}
if (!isset($this->sc_temp_usr_login)) {$this->sc_temp_usr_login = (isset($_SESSION['usr_login'])) ? $_SESSION['usr_login'] : "";}
  
	

	$sql = "INSERT INTO
				public.sec_users( login, \"name\", pswd, email, active )
			VALUES 
				(". $this->Db->qstr($usr_id). ", ".
					$this->Db->qstr($name) . ", ".
					$this->Db->qstr(hash("sha512",date("YmdHis"))) . ", ".
					$this->Db->qstr($email) . ", 'Y')";
			
	
	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
	
	$sql = "INSERT INTO
				public.sec_users_social( public.sec_users_social.login, public.sec_users_social.resource, public.sec_users_social.resource_id )
			VALUES 
				(". $this->Db->qstr($usr_id). ", ".
					$this->Db->qstr($resource) . ", ".
					$this->Db->qstr($usr_id) . ")";
			
	
	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
									 
	
	$sql = "INSERT INTO
				public.sec_users_groups( login, group_id )
			VALUES 
				(". $this->Db->qstr($usr_id). ", ".
					$this->Db->qstr($group_default) . ")";
			
	
	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      

	
	$usr_login			= $usr_id;
	$usr_priv_admin 	= FALSE;
	$usr_email			= $email;
	 if (isset($usr_login)) {$this->sc_temp_usr_login = $usr_login;}
;
	 if (isset($usr_priv_admin)) {$this->sc_temp_usr_priv_admin = $usr_priv_admin;}
;
	 if (isset($usr_email)) {$this->sc_temp_usr_email = $usr_email;}
;
	$this->sc_validate_success();
if (isset($this->sc_temp_usr_login)) { $_SESSION['usr_login'] = $this->sc_temp_usr_login;}
if (isset($this->sc_temp_usr_priv_admin)) { $_SESSION['usr_priv_admin'] = $this->sc_temp_usr_priv_admin;}
if (isset($this->sc_temp_usr_email)) { $_SESSION['usr_email'] = $this->sc_temp_usr_email;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function remember_me_init()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_usr_email)) {$this->sc_temp_usr_email = (isset($_SESSION['usr_email'])) ? $_SESSION['usr_email'] : "";}
if (!isset($this->sc_temp_usr_name)) {$this->sc_temp_usr_name = (isset($_SESSION['usr_name'])) ? $_SESSION['usr_name'] : "";}
if (!isset($this->sc_temp_usr_priv_admin)) {$this->sc_temp_usr_priv_admin = (isset($_SESSION['usr_priv_admin'])) ? $_SESSION['usr_priv_admin'] : "";}
if (!isset($this->sc_temp_usr_login)) {$this->sc_temp_usr_login = (isset($_SESSION['usr_login'])) ? $_SESSION['usr_login'] : "";}
  
if(isset($_COOKIE['usr_data']) && !empty($_COOKIE['usr_data'])){

    $usr_data = unserialize(decode_string($_COOKIE['usr_data']));
    
    if(substr($usr_data['code'], 0, 7) == 'cookie_'){
        


        $sql = "SELECT 
                    priv_admin,
                    active, 
                    \"name\", 
                    email 
                FROM public.sec_users 
                WHERE login = ". $this->Db->qstr($usr_data['login']) ."
                AND activation_code = ".$this->Db->qstr($usr_data['code']);
         
      $nm_select = $sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


        if(count($this->rs) != 0 && $this->rs[0][1] == 'Y')
        {
            $this->sc_temp_usr_login		= $usr_data['login'];
            $this->sc_temp_usr_priv_admin 	= ($this->rs[0][0] == 'Y') ? TRUE : FALSE;
            $this->sc_temp_usr_name		= $this->rs[0][2];
            $this->sc_temp_usr_email		= $this->rs[0][3];
            
            $this->sc_validate_success();
        }
    }
}
if (isset($this->sc_temp_usr_login)) { $_SESSION['usr_login'] = $this->sc_temp_usr_login;}
if (isset($this->sc_temp_usr_priv_admin)) { $_SESSION['usr_priv_admin'] = $this->sc_temp_usr_priv_admin;}
if (isset($this->sc_temp_usr_name)) { $_SESSION['usr_name'] = $this->sc_temp_usr_name;}
if (isset($this->sc_temp_usr_email)) { $_SESSION['usr_email'] = $this->sc_temp_usr_email;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function remember_me_validate()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_sett_cookie_expiration_time)) {$this->sc_temp_sett_cookie_expiration_time = (isset($_SESSION['sett_cookie_expiration_time'])) ? $_SESSION['sett_cookie_expiration_time'] : "";}
  
if($this->remember_me  == 1){

    $chars  = 'abcdefghijklmnopqrstuvxywz';
    $chars .= 'ABCDEFGHIJKLMNOPQRSTUVXYWZ';
    $chars .= '0123456789!@$*.,;:';
    $max = strlen($chars)-1;
    $code = "cookie_";
    for($i=0; $i < 25; $i++)
    {
        $code .= $chars[mt_rand(0, $max)];
    }
    
    $slogin = $this->Db->qstr($this->login );

    
     $nm_select ="UPDATE public.sec_users SET activation_code = ". $this->Db->qstr($code) . " WHERE login = ". $slogin; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      

    $usr_data = array(
        'login' => $this->login ,
        'code' => $code,
    );
    $remember_me_expiry_cookie = $this->sc_temp_sett_cookie_expiration_time;
    setcookie("usr_data", encode_string(serialize($usr_data)),time()+60*60*24* $remember_me_expiry_cookie, '/');
}
if (isset($this->sc_temp_sett_cookie_expiration_time)) { $_SESSION['sett_cookie_expiration_time'] = $this->sc_temp_sett_cookie_expiration_time;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function sc_validate_success()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_sett_session_expire)) {$this->sc_temp_sett_session_expire = (isset($_SESSION['sett_session_expire'])) ? $_SESSION['sett_session_expire'] : "";}
if (!isset($this->sc_temp_usr_login)) {$this->sc_temp_usr_login = (isset($_SESSION['usr_login'])) ? $_SESSION['usr_login'] : "";}
  
$sql = "SELECT 
		app_name,
		priv_access,
		priv_insert,
		priv_delete,
		priv_update,
		priv_export,
		priv_print
	      FROM public.sec_groups_apps
	      WHERE group_id IN
	          (SELECT
		       group_id
		   FROM
		       public.sec_users_groups 
		   WHERE
		       login = '". $this->sc_temp_usr_login ."')";
		
	
 
      $nm_select = $sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


$arr_default = array(
					'access' => 'off',
					'insert' => 'off',
					'delete' => 'off',
					'update' => 'off',
					'export' => 'btn_display_off',
					'print'  => 'btn_display_off',
					);
if ($this->rs !== false)
{
	$arr_perm = array();
	while (!$this->rs->EOF)
	{
		$app = $this->rs->fields[0];
		
		if(!isset($arr_perm[$app]))
		{
		   $arr_perm[$app] = $arr_default;
		}
		if( $this->rs->fields[1] == 'Y')
		{
			$arr_perm[$app][ 'access' ] = 'on';
		}
		if($this->rs->fields[2] == 'Y')
		{
			$arr_perm[$app][ 'insert' ] = 'on';
		}
		if($this->rs->fields[3] == 'Y')
		{
			$arr_perm[$app][ 'delete' ] = 'on';
		}
		if($this->rs->fields[4] == 'Y')
		{
			$arr_perm[$app][ 'update' ] = 'on';
		}
		if($this->rs->fields[5] == 'Y')
		{
			$arr_perm[$app]['export'] =  'btn_display_on';
		}
		if($this->rs->fields[6] == 'Y')
		{
			$arr_perm[$app]['print'] =  'btn_display_on';
		}


		$this->rs->MoveNext();	
	}
	$this->rs->Close();
		   
	foreach($arr_perm as $app => $perm)
	{
		$_SESSION['scriptcase']['sc_apl_seg'][$app] = $perm['access'];;
		
		$_SESSION['scriptcase']['sc_apl_conf'][$app]['insert'] = $perm['insert'];
		$_SESSION['scriptcase']['sc_apl_conf'][$app]['delete'] = $perm['delete'];
		$_SESSION['scriptcase']['sc_apl_conf'][$app]['update'] = $perm['update'];
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['xls'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['xls'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['xls'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['xls'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['xls'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'xls';
}
;
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['word'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['word'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['word'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['word'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['word'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'word';
}
;
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['pdf'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['pdf'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['pdf'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['pdf'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['pdf'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'pdf';
}
;
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['xml'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['xml'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['xml'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['xml'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['xml'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'xml';
}
;
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['csv'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['csv'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['csv'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['csv'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['csv'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'csv';
}
;
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['rtf'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['rtf'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['rtf'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['rtf'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['rtf'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'rtf';
}
;
		if ($perm['export'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['json'] = 'on';
}
elseif ($perm['export'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['json'] = 'off';
}
elseif ($perm['export'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['json'] = 'on';
}
elseif ($perm['export'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['json'] = 'off';
}
elseif ($perm['export'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']]['json'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['export']] = 'json';
}
;
		if ($perm['print'] == 'btn_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['print'] = 'on';
}
elseif ($perm['print'] == 'btn_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['btn_display']['print'] = 'off';
}
elseif ($perm['print'] == 'field_display_on') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['print'] = 'on';
}
elseif ($perm['print'] == 'field_display_off') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app]['field_display']['print'] = 'off';
}
elseif ($perm['print'] == 'field_readonly') {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['print']]['print'] = 'on';
}
else {
    $_SESSION['scriptcase']['sc_apl_conf'][$app][$perm['print']] = 'print';
}
;

	}
		
		
	
		$this->NM_gera_log_insert("User", 'login',  $this->Nm_lang['lang_login_ok'] );
		
        if($this->sc_temp_sett_session_expire != 'N'){
            if (is_file($_SESSION['scriptcase']['dir_temp'] . "/sc_apl_default_Pandemic_Alerts.txt")) {
    unlink($_SESSION['scriptcase']['dir_temp'] . "/sc_apl_default_Pandemic_Alerts.txt");
}
if (is_file("../_lib/_app_data/app_Login_ini.php")) {
    $SC_arq_def = fopen($_SESSION['scriptcase']['dir_temp'] . "/sc_apl_default_Pandemic_Alerts.txt", "w");
    fwrite ($SC_arq_def, 'app_Login, $this->sc_temp_sett_session_expire');
    fclose ($SC_arq_def);
    setcookie('sc_apl_default_Pandemic_Alerts','app_Login, $this->sc_temp_sett_session_expire','0','/');
}
;
        }
    if (isset($this->sc_temp_usr_login)) { $_SESSION['usr_login'] = $this->sc_temp_usr_login;}
 if (isset($this->sc_temp_sett_session_expire)) { $_SESSION['sett_session_expire'] = $this->sc_temp_sett_session_expire;}
 if (!isset($this->Campos_Mens_erro) || empty($this->Campos_Mens_erro))
 {
$this->nmgp_redireciona_form($this->path_link . "" . SC_dir_app_name('app_menu') . "/app_menu.php", $this->nm_location, "", "_self", "ret_self", 440, 630);
 };	
	
}
if (isset($this->sc_temp_usr_login)) { $_SESSION['usr_login'] = $this->sc_temp_usr_login;}
if (isset($this->sc_temp_sett_session_expire)) { $_SESSION['sett_session_expire'] = $this->sc_temp_sett_session_expire;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function tw_return()
{
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
if (!isset($this->sc_temp_twitter_name)) {$this->sc_temp_twitter_name = (isset($_SESSION['twitter_name'])) ? $_SESSION['twitter_name'] : "";}
if (!isset($this->sc_temp_twitter_email)) {$this->sc_temp_twitter_email = (isset($_SESSION['twitter_email'])) ? $_SESSION['twitter_email'] : "";}
if (!isset($this->sc_temp_twitter_user)) {$this->sc_temp_twitter_user = (isset($_SESSION['twitter_user'])) ? $_SESSION['twitter_user'] : "";}
  
$this->get_social("twitter", $this->sc_temp_twitter_user, $this->sc_temp_twitter_email,$this->sc_temp_twitter_name);


if (isset($this->sc_temp_twitter_user)) { $_SESSION['twitter_user'] = $this->sc_temp_twitter_user;}
if (isset($this->sc_temp_twitter_email)) { $_SESSION['twitter_email'] = $this->sc_temp_twitter_email;}
if (isset($this->sc_temp_twitter_name)) { $_SESSION['twitter_name'] = $this->sc_temp_twitter_name;}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function push_api_log($_source, $_data){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
		$d = date('Y-m-d H:i:s');
	
		$_data = pg_escape_string($_data);
			
			
	
		$insert_table  = 'public.api_log';      
		$insert_fields = array(   
					'source' => "'".$_source."'",
					'input' => "'".$_data."'",
					'dateheure' => "'".$d."'",
					
				 );

		$insert_sql = 'INSERT INTO ' . $insert_table
					. ' ('   . implode(', ', array_keys($insert_fields))   . ')'
					. ' VALUES ('    . implode(', ', array_values($insert_fields)) . ')';

		
     $nm_select = $insert_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_setting($var_name){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT set_value"
		   . " FROM sec_settings"
		   . " WHERE set_name = '" . $var_name . "'";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$val = '';

		if (isset($this->rs[0][0]))     
		{
		   $val = $this->rs[0][0];

		}

		return $val;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_params($profil){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
		
		$check_sql = 'SELECT geoserver_url, protocol, geoserver_user, geoserver_pwd, timeout_value, max_file_size, maintenance_mode, maintenance_message, admin_contact, geoserver_url_local, url_qr_code'
		   . ' FROM public.app_params'
		   . ' WHERE "profil" = ' ."'" . $profil. "'";
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$_params = array();

		if (isset($this->rs[0][0]))     
		{
			$_params['geoserver_url'] = $this->rs[0][0];
			$_params['protocol'] = $this->rs[0][1];
			$_params['geoserver_user'] = $this->rs[0][2];
			$_params['geoserver_pwd'] = $this->rs[0][3];
			$_params['timeout_value'] = $this->rs[0][4];
			$_params['max_file_size'] = $this->rs[0][5];
			$_params['maintenance_mode'] = $this->rs[0][6];
			$_params['maintenance_message'] = $this->rs[0][7];
			$_params['admin_contact'] = $this->rs[0][8];
			$_params['geoserver_url_local'] = $this->rs[0][9];
			$_params['url_qr_code'] = $this->rs[0][10];
	
		}

		return $_params;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_uuid_url($profil){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
		
		$check_sql = 'SELECT url_uuid_ws'
		   . ' FROM public.app_params'
		   . ' WHERE "profil" = ' ."'" . $profil. "'";
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$_url = '';

		if (isset($this->rs[0][0]))     
		{
			$_url = $this->rs[0][0];

		}

		return $_url;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_device_mgm_url($profil){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
		
		$check_sql = 'SELECT url_device_mgm_ws'
		   . ' FROM public.app_params'
		   . ' WHERE "profil" = ' ."'" . $profil. "'";
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$_url = '';

		if (isset($this->rs[0][0]))     
		{
			$_url = $this->rs[0][0];

		}

		return $_url;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_id($domain_code, $facility_code, $user_name){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
			
			$url = $this->get_uuid_url('A');
		
			$ch = curl_init($url);


			$request_example = array(
				'name_space' => $domain_code,
				'facility_code' => $facility_code,
				'user_name' => $user_name,

			);

			

			$payload = json_encode(array("domain" => $request_example));

			curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

			curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

		
			$result = curl_exec($ch);

			$uuid_results = json_decode($result, true);
	
	
			
			curl_close($ch);
			
			
			
			return $uuid_results;
	
	
	
	
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_nmc($code_nmc){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT nomenclature_item"
		   . " FROM ref_nomenclature_items"
		   . " WHERE nomenclature_item_code = '" . $code_nmc . "'";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$nmc = '';

		if (isset($this->rs[0][0]))     
		{
			$nmc = $this->rs[0][0];

		}


		return $nmc;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_wilaya_of_facility($code_facility){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT wilaya_structure"
		   . " FROM structures_sante"
		   . " WHERE code_structure = '" . $code_facility . "'";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$w = '';

		if (isset($this->rs[0][0]))     
		{
			$w = $this->rs[0][0];

		}


		return $w;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_services_of_facility($facility){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT code_service_sisdz, nom_service"
		   . " FROM structures_services"
		   . " WHERE code_etablissement_sisdz = '" . $facility . "' order by nom_service";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rsnmc = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rsnmc = false;
          $this->rsnmc_erro = $this->Db->ErrorMsg();
      } 


		$nmc = array();

				
		if (false == $this->rsnmc )     
		{
			$nmc[] = 'Error while accessing database (Services sante)';
		}
		else
		{
			$i=1;
		   while(!$this->rsnmc->EOF)
			{
				$nmc[$this->rsnmc->fields[0]] = $this->rsnmc->fields[1];
				$this->rsnmc->MoveNext();
			   
			}
			$this->rsnmc->Close();
		}


		return $nmc;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_nmc_abrege($code_nmc){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT nomenclature_item_abrege"
		   . " FROM ref_nomenclature_items"
		   . " WHERE nomenclature_item_code = '" . $code_nmc . "'";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$nmc = '';

		if (isset($this->rs[0][0]))     
		{
			$nmc = $this->rs[0][0];

		}


		return $nmc;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_items_of_nmc($code_nmc){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT nomenclature_item_code, nomenclature_item"
		   . " FROM ref_nomenclature_items"
		   . " WHERE nomenclature_fk = '" . $code_nmc . "' order by nomenclature_item_order";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rsnmc = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rsnmc = false;
          $this->rsnmc_erro = $this->Db->ErrorMsg();
      } 


		$nmc = array();

				
		if (false == $this->rsnmc )     
		{
			$nmc[] = 'Error while accessing database (ref_nomenclatures)';
		}
		else
		{
			$i=1;
		   while(!$this->rsnmc->EOF)
			{
				$nmc[$this->rsnmc->fields[0]] = $this->rsnmc->fields[1];
				$this->rsnmc->MoveNext();
			   
			}
			$this->rsnmc->Close();
		}


		return $nmc;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_nmc_secured($code_nmc){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


		$check_table = 'ref_nomenclatures';    
		$check_where = "nomenclature_code = '".$code_nmc."' and nc_secured='O'"; 

		$check_sql = 'SELECT *'
		   . ' FROM '  . $check_table
		   . ' WHERE ' . $check_where;
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


		if (false == $this->dataset )
		{
			return false;
		}
		elseif ($this->dataset->EOF)
		{
			return false;
		}
		else
		{
			return true;
		}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_nmc_exist($code_nmc){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


		$check_table = 'ref_nomenclatures';    
		$check_where = "nomenclature_code = '".$code_nmc."'"; 

		$check_sql = 'SELECT *'
		   . ' FROM '  . $check_table
		   . ' WHERE ' . $check_where;
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


		if (false == $this->dataset )
		{
			return false;
		}
		elseif ($this->dataset->EOF)
		{
			return false;
		}
		else
		{
			return true;
		}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_item_nmc_exists($code_item, $code_nmc=''){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


		$check_table = 'ref_nomenclature_items';    
		
		if (empty($code_nmc)){
			$check_where = "nomenclature_item_code = '".$code_item."'"; 
		}
		else{
			
			$check_where = "nomenclature_item_code = '".$code_item."' and nomenclature_fk ='".$code_nmc."'"; 
		}

		$check_sql = 'SELECT *'
		   . ' FROM '  . $check_table
		   . ' WHERE ' . $check_where;
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


		if (false == $this->dataset )
		{
			return false;
		}
		elseif ($this->dataset->EOF)
		{
			return false;
		}
		else
		{
			return true;
		}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_communes_of_wilaya($wil){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
		
		$check_sql = "SELECT code_commune, nom_commune"
			   . " FROM commune"
			   . " WHERE code_wilaya='".$wil."'"
			   . " ORDER BY code_commune";
			 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rscom = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rscom = false;
          $this->rscom_erro = $this->Db->ErrorMsg();
      } 


			$communes = array();


			if (false == $this->rscom )     
			{
				$communes[] = 'Error while accessing database (commune)';
			}
			else
			{
				
				
				$i=1;
			   while(!$this->rscom->EOF)
				{
					$communes[$this->rscom->fields[0]] = $this->rscom->fields[1];
				    
					$this->rscom->MoveNext();

				}
				$this->rscom->Close();
			}


			return $communes;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_all_wilayas(){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
		
		$check_sql = "SELECT code_wilaya, nom_wilaya"
			   . " FROM wilaya"
			   . " ORDER BY code_wilaya";
			 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rswil = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rswil = false;
          $this->rswil_erro = $this->Db->ErrorMsg();
      } 


			$wilayas = array();


			if (false == $this->rswil )     
			{
				$wilayas[] = 'Error while accessing database (ref_nomenclatures)';
			}
			else
			{
				$i=1;
			   while(!$this->rswil->EOF)
				{
					$wilayas[$this->rswil->fields[0]]['name'] = $this->rswil->fields[1];
				    $wilayas[$this->rswil->fields[0]]['communes'] = $this->get_communes_of_wilaya($this->rswil->fields[0]);
					$this->rswil->MoveNext();

				}
				$this->rswil->Close();
			}


			return $wilayas;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_wilaya_exists($_wilaya){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
		
		$check_table = 'wilaya';    
		$check_where = "code_wilaya = '".$_wilaya."'"; 

		$check_sql = 'SELECT *'
		   . ' FROM '  . $check_table
		   . ' WHERE ' . $check_where;
		
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


		if (false == $this->dataset )
		{
			return false;
		}
		elseif ($this->dataset->EOF)
		{
			return false;
		}
		else
		{
			return true;
		}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_facilities_by_wilaya($_wilaya){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
		
		$check_sql = "SELECT code_structure, nom_structure, wilaya_structure, type_structure, longitude, latitude"
			   . " FROM structures_sante"
			   . " WHERE wilaya_structure = '" .$_wilaya. "'"
			   . " ORDER BY wilaya_structure, type_structure";
			 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rswil = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rswil = false;
          $this->rswil_erro = $this->Db->ErrorMsg();
      } 


			$structures = array();


			if (false == $this->rswil )     
			{
				$structures[] = 'Error while accessing database (structures_sante)';
			}
			else
			{
				$i=1;
			   while(!$this->rswil->EOF)
				{
					$structures[$this->rswil->fields[0]]['name'] = $this->rswil->fields[1] . " - " . $this->get_nom_wilaya($this->rswil->fields[2]);
				    $structures[$this->rswil->fields[0]]['wilaya'] = $this->rswil->fields[2];
				    $structures[$this->rswil->fields[0]]['type'] = $this->rswil->fields[3];
				    $structures[$this->rswil->fields[0]]['lng'] = $this->rswil->fields[4];
				    $structures[$this->rswil->fields[0]]['lat'] = $this->rswil->fields[5];
					$this->rswil->MoveNext();

				}
				$this->rswil->Close();
			}


			return $structures;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_all_facilities($_details=false){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
		
			$d_sql = '';
			if ($_details){
				$d_sql = ', type_structure, longitude, latitude';
				
			}
				
			
		
			$check_sql = "SELECT code_structure, nom_structure, wilaya_structure" . $d_sql
			   . " FROM structures_sante"
			   . " ORDER BY wilaya_structure, type_structure";
			 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rswil = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rswil = false;
          $this->rswil_erro = $this->Db->ErrorMsg();
      } 


			$structures = array();


			if (false == $this->rswil )     
			{
				$structures[] = 'Error while accessing database (structures_sante)';
			}
			else
			{
				$i=1;
			   while(!$this->rswil->EOF)
				{
					
				    if ($d_sql){
						$structures[$this->rswil->fields[0]]['name'] = $this->rswil->fields[1] . " - " . $this->get_nom_wilaya($this->rswil->fields[2]);
						$structures[$this->rswil->fields[0]]['wilaya'] = $this->rswil->fields[2];
						$structures[$this->rswil->fields[0]]['type'] = $this->rswil->fields[3];
						$structures[$this->rswil->fields[0]]['lng'] = $this->rswil->fields[4];
						$structures[$this->rswil->fields[0]]['lat'] = $this->rswil->fields[5];
					}
				    else{
						$structures[$this->rswil->fields[0]] = $this->rswil->fields[1] . " - " . $this->get_nom_wilaya($this->rswil->fields[2]);
						
					}
					$this->rswil->MoveNext();

				}
				$this->rswil->Close();
			}


			return $structures;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_sended_icon_url($var_status){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
        
               
        switch ($var_status){
            
            case 'TERMINATED':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'img_messages/sended-1.png');
                $_text = $this->get_nmc('TERMINATED');
                
                break;    
			
			
				
            case 'SCHEDULED':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'img_messages/waiting-1.png');
                $_text = $this->get_nmc('SCHEDULED');
                
                break;
				
			 case 'INPROGRESS':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'img_messages/ongoing.png');
                $_text = $this->get_nmc('INPROGRESS');
                
                break;
				
			case 'STOPED':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'img_messages/not_sended.png');
                $_text = $this->get_nmc('STOPED');
                
                break;
				
				
			case 'RESTARTED':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'img_messages/returned.png');
                $_text = $this->get_nmc('RESTARTED');
                
                break;
			
		
				
			           
            default:
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'img_messages/not_sended.png');
                $_text = $this->get_nmc('STOPED');
        }        
        
        
        $_icon = '<img  width="32" height="32" style="vertical-align:middle;" title="'.$_text.'" src="'.$icon_url.'" />';
        
        return $_icon;        
        
    
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_state_icon_url($var_state){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
        
               
        switch ($var_state){
            
            case 'V':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/check_24.png');
                $_text = $this->get_nmc('VALIDE');
                
                break;    
			
			
				
            case 'I':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/circle-24_red.png');
                $_text = $this->get_nmc('ERRONE');
                
                break;
			
			
				
			           
            default:
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/circle-24_orange.png');
                $_text = $this->get_nmc('ATTENTE');
        }        
        
        
        $_icon = '<img  width="20" height="20" style="vertical-align:middle;" title="'.$_text.'" src="'.$icon_url.'" />';
        
        return $_icon;        
        
    
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_valid_email($email){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		if (filter_var($email, FILTER_VALIDATE_EMAIL)) {

			return true;
		}
		else{

			return false;

		}

	
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_valid_tel($phone){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		if(preg_match('/^[0-9]{10}+$/', $phone)) {
			return true;
		} 
		else {
			return false;
		}


	
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_state_confirmation_icon_url($var_state){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	
		switch ($var_state){
            
            case 'C':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/check_24.png');
                $_text = 'Cas confirmé';
                
                break;    
			
							
            case 'I':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/circle-24_blue.png');
                $_text = 'Cas infirmé';
                
                break;
			
			case 'D':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/delete_24.png');
                $_text = 'Résultat indeterminé';
                
                break;	
			
			case 'S':
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/circle-24_orange.png');
                $_text = 'Cas suspect - Déclaration en attente de confirmation';
                
                break;					
		
			           
            default:
                
                $icon_url = sc_url_library('sys', 'images_ressources', 'imgmap/circle-24_orange.png');
                $_text = 'Déclaration en attente de confirmation';
		}
		
		$_icon = '<img  width="24" height="24" title="'.$_text.'" src="'.$icon_url.'" />';
        
        return $_icon;
		
	
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_suspect_state_icon_url($var_state){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
        
               
        
        if ($var_state == 'R'){    
 
			$icon_url = sc_url_library('sys', 'images_ressources', 'img/lock_open_24.png');
			$_text = $this->get_nmc('EFRAP');
 			
		}
		elseif ($var_state == 'L'){
			
			
			
			$icon_url = sc_url_library('sys', 'images_ressources', 'img/lock_ok_24.png');
  			$_text = $this->get_nmc('EFLAB');
			
		}
		elseif ($var_state == 'S'){
			
					
			$icon_url = sc_url_library('sys', 'images_ressources', 'img/lock_ok_24.png');
  			$_text = $this->get_nmc('EFSEM');
			
		}
       
        $_icon = "<img  width='24' height='24' title='".$_text."' src='".$icon_url."' style='vertical-align:middle' />";
        
        return $_icon;        
        
    
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_suspect_state_flag_icon_url($var_state){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
        
               
        
        if ($var_state == 'R'){    
 
			$icon_url = sc_url_library('sys', 'images_ressources', 'img/signal_flag_white_24.png');
			$_text = $this->get_nmc('EFRAP');
 			
		}
		elseif ($var_state == 'L'){
			
			
			
			$icon_url = sc_url_library('sys', 'images_ressources', 'img/signal_flag_blue_24.png');
  			$_text = $this->get_nmc('EFLAB');
			
		}
		elseif ($var_state == 'S'){
			
					
			$icon_url = sc_url_library('sys', 'images_ressources', 'img/signal_flag_green_24.png');
  			$_text = $this->get_nmc('EFSEM');
			
		}
       
        $_icon = "<img  width='24' height='24' title='".$_text."' src='".$icon_url."' style='vertical-align:middle' />";
        
        return $_icon;        
        
    
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_group_exists($_group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$slogin = $this->Db->qstr($_group);
	

	$check_table = 'sec_groups';    
	$check_where = "group_id = ".$_group; 

	$check_sql = 'SELECT *'
	   . ' FROM '  . $check_table
	   . ' WHERE ' . $check_where;
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


	if (false == $this->dataset )
	{
		return false;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_login_exists($_login){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	
	
	
	$slogin = $this->Db->qstr($_login);
	

	$check_table = 'sec_users';    
	$check_where = "login = ".$slogin; 

	$check_sql = 'SELECT *'
	   . ' FROM '  . $check_table
	   . ' WHERE ' . $check_where;
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


	if (false == $this->dataset )
	{
		return false;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_groups_of_wilaya($_wilaya){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = 'SELECT group_id, description ' 
		       . 'FROM sec_groups WHERE "structure" in (select code_structure from structures_sante where wilaya_structure = '."'$_wilaya') and ".'"role"' . "= 'R' and mobile='O' and profile = 'N'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rsgx = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rsgx = false;
          $this->rsgx_erro = $this->Db->ErrorMsg();
      } 


	$_groups = array();
	if (false == $this->rsgx )     
	{
		$_groups[0] = 'Error while accessing database (groups of wilaya)';
	}
	else
	{
	   while(!$this->rsgx->EOF)
		{
			$_groups[$this->rsgx->fields[0]] = $this->rsgx->fields[1];
			$this->rsgx->MoveNext();
		}
		$this->rsgx->Close();
	}


	return $_groups;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function check_token($token){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$JWT = sc_url_library('sys', 'JWT_03', 'classes/JWT.php'); 
	$KEY = sc_url_library('sys', 'JWT_03', 'includes/config.php');

	require_once($JWT);
	require_once($KEY);

	$jwt = new JWT();
	
	$_check_array = array();

	if(!$jwt->isValid($token)){
		$_check_array['message'] = 'Token invalide';
		$_check_array['http_response'] = 401;
		$_check_array['error'] = '3';
		$_check_array['valid'] = false;
		
	}
	else if (!$jwt->check($token, SECRET)){
		$_check_array['message'] = 'Token invalide';
		$_check_array['http_response'] = 401;
		$_check_array['error'] = '4';
		$_check_array['valid'] = false;
	}
	else if ($jwt->isExpired($token)){
		$_check_array['message'] = 'Le token a expiré';
		$_check_array['http_response'] = 401;
		$_check_array['error'] = '5';
		$_check_array['valid'] = false;
	}
	else{
		
		$_check_array['message'] = '';
		$_check_array['http_response'] = 200;
		$_check_array['error'] = '0';
		$_check_array['valid'] = true;
		$_check_array['payload'] = $jwt->getPayload($token);
		
		
	}
	
	return $_check_array;
	
	

$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_group($var_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  



	$check_sql = "SELECT description, structure, mobile, role, profile, profile_group, scope, default_app "
	   . " FROM sec_groups"
	   . " WHERE group_id = '" . $var_group_id . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rsg = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rsg[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rsg = false;
          $this->rsg_erro = $this->Db->ErrorMsg();
      } 



	$_gdx = array();

	if (isset($this->rsg[0][0]))     
	{
		$_gdx['group_desc'] = $this->rsg[0][0];
		$_gdx['structure'] = $this->rsg[0][1];
		$_gdx['mobile'] = $this->rsg[0][2];
		$_gdx['role'] = $this->rsg[0][3];
		$_gdx['profile'] = $this->rsg[0][4];
		$_gdx['profile_group'] = $this->rsg[0][5];
		$_gdx['scope'] = $this->rsg[0][6];
		$_gdx['default_app'] = $this->rsg[0][7];

	}



	return $_gdx;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_structure_from_group($var_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	

	$check_sql = "SELECT nom_structure, code_structure"
	   . " FROM structures_sante where code_structure in (select structure from sec_groups where group_id='".$var_group_id."')";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rss = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rss[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rss = false;
          $this->rss_erro = $this->Db->ErrorMsg();
      } 



	$_struc = array();

	if (isset($this->rss[0][0]))     
	{
		$_struc['name']  = $this->rss[0][0];
		$_struc['code'] = $this->rss[0][1];
	}

	return $_struc;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_user_details($var_username){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		
		
		$slogin = $this->Db->qstr($var_username);
	
		$check_sql = "SELECT \"name\", email, active, mfa, group_id, reset, priv_admin, tel, profession_nm_fk"
		   . " FROM sec_users"
		   . " WHERE login = " . $slogin ;
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$_ud= array();

		 $_ud['login'] = $var_username;

		if (isset($this->rs[0][0]))     
		{
			$_ud['name'] = $this->rs[0][0];
			$_ud['email'] = $this->rs[0][1];
			$_ud['active'] = $this->rs[0][2];
			$_ud['mfa'] = $this->rs[0][3];
			$_ud['group'] = $this->rs[0][4];
			$_ud['reset'] = $this->rs[0][5];
			$_ud['admin'] = $this->rs[0][6];
			$_ud['tel'] = $this->rs[0][7];
			$_ud['profession'] = $this->rs[0][8];
			
			
		}

		$_g = $_ud['group'];



		if (isset($_g) && !empty($_g)){


			$_gdetails = $this->get_group($_g);


			if (isset($_gdetails)){

					$_ud['group_name'] = $_gdetails['group_desc'];
					$_ud['mobile'] = $_gdetails['mobile'];
				    $_ud['code_structure'] = $_gdetails['structure'];
					$_ud['role'] = $_gdetails['role'];
				    $_ud['scope'] = $_gdetails['scope'];

					$_struc = $this->get_structure_from_group($_g);


					if (isset($_struc)){

						$_ud['name_structure'] = $_struc['name'];
						$_ud['code_structure'] = $_struc['code'];

					}
			}

		}


	
	return $_ud;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_facility_status($facilitycode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$check_sql = "SELECT statut_structure_nm_fk"
	   . " FROM public.structures_sante"
	   . " WHERE code_structure = '" . $facilitycode . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$inst = '';

	if (isset($this->rs[0][0]))     
	{
		$inst = $this->rs[0][0];

	}


	return $inst;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function check_user($var_user, $var_pwd){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	
	
	
	$slogin = $this->Db->qstr($var_user);
	$spswd  = $this->Db->qstr($var_pwd);

	$check_table = 'sec_users';    
	$check_where = "login = ".$slogin." and pswd=".$spswd; 

	$check_sql = 'SELECT *'
	   . ' FROM '  . $check_table
	   . ' WHERE ' . $check_where;
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


	if (false == $this->dataset )
	{
		return false;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_name_of_user($user){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT name'
	   . ' FROM public.sec_users'
	   . " WHERE login = '" . $user. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$nuser = '';

	if (isset($this->rs[0][0]))     
	{
		$nuser = $this->rs[0][0];

	}

	return $nuser;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_name_of_group($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT description'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$ngroup = '';

	if (isset($this->rs[0][0]))     
	{
		$ngroup = $this->rs[0][0];

	}

	return $ngroup;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_default_app_of_group($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT default_app'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$ngroup = '';

	if (isset($this->rs[0][0]))     
	{
		$ngroup = $this->rs[0][0];

	}

	return $ngroup;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_validator($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT role'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$v = false;

	if (isset($this->rs[0][0]))     
	{
		$vgroup = $this->rs[0][0];
		if ($vgroup=='V'){

			$v = true;
		}


	}

	return $v;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_mobilegroup($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT mobile'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$v = false;

	if (isset($this->rs[0][0]))     
	{
		$vgroup = $this->rs[0][0];
		if ($vgroup=='O'){

			$v = true;
		}


	}

	return $v;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_profilegroup($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT profile'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$v = false;

	if (isset($this->rs[0][0]))     
	{
		$vgroup = $this->rs[0][0];
		if ($vgroup=='O'){

			$v = true;
		}


	}

	return $v;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_group_of_role($group, $role){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT role'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$v = false;

	if (isset($this->rs[0][0]))     
	{
		$vgrouprole = $this->rs[0][0];
		if ($vgrouprole==$role){

			$v = true;
		}


	}

	return $v;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_profile_of_group($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


	$check_sql = 'SELECT profile_group'
	   . ' FROM public.sec_groups'
	   . " WHERE group_id = '" . $group. "'";

	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$rgroup = '';

	if (isset($this->rs[0][0]))     
	{
		$rgroup = $this->rs[0][0];

	}

	return $rgroup;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_groups_of_user($username){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	/**
	 * Récupérer les groupes de l'utiliateur
	 */

	$check_sql = 'SELECT group_id'
	   . ' FROM public.sec_users_groups'
	   . " WHERE login = '" . $username. "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$_groups = array();
	if (false == $this->rs)     // Error while accessing database
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (groups of user)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (groups of user)';
 }
;
	}
	else
	{
	   while(!$this->rs->EOF)
		{
			$_groups[] = $this->rs->fields[0];
			$this->rs->MoveNext();
		}
		$this->rs->Close();
	}


	return $_groups;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_code_facility_of_group($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT structure"
	   . " FROM public.sec_groups"
	   . " WHERE group_id = '" . $group . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$inst = '';

	if (isset($this->rs[0][0]))     // Row found
	{
		$inst = $this->rs[0][0];

	}

	return $inst;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_name_of_facility($facilitycode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT nom_structure"
	   . " FROM public.structures_sante"
	   . " WHERE code_structure = '" . $facilitycode . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$inst = '';

	if (isset($this->rs[0][0]))     // Row found
	{
		$inst = $this->rs[0][0];

	}


	return $inst;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_type_of_facility($facilitycode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT type_structure"
	   . " FROM public.structures_sante"
	   . " WHERE code_structure = '" . $facilitycode . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$inst = '';

	if (isset($this->rs[0][0]))     // Row found
	{
		$inst = $this->rs[0][0];

	}


	return $inst;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_facility_contain_labo($facilitycode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT *"
	   . " FROM public.structures_sante"
	   . " WHERE code_structure = '" . $facilitycode . "' and role_labo='O'";
		
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


	if (false == $this->dataset )
	{
		return false;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_wilaya_of_group($group){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT wilaya_structure"
	   . " FROM public.structures_sante"
	   . " WHERE code_structure in (select structure from sec_groups where group_id = '" . $group . "')";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$_wils = array();

	if (false == $this->rs)     // Error while accessing database
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (wilayas of groups)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (wilayas of groups)';
 }
;
	}
	else
	{
	   while(!$this->rs->EOF)
		{
			$_wils[] = $this->rs->fields[0];
			$this->rs->MoveNext();
		}
		$this->rs->Close();
	}


	return $_wils;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_wilayas_of_group($groupcode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

		$check_sql = "SELECT wilaya_fk"
		   . " FROM public.sec_groups_wilayas"
		   . " WHERE group_fk = '" . $groupcode . "'";
		 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


		$_wils = array();

		if (false == $this->rs)     // Error while accessing database
		{
			
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (wilayas of groups)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (wilayas of groups)';
 }
;
		}
		else
		{
		   while(!$this->rs->EOF)
			{
				$_wils[] = $this->rs->fields[0];
				$this->rs->MoveNext();
			}
			$this->rs->Close();
		}


		return $_wils;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_communes_of_epsp($epsp_code){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT code_commune"
	   . " FROM public.commune"
	   . " WHERE code_epsp = '" . $epsp_code . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$_coms = array();

	if (false == $this->rs)     // Error while accessing database
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (communes of groups)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (communes of groups)';
 }
;
	}
	else
	{
	   while(!$this->rs->EOF)
		{
			$_coms[] = $this->rs->fields[0];
			$this->rs->MoveNext();
		}
		$this->rs->Close();
	}


	return $_coms;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_semep_users_of_facility($facility){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$check_sql = "SELECT login from sec_users where group_id in (select group_id from sec_groups where structure = '$facility' and role='S')";
	   
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$_users = array();

	if (false == $this->rs)     // Error while accessing database
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (communes of groups)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (communes of groups)';
 }
;
	}
	else
	{
	   while(!$this->rs->EOF)
		{
			$_users[] = $this->rs->fields[0];
			$this->rs->MoveNext();
		}
		$this->rs->Close();
	}


	return $_users;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_rap_users_of_facility($facility){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$check_sql = "SELECT login from sec_users where group_id in (select group_id from sec_groups where structure = '$facility' and role='R')";
	   
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$_users = array();

	if (false == $this->rs)     // Error while accessing database
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (communes of groups)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (communes of groups)';
 }
;
	}
	else
	{
	   while(!$this->rs->EOF)
		{
			$_users[] = $this->rs->fields[0];
			$this->rs->MoveNext();
		}
		$this->rs->Close();
	}


	return $_users;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function is_semep_of_epsp($facilitycode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT code_commune"
	   . " FROM public.commune"
	   . " WHERE code_epsp = '" . $facilitycode . "'";
		
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


	if (false == $this->dataset )
	{
		return false;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_communes_of_group($groupcode){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT commune_structure"
	   . " FROM public.structures_sante"
	   . " WHERE code_structure in (select structure from sec_groups where group_id = '" . $groupcode . "')";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rs = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$_coms = array();

	if (false == $this->rs)     // Error while accessing database
	{
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (communes of groups)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (communes of groups)';
 }
;
	}
	else
	{
	   while(!$this->rs->EOF)
		{
			$_coms[] = $this->rs->fields[0];
			$this->rs->MoveNext();
		}
		$this->rs->Close();
	}


	return $_coms;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_nom_wilaya($wil){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT nom_wilaya"
	   . " FROM wilaya"
	   . " WHERE code_wilaya = '" . $wil . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$nwil = '';

	if (isset($this->rs[0][0]))     // Row found
	{
		$nwil = $this->rs[0][0];

	}


	return $nwil;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_nom_commune($com){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$check_sql = "SELECT nom_commune"
	   . " FROM commune"
	   . " WHERE code_commune = '" . $com . "'";
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($SCrx = $this->Db->Execute($nm_select)) 
      { 
          $SCy = 0; 
          $nm_count = $SCrx->FieldCount();
          while (!$SCrx->EOF)
          { 
                 for ($SCx = 0; $SCx < $nm_count; $SCx++)
                 { 
                      $this->rs[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 


	$ncom = '';

	if (isset($this->rs[0][0]))     // Row found
	{
		$ncom = $this->rs[0][0];

	}


	return $ncom;
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function get_photo_of_user($user){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  


			$check_sql = "SELECT encode(picture, 'base64')"
			   . ' FROM public.sec_users'
			   . " WHERE login = '" . $user. "'";

			 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->rsp = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rsp = false;
          $this->rsp_erro = $this->Db->ErrorMsg();
      } 

			
			$_photo = array();
			if (false === $this->rsp )     // Error while accessing database
			{
				
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= 'Error while accessing database (photo of user)';
 if ('submit_form' == $this->NM_ajax_opcao || 'event_' == substr($this->NM_ajax_opcao, 0, 6) || (isset($this->wizard_action) && 'change_step' == $this->wizard_action))
 {
  if (isset($this->wizard_action) && 'change_step' == $this->wizard_action) {
   $sErrorIndex = 'geral_app_Login';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_app_Login';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = 'Error while accessing database (photo of user)';
 }
;
			}
			else
			{
			   while(!$this->rsp->EOF)
				{
					$_photo[] = $this->rsp->fields[0];
					$this->rsp->MoveNext();
				}
				$this->rsp->Close();
			}




			if (!empty($_photo[0])){
				return '<img width="50" height="50" style="border-radius: 50%; border: 2px solid #ccc; padding:1px;margin:10px;" src="data:image/png;base64,'.$_photo[0].'" />';
			}
			else{
				return '<img width="50" height="50" style="border-radius: 50%; border: 2px solid #ccc; padding:1px;margin:10px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAqESURBVGhD1ZprjBVnGcf/M+e2twPLLrvLtrSABUoBpQkGStFWadIq1tYajcYvjTHWlCYmfjDR9IN+Nq0fjMaPNRqTxsaSNPFDFdtCQRAoYIF2YYFdYK+wZ9mzu+d+zozP87zvOTNnzv1CUn5n57zP887MO89/3uvMWePZ1w/aaBHbtpEvxNAW5ymj8KXzivfnU8O29KFOvvKtgm9wyh85hjb5Uylju45VO9UOKYs3+piS0wKqIMVnXSzTkmBVkOJeEMv5TQtWBSnuFbH8aUqwKkhxL4nltGHBqiDFvSaW8xsSrApS3ItimboFq4IU95xYlSP765qHVUGKpsRmUsDcDdjRWSCxBDubpj0kLRACOnuAnj7YK4dghLrpbPrky5E/lTJNi9X7yagtWBWkaFgsCbXHzsKeHAGsnORVJdwPe3gT7IF15PDVqBxVFJXZuli2qwpWBTlICHIyIYmyCwXm7XQc1sxV2BMkNLEo+Q3RGYa1cRfs8Gpx2yWW7Yp9WBXkUK9Ye+oycv95C/boyebEMtTszQvvA5GbVGb7xLJdVrAqyKF+sZdgffohkMtKXkuQUN+Vk7CTy851dAxyLd70tTlfbEm1TxsZRTanJYJVQQ51N2MKzLp8Qvy2QTcuM3oa2XSSLyJZKj710RnKllT7cqzO07ZKPdOSKsyhbrGEdfNie2rWQ2csgvnp68iQaBWfOyblq1T7sk/naTt/PKcFweyobEUjYuXc2zfEdrOmP4ztn1ujvebguTuYXERkdgLpZMIVE8dLtqTal306T9tFMdImgsWRbEWjYqVmXQOUzzRx4IU9eOOX38VvDuzHN/c+ovc0RygTpy5t4c7tSRFNF+UIdUpwKvHoPG27Y8zbpjhiKhoWy+R4IeHw8guP4bkvbYVhGDBpe+Xbj+PVF5/CYC8tMpogkKWFC8HXi85NI5WMs6PDy8dLm8t2x+jYNBBuevp7vxaPaEaswSktKuwbF8Tfsm4QP/3OXrHdrBvqxbN7t2JwVQ+WEinML7qap4vujiB2b31A7GiMBivCNkwsd/WJzaTiMfgCAfj9ASc2SvO2O0bH5umNFh77X3tbcpoVyx9kM7A+/Kvk/fwHT+KpnRvFrkY8mcboRATTkSUkUhmEAn7cP7AC2zYMwe8zEaP9L792ELfuLCPrC2JqYLM+06Gntx+hzi4OqBCnO0bHVmIZ6cMtiWXf9FEGNV/TwK5HVO3UootqcsfGYXxt92a88MQ27N/zsPgsluGa3v/YFrErsbwQodp25ml3jI7tiGUoxBbFEvJNooeouYa76IGgTWx6QC0tqUYqshy9g2RBtIrRsYvF8sAng5byCl/6BLftpCVixSfoyWe4f4XktYu+cKeklkEtqArxpSiJjontxFsqlvep9iP5joBi20krid26Cnj9x/sw2NfcKFyJzo4ANq1djd8deAYrO/w6tzyJ5UUkYktiVxLLmCpfC5BU2y5RTMWapXTXkIlt6wfx/X07ZF+74H786ov7sP3BfuxcG9a5lUnGlqV5U1Aqg3CLZaiGtQCPGHdaTSx90UCg8nll1U54PFjTp8r00WhTDzxlFZq3RyyjVloeMe60llj2p5bVvrvJ+Lyak+shnUhIbXvFWrReMFsVy/f9zG1aeHD+XWJmKY2rEVpdNUA6mUSKhOdhsRwv9WFHjDutVyznzsQsHJ1s/5NSnr98NANLhdEQmZQSnRfLqCbtEsU0IjZ/zh/+l8b1RR4d28v7V+6I4GZh0VzbeQrzcE2x8q0EesXysZGkhZcOxTFPabs4NHoHrxy8jGwz1esim06TcPUAUlTDVcWyTVs5sfmjOK52Nu33SHC7yIsu1HCrYtVhFv59I6P8FolnLPxzdF577YFFSw23SyxzMZLFWLSOd9A1+MenEcTTrZfjhdYMOnAtpBWxci75b47UP2eWI0eF/OnUtPbaS8k8rC3Ja1SsMix8fLu1fvzOxQjG5p05tJ0UzcPaYkf8ZsQy3P9a4eykegi4GxRGaRWyqBC/WbHsJ7I67zOI6yWeqJCAWxHLn3SOF+2S1RSZbPsHqzzUhxlRIQG3KpbWcXjyoSHYZvXn12o8s+tRBKz2TG9eqEmLCgm4VbFGMoaOy8fw/BfWwwyqtxXN8NVdO7EdUfSkmvwxrgoyaLUsljZfZAKdI0dgxhbg9/thrHmUJngutTGMFffB6FmDkN/EwOIkVi9NUzNU12oH0odbrVnfwjRC42cLvy0tLi6qwNd9GfDX/1LP6HsIxoN7pdxoNCp54eQCBpamxG4H8h5Bwq5bbA6+dBzBxVn03B5F3/XTWDmlXsLnmZyclNQID8Pc/HUSspEcmRDK09ELY8NXYNz/RTkuEokg6XrCCWfjeCQ1jQcy8+jPLaPL4iWijqdBZOFRS6xJArtnL6P3+imsHj2CvrETWDl9EV13JhBILdM4Vdzkrl27pi3CFyIhO2E+/A0YA1uoMNdg1jMEY/0TMDc9Tc14SGd6zic4vgDd6FW5OO7PLGBj+ha2JSexOTUjNyFs1b+yc72mLS/WR4J6x0+SuBsIJKIwyvyvRqEMzcjIiLZcBLpgD3weqf69iC3aSIU2kNgnpRVQtapjNN7zveUzfEaHnZWbsCE9R6l6j1UL1c4qiOXfjMITH8PMVZ8ivAHNzc1hZqb4oX3h5gL+9sM38fbP/oV3fp/B27+6hL//5C1cerf05pw/f15binKCvaylmg/RDaiFGqXLiOWLdFCT9adr37lyAZ07d05bfN8sHP/jMeQyxa0jtZTCR38+jVsjt3QOkEwky7aQWqL5F5RhEl0L9fDAeMTyD9Fd8+Pi16JcMGfOnNEWcOW9UcyPlX+2tS0bp944KSlz/sJ5ZLPNPXysoL7cWWPBopt0sViGR2FT/oGsNmVr+OxZ5HKqRhduLCA8HKbxqnikZn94x31Y//h6ejhXIk+fPi1pCTVqOA+P4tWQ0d0rlufZjmhrz6NLy8v45OInYu/60W4899tvYfdLe8TPM7hlEPt+8RS2Pb8dgQ71W++JE6X/GMM/rHvGtYr00iBWbcqiUbpUrEE1G4zX/z4pFAohGAzKCsvN8ePHtaVY9eAqbSksz8u58fFx3Lrl9Gcur7u7Gz09PSS6yjzugsWuyFV+lpZS3GKZYGyOHbHrgWuA52Jv3zvx3+LaSkaLA4lOqNVUHu8N4vISiQQymYwTYx1wX66Eax52ajoYa+zlGQdVbqCZnp7G1atXtUeCF4sDSS0lkaQtz7Gjx7TlwDeSV12NDGThXLJiD9CDlqtZNyHY25TdHD16VFtcw547T5fL1/LU1BSujRWvsNxUu4YXHywarcsPuNTkHbH84ZWVaTU2LVQV/GEVwUR0Qs2d7hvjxefzqYGrAbot9eLdS6EPy4dSXj42SjXBE5MT1KyviO3tw0xe8AcfHJa0HIFAQFv101NJsFssE0g2/tDNd79aUIcPH5HU24cZbtI3b97EWIXmzGU30pzz8BNVOUqelpoRzASrCD5y5Ihco2yTnozSDalSuyS20ebMcD8OlllbFz0tgfquP1MaVD2Y1M/8tJVjdnZW1sfx+dLfeLnWD717SHulBGh+b5bSWgb+D9iXSRNe3sfQAAAAAElFTkSuQmCC" />';
			}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function random_string($_length){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	
    $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ?#!.;@],_';
    $charactersLength = strlen($characters);
    $randomString = '';
    for ($i = 0; $i < $_length; $i++) {
        $randomString .= $characters[random_int(0, $charactersLength - 1)];
    }
    return $randomString;
	
	

$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function delete_from_all_groups($_login){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	/**
	 * Delete a record on another table
	 */

	$delete_table  = 'sec_users_groups';      // Table name
	$delete_where  = "login = '".$_login."'"; // Where clause

	$delete_sql = 'DELETE FROM ' . $delete_table
		. ' WHERE '      . $delete_where;
	
     $nm_select = $delete_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function add_user_to_group($user_login, $group_login){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  	
	
	
	/**
	 * Insert a record on another table
	 */

	$insert_table  = 'sec_users_groups';      // Table name
	$insert_fields = array(   // Field list, add as many as needed
		 'login' => "'".$user_login."'",
		 'group_id' => "'".$group_login."'",
	 );



	$insert_sql = 'INSERT INTO ' . $insert_table
		. ' ('   . implode(', ', array_keys($insert_fields))   . ')'
		. ' VALUES ('    . implode(', ', array_values($insert_fields)) . ')';



	
     $nm_select = $insert_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function delete_links($_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$sql = "DELETE FROM sec_groups_apps  where  group_id = '". $_group_id."'";
	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function delete_rights($_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$sql = "UPDATE sec_groups_apps set priv_access='N', priv_insert='N', priv_delete='N', priv_update='N', "
		   . "priv_export='N', priv_print='N' " . " where group_id = " . $_group_id;

	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function delete_scope($_table, $_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  
	
	$delete_table  = $_table;      // Table name
	$delete_where  = "group_fk = $_group_id"; // Where clause

	$delete_sql = 'DELETE FROM ' . $delete_table
		. ' WHERE '      . $delete_where;
	
     $nm_select = $delete_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function set_rights($_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$sql = "INSERT INTO sec_groups_apps(group_id, app_name)
			 SELECT '". $_group_id."', app_name FROM sec_apps ";
	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function set_rights_from_template($_group_id, $_template, $_reset){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	$sql = '';

	if ($_reset=='O'){


		$this->delete_links($_group_id);

		$sql =    "INSERT INTO sec_groups_apps(group_id, app_name, priv_access, priv_insert, priv_delete, priv_update, "
		   .  "priv_export, priv_print) "
		   .  " SELECT '". $_group_id."', app_name, priv_access, priv_insert, priv_delete, priv_update, priv_export, priv_print"
		   .  " FROM sec_groups_apps where group_id = '".$_template."'";


	}
	else{

		$sql =    "INSERT INTO sec_groups_apps(group_id, app_name, priv_access, priv_insert, priv_delete, priv_update, "
		   .  "priv_export, priv_print) "
		   .  " SELECT '". $_group_id."', app_name, priv_access, priv_insert, priv_delete, priv_update, priv_export, priv_print"
		   .  " FROM sec_groups_apps where group_id = '".$_template."'"
		   .  "ON Conflict (group_id, app_name) DO "
		   .  "UPDATE SET priv_access = excluded.priv_access, priv_insert=excluded.priv_insert, priv_delete=excluded.priv_delete, priv_update=excluded.priv_update, priv_export=excluded.priv_export, priv_print=excluded.priv_print WHERE sec_groups_apps.priv_access is distinct from 'Y'";




	}



	
     $nm_select = $sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                app_Login_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
function users_exists($_group_id){
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'on';
  

	/**
	 * Check for an existing record
	 */

	$check_table = 'sec_users_groups';    // Table name
	$check_where = "group_id = $_group_id"; // Where clause

	$check_sql = 'SELECT *'
	   . ' FROM '  . $check_table
	   . ' WHERE ' . $check_where;
	 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($this->dataset = $this->Db->Execute($nm_select)) 
      { }
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->dataset = false;
          $this->dataset_erro = $this->Db->ErrorMsg();
      } 


	if (false == $this->dataset )
	{
		return true;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
}
//
}
//===============================================================================
class app_Login_edit
{
    var $contr_app_Login;
    function inicializa()
    {
        global $nm_opc_lookup, $nm_opc_php, $script_case_init;
        require_once("app_Login_apl.php");
        $this->contr_app_Login = new app_Login_apl();
    }
}
if (!function_exists("NM_is_utf8"))
{
    include_once("../_lib/lib/php/nm_utf8.php");
}
ob_start();
//
//----------------  
//
    $_SESSION['scriptcase']['app_Login']['contr_erro'] = 'off';
    if (!function_exists("NM_is_utf8"))
    {
        include_once("../_lib/lib/php/nm_utf8.php");
    }
    if (!function_exists("SC_dir_app_ini"))
    {
        include_once("../_lib/lib/php/nm_ctrl_app_name.php");
    }
    SC_dir_app_ini('Pandemic_Alerts');
    $sc_conv_var = array();
    if (!empty($_FILES))
    {
        foreach ($_FILES as $nmgp_campo => $nmgp_valores)
        {
             if (isset($sc_conv_var[$nmgp_campo]))
             {
                 $nmgp_campo = $sc_conv_var[$nmgp_campo];
             }
             elseif (isset($sc_conv_var[strtolower($nmgp_campo)]))
             {
                 $nmgp_campo = $sc_conv_var[strtolower($nmgp_campo)];
             }
             $tmp_scfile_name     = $nmgp_campo . "_scfile_name";
             $tmp_scfile_type     = $nmgp_campo . "_scfile_type";
             $$nmgp_campo = is_array($nmgp_valores['tmp_name']) ? $nmgp_valores['tmp_name'][0] : $nmgp_valores['tmp_name'];
             $$tmp_scfile_type   = is_array($nmgp_valores['type'])     ? $nmgp_valores['type'][0]     : $nmgp_valores['type'];
             $$tmp_scfile_name   = is_array($nmgp_valores['name'])     ? $nmgp_valores['name'][0]     : $nmgp_valores['name'];
        }
    }
    $Sc_lig_md5 = false;
    $Sem_Session = (!isset($_SESSION['sc_session'])) ? true : false;
    $_SESSION['scriptcase']['sem_session'] = false;
    if (!empty($_POST))
    {
        foreach ($_POST as $nmgp_var => $nmgp_val)
        {
             if (substr($nmgp_var, 0, 11) == "SC_glo_par_")
             {
                 $nmgp_var = substr($nmgp_var, 11);
                 $nmgp_val = $_SESSION[$nmgp_val];
             }
             if ($nmgp_var == "nmgp_parms" && substr($nmgp_val, 0, 8) == "@SC_par@")
             {
                 $SC_Ind_Val = explode("@SC_par@", $nmgp_val);
                 if (count($SC_Ind_Val) == 4 && isset($_SESSION['sc_session'][$SC_Ind_Val[1]][$SC_Ind_Val[2]]['Lig_Md5'][$SC_Ind_Val[3]]))
                 {
                     $nmgp_val = $_SESSION['sc_session'][$SC_Ind_Val[1]][$SC_Ind_Val[2]]['Lig_Md5'][$SC_Ind_Val[3]];
                     $Sc_lig_md5 = true;
                 }
                 else
                 {
                     $_SESSION['sc_session']['SC_parm_violation'] = true;
                 }
             }
             if (isset($sc_conv_var[$nmgp_var]))
             {
                 $nmgp_var = $sc_conv_var[$nmgp_var];
             }
             elseif (isset($sc_conv_var[strtolower($nmgp_var)]))
             {
                 $nmgp_var = $sc_conv_var[strtolower($nmgp_var)];
             }
             nm_limpa_str_app_Login($nmgp_val);
             $nmgp_val = NM_decode_input($nmgp_val);
             $$nmgp_var = $nmgp_val;
        }
    }
    if (!empty($_GET))
    {
        foreach ($_GET as $nmgp_var => $nmgp_val)
        {
             if (substr($nmgp_var, 0, 11) == "SC_glo_par_")
             {
                 $nmgp_var = substr($nmgp_var, 11);
                 $nmgp_val = $_SESSION[$nmgp_val];
             }
             if ($nmgp_var == "nmgp_parms" && substr($nmgp_val, 0, 8) == "@SC_par@")
             {
                 $SC_Ind_Val = explode("@SC_par@", $nmgp_val);
                 if (count($SC_Ind_Val) == 4 && isset($_SESSION['sc_session'][$SC_Ind_Val[1]][$SC_Ind_Val[2]]['Lig_Md5'][$SC_Ind_Val[3]]))
                 {
                     $nmgp_val = $_SESSION['sc_session'][$SC_Ind_Val[1]][$SC_Ind_Val[2]]['Lig_Md5'][$SC_Ind_Val[3]];
                     $Sc_lig_md5 = true;
                 }
                 else
                 {
                     $_SESSION['sc_session']['SC_parm_violation'] = true;
                 }
             }
             if (isset($sc_conv_var[$nmgp_var]))
             {
                 $nmgp_var = $sc_conv_var[$nmgp_var];
             }
             elseif (isset($sc_conv_var[strtolower($nmgp_var)]))
             {
                 $nmgp_var = $sc_conv_var[strtolower($nmgp_var)];
             }
             nm_limpa_str_app_Login($nmgp_val);
             $nmgp_val = NM_decode_input($nmgp_val);
             $$nmgp_var = $nmgp_val;
        }
    }
    if (!isset($_SERVER['HTTP_REFERER']) || (!isset($nmgp_parms) && !isset($script_case_init) && !isset($_POST['rs']) && !isset($nmgp_start) ))
    {
        $Sem_Session = false;
    }
    $NM_dir_atual = getcwd();
    if (empty($NM_dir_atual)) {
        $str_path_sys  = (isset($_SERVER['SCRIPT_FILENAME'])) ? $_SERVER['SCRIPT_FILENAME'] : $_SERVER['ORIG_PATH_TRANSLATED'];
        $str_path_sys  = str_replace("\\", '/', $str_path_sys);
    }
    else {
        $sc_nm_arquivo = explode("/", $_SERVER['PHP_SELF']);
        $str_path_sys  = str_replace("\\", "/", getcwd()) . "/" . $sc_nm_arquivo[count($sc_nm_arquivo)-1];
    }
    $str_path_web    = $_SERVER['PHP_SELF'];
    $str_path_web    = str_replace("\\", '/', $str_path_web);
    $str_path_web    = str_replace('//', '/', $str_path_web);
    $path_aplicacao  = substr($str_path_web, 0, strrpos($str_path_web, '/'));
    $path_aplicacao  = substr($path_aplicacao, 0, strrpos($path_aplicacao, '/'));
    $root            = substr($str_path_sys, 0, -1 * strlen($str_path_web));
    if ($Sem_Session && (!isset($nmgp_start) || $nmgp_start != "SC")) {
        if (isset($_COOKIE['sc_apl_default_Pandemic_Alerts'])) {
            $apl_def = explode(",", $_COOKIE['sc_apl_default_Pandemic_Alerts']);
        }
        elseif (is_file($root . $_SESSION['scriptcase']['app_Login']['glo_nm_path_imag_temp'] . "/sc_apl_default_Pandemic_Alerts.txt")) {
            $apl_def = explode(",", file_get_contents($root . $_SESSION['scriptcase']['app_Login']['glo_nm_path_imag_temp'] . "/sc_apl_default_Pandemic_Alerts.txt"));
        }
        if (isset($apl_def)) {
            if ($apl_def[0] != "app_Login") {
                $_SESSION['scriptcase']['sem_session'] = true;
                if (strtolower(substr($apl_def[0], 0 , 7)) == "http://" || strtolower(substr($apl_def[0], 0 , 8)) == "https://" || substr($apl_def[0], 0 , 2) == "..") {
                    $_SESSION['scriptcase']['app_Login']['session_timeout']['redir'] = $apl_def[0];
                }
                else {
                    $_SESSION['scriptcase']['app_Login']['session_timeout']['redir'] = $path_aplicacao . "/" . SC_dir_app_name($apl_def[0]) . "/index.php";
                }
                $Redir_tp = (isset($apl_def[1])) ? trim(strtoupper($apl_def[1])) : "";
                $_SESSION['scriptcase']['app_Login']['session_timeout']['redir_tp'] = $Redir_tp;
            }
            if (isset($_COOKIE['sc_actual_lang_Pandemic_Alerts'])) {
                $_SESSION['scriptcase']['app_Login']['session_timeout']['lang'] = $_COOKIE['sc_actual_lang_Pandemic_Alerts'];
            }
        }
    }
    if (isset($SC_lig_apl_orig) && !$Sc_lig_md5 && (!isset($nmgp_parms) || ($nmgp_parms != "SC_null" && substr($nmgp_parms, 0, 8) != "OrScLink")))
    {
        $_SESSION['sc_session']['SC_parm_violation'] = true;
    }
    if (isset($nmgp_parms) && $nmgp_parms == "SC_null")
    {
        $nmgp_parms = "";
    }
    if (isset($SC_where_pdf) && !empty($SC_where_pdf))
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['where_filter'] = $SC_where_pdf;
    }

    if (isset($_POST['rs']) && !is_array($_POST['rs']) && 'ajax_' == substr($_POST['rs'], 0, 5) && isset($_POST['rsargs']) && !empty($_POST['rsargs']) && !isset($_SESSION['scriptcase']['app_Login']['session_timeout']['redir']))
    {
        if ('ajax_app_Login_validate_login' == $_POST['rs'])
        {
            $login = NM_utf8_urldecode($_POST['rsargs'][0]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][1]);
        }
        if ('ajax_app_Login_validate_pswd' == $_POST['rs'])
        {
            $pswd = NM_utf8_urldecode($_POST['rsargs'][0]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][1]);
        }
        if ('ajax_app_Login_validate_new_user' == $_POST['rs'])
        {
            $new_user = NM_utf8_urldecode($_POST['rsargs'][0]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][1]);
        }
        if ('ajax_app_Login_validate_remember_me' == $_POST['rs'])
        {
            $remember_me = NM_utf8_urldecode($_POST['rsargs'][0]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][1]);
        }
        if ('ajax_app_Login_validate_retrieve_pswd' == $_POST['rs'])
        {
            $retrieve_pswd = NM_utf8_urldecode($_POST['rsargs'][0]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][1]);
        }
        if ('ajax_app_Login_submit_form' == $_POST['rs'])
        {
            $login = NM_utf8_urldecode($_POST['rsargs'][0]);
            $pswd = NM_utf8_urldecode($_POST['rsargs'][1]);
            $new_user = NM_utf8_urldecode($_POST['rsargs'][2]);
            $remember_me = NM_utf8_urldecode($_POST['rsargs'][3]);
            $retrieve_pswd = NM_utf8_urldecode($_POST['rsargs'][4]);
            $new_user_sc_target_name = NM_utf8_urldecode($_POST['rsargs'][5]);
            $retrieve_pswd_sc_target_name = NM_utf8_urldecode($_POST['rsargs'][6]);
            $nm_form_submit = NM_utf8_urldecode($_POST['rsargs'][7]);
            $nmgp_url_saida = NM_utf8_urldecode($_POST['rsargs'][8]);
            $nmgp_opcao = NM_utf8_urldecode($_POST['rsargs'][9]);
            $nmgp_ancora = NM_utf8_urldecode($_POST['rsargs'][10]);
            $nmgp_num_form = NM_utf8_urldecode($_POST['rsargs'][11]);
            $nmgp_parms = NM_utf8_urldecode($_POST['rsargs'][12]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][13]);
            $csrf_token = NM_utf8_urldecode($_POST['rsargs'][14]);
            $bok = NM_utf8_urldecode($_POST['rsargs'][15]);
        }
        if ('ajax_app_Login_navigate_form' == $_POST['rs'])
        {
            $nm_form_submit = NM_utf8_urldecode($_POST['rsargs'][0]);
            $nmgp_opcao = NM_utf8_urldecode($_POST['rsargs'][1]);
            $nmgp_ordem = NM_utf8_urldecode($_POST['rsargs'][2]);
            $nmgp_arg_dyn_search = NM_utf8_urldecode($_POST['rsargs'][3]);
            $script_case_init = NM_utf8_urldecode($_POST['rsargs'][4]);
        }
    }

    if (!empty($glo_perfil))  
    { 
        $_SESSION['scriptcase']['glo_perfil'] = $glo_perfil;
    }   
    if (isset($glo_servidor)) 
    {
        $_SESSION['scriptcase']['glo_servidor'] = $glo_servidor;
    }
    if (isset($glo_banco)) 
    {
        $_SESSION['scriptcase']['glo_banco'] = $glo_banco;
    }
    if (isset($glo_tpbanco)) 
    {
        $_SESSION['scriptcase']['glo_tpbanco'] = $glo_tpbanco;
    }
    if (isset($glo_usuario)) 
    {
        $_SESSION['scriptcase']['glo_usuario'] = $glo_usuario;
    }
    if (isset($glo_senha)) 
    {
        $_SESSION['scriptcase']['glo_senha'] = $glo_senha;
    }
    if (isset($glo_senha_protect)) 
    {
        $_SESSION['scriptcase']['glo_senha_protect'] = $glo_senha_protect;
    }
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['lig_edit_lookup']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['lig_edit_lookup']     = false;
        $_SESSION['sc_session'][$script_case_init]['app_Login']['lig_edit_lookup_cb']  = '';
        $_SESSION['sc_session'][$script_case_init]['app_Login']['lig_edit_lookup_row'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_call']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_call'] = false;
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_proc']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_proc'] = false;
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_insert']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_insert'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_update']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_update'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_delete']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_delete'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_btn_nav']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_form_btn_nav'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_grid_edit']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_grid_edit'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_grid_edit_link']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_grid_edit_link'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_qtd_reg']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_qtd_reg'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_tp_pag']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_liga_tp_pag'] = '';
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && !isset($_SESSION['sc_session'][$script_case_init]['app_Login']['run_modal']))
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['run_modal'] = isset($_GET['nmgp_url_saida']) && 'modal' == $_GET['nmgp_url_saida'];
    } 
    if (isset($script_case_init) && !is_array($script_case_init) && $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_proc'])
    {
        return;
    }
    if (isset($script_case_init) && !is_array($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_parms']))
    { 
        $tmp_nmgp_parms = '';
        if (isset($nmgp_parms) && '' != $nmgp_parms)
        {
            $tmp_nmgp_parms = $nmgp_parms . '?@?';
        }
        $nmgp_parms = $tmp_nmgp_parms . $_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_parms'];
        unset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_parms']);
    } 
    if (isset($nmgp_parms) && !empty($nmgp_parms) && !is_array($nmgp_parms)) 
    { 
        if (isset($_SESSION['nm_aba_bg_color'])) 
        { 
            unset($_SESSION['nm_aba_bg_color']);
        }   
        $nmgp_parms = NM_decode_input($nmgp_parms);
        $nmgp_parms = str_replace("@aspass@", "'", $nmgp_parms);
        $nmgp_parms = str_replace("*scout", "?@?", $nmgp_parms);
        $nmgp_parms = str_replace("*scin", "?#?", $nmgp_parms);
        $todox = str_replace("?#?@?@?", "?#?@ ?@?", $nmgp_parms);
        $todo  = explode("?@?", $todox);
        $ix = 0;
        while (!empty($todo[$ix]))
        {
           $cadapar = explode("?#?", $todo[$ix]);
           if (1 < sizeof($cadapar))
           {
               if (substr($cadapar[0], 0, 11) == "SC_glo_par_")
               {
                   $cadapar[0] = substr($cadapar[0], 11);
                   $cadapar[1] = $_SESSION[$cadapar[1]];
               }
               nm_limpa_str_app_Login($cadapar[1]);
               if (isset($sc_conv_var[$cadapar[0]]))
               {
                   $cadapar[0] = $sc_conv_var[$cadapar[0]];
               }
               elseif (isset($sc_conv_var[strtolower($cadapar[0])]))
               {
                   $cadapar[0] = $sc_conv_var[strtolower($cadapar[0])];
               }
               if ($cadapar[1] == "@ ") {$cadapar[1] = trim($cadapar[1]); }
               $Tmp_par   = $cadapar[0];
               $$Tmp_par = $cadapar[1];
           }
           $ix++;
        }
        if (isset($facebook_error_code)) 
        {
            $_SESSION['facebook_error_code'] = $facebook_error_code;
        }
        if (isset($facebook_error_msg)) 
        {
            $_SESSION['facebook_error_msg'] = $facebook_error_msg;
        }
        if (isset($facebook_user)) 
        {
            $_SESSION['facebook_user'] = $facebook_user;
        }
        if (isset($facebook_email)) 
        {
            $_SESSION['facebook_email'] = $facebook_email;
        }
        if (isset($facebook_name)) 
        {
            $_SESSION['facebook_name'] = $facebook_name;
        }
        if (isset($google_error_code)) 
        {
            $_SESSION['google_error_code'] = $google_error_code;
        }
        if (isset($google_error_msg)) 
        {
            $_SESSION['google_error_msg'] = $google_error_msg;
        }
        if (isset($google_user)) 
        {
            $_SESSION['google_user'] = $google_user;
        }
        if (isset($google_email)) 
        {
            $_SESSION['google_email'] = $google_email;
        }
        if (isset($google_name)) 
        {
            $_SESSION['google_name'] = $google_name;
        }
        if (isset($usr_login)) 
        {
            $_SESSION['usr_login'] = $usr_login;
        }
        if (isset($usr_email)) 
        {
            $_SESSION['usr_email'] = $usr_email;
        }
        if (isset($sett_remember_me)) 
        {
            $_SESSION['sett_remember_me'] = $sett_remember_me;
        }
        if (isset($sett_new_users)) 
        {
            $_SESSION['sett_new_users'] = $sett_new_users;
        }
        if (isset($sett_retrieve_password)) 
        {
            $_SESSION['sett_retrieve_password'] = $sett_retrieve_password;
        }
        if (isset($usr_priv_admin)) 
        {
            $_SESSION['usr_priv_admin'] = $usr_priv_admin;
        }
        if (isset($usr_name)) 
        {
            $_SESSION['usr_name'] = $usr_name;
        }
        if (isset($remember_me)) 
        {
            $_SESSION['remember_me'] = $remember_me;
        }
        if (isset($usr_grp)) 
        {
            $_SESSION['usr_grp'] = $usr_grp;
        }
        if (isset($usr_reset)) 
        {
            $_SESSION['usr_reset'] = $usr_reset;
        }
        if (isset($usr_tel)) 
        {
            $_SESSION['usr_tel'] = $usr_tel;
        }
        if (isset($usr_profession)) 
        {
            $_SESSION['usr_profession'] = $usr_profession;
        }
        if (isset($usr_sql)) 
        {
            $_SESSION['usr_sql'] = $usr_sql;
        }
        if (isset($usr_result)) 
        {
            $_SESSION['usr_result'] = $usr_result;
        }
        if (isset($group_name_permissions)) 
        {
            $_SESSION['group_name_permissions'] = $group_name_permissions;
        }
        if (isset($sett_enable_2fa)) 
        {
            $_SESSION['sett_enable_2fa'] = $sett_enable_2fa;
        }
        if (isset($selected_language)) 
        {
            $_SESSION['selected_language'] = $selected_language;
        }
        if (isset($usr_photo)) 
        {
            $_SESSION['usr_photo'] = $usr_photo;
        }
        if (isset($usr_fac)) 
        {
            $_SESSION['usr_fac'] = $usr_fac;
        }
        if (isset($usr_nfac)) 
        {
            $_SESSION['usr_nfac'] = $usr_nfac;
        }
        if (isset($usr_ngrp)) 
        {
            $_SESSION['usr_ngrp'] = $usr_ngrp;
        }
        if (isset($usr_statut)) 
        {
            $_SESSION['usr_statut'] = $usr_statut;
        }
        if (isset($usr_role)) 
        {
            $_SESSION['usr_role'] = $usr_role;
        }
        if (isset($usr_scope)) 
        {
            $_SESSION['usr_scope'] = $usr_scope;
        }
        if (isset($usr_mobile)) 
        {
            $_SESSION['usr_mobile'] = $usr_mobile;
        }
        if (isset($usr_wils_array)) 
        {
            $_SESSION['usr_wils_array'] = $usr_wils_array;
        }
        if (isset($usr_wils_sql)) 
        {
            $_SESSION['usr_wils_sql'] = $usr_wils_sql;
        }
        if (isset($sett_cookie_expiration_time)) 
        {
            $_SESSION['sett_cookie_expiration_time'] = $sett_cookie_expiration_time;
        }
        if (isset($sett_session_expire)) 
        {
            $_SESSION['sett_session_expire'] = $sett_session_expire;
        }
        if (isset($twitter_user)) 
        {
            $_SESSION['twitter_user'] = $twitter_user;
        }
        if (isset($twitter_email)) 
        {
            $_SESSION['twitter_email'] = $twitter_email;
        }
        if (isset($twitter_name)) 
        {
            $_SESSION['twitter_name'] = $twitter_name;
        }
        if (isset($var_app)) 
        {
            $_SESSION['var_app'] = $var_app;
        }
        if (isset($mobile_token)) 
        {
            $_SESSION['mobile_token'] = $mobile_token;
        }
        if (isset($var_dashboard_wilaya)) 
        {
            $_SESSION['var_dashboard_wilaya'] = $var_dashboard_wilaya;
        }
        if (isset($var_dashboard_semep)) 
        {
            $_SESSION['var_dashboard_semep'] = $var_dashboard_semep;
        }
        if (isset($wil_fac)) 
        {
            $_SESSION['wil_fac'] = $wil_fac;
        }
    } 
    elseif (isset($script_case_init) && !empty($script_case_init) && !is_array($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['app_Login']['parms']))
    {
        if (!isset($nmgp_opcao) || ($nmgp_opcao != "incluir" && $nmgp_opcao != "novo" && $nmgp_opcao != "recarga" && $nmgp_opcao != "muda_form"))
        {
            $todox = str_replace("?#?@?@?", "?#?@ ?@?", $_SESSION['sc_session'][$script_case_init]['app_Login']['parms']);
            $todo  = explode("?@?", $todox);
            $ix = 0;
            while (!empty($todo[$ix]))
            {
               $cadapar = explode("?#?", $todo[$ix]);
               if (substr($cadapar[0], 0, 11) == "SC_glo_par_")
               {
                   $cadapar[0] = substr($cadapar[0], 11);
                   $cadapar[1] = $_SESSION[$cadapar[1]];
               }
               if ($cadapar[1] == "@ ") {$cadapar[1] = trim($cadapar[1]); }
               $Tmp_par   = $cadapar[0];
               $$Tmp_par = $cadapar[1];
               $ix++;
            }
        }
    } 
    if (isset($script_case_init) && $script_case_init != preg_replace('/[^0-9.-]/', '', $script_case_init))
    {
        unset($script_case_init);
    }
    if (!isset($script_case_init) || empty($script_case_init) || is_array($script_case_init))
    {
        $script_case_init = rand(2, 10000);
    }
    $salva_run = "N";
    $salva_iframe = false;
    if (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu']))
    {
        $salva_iframe = $_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu'];
        unset($_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu']);
    }
    if (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe']))
    {
        $salva_run = $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'];
        unset($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe']);
    }
    if (isset($nm_run_menu) && $nm_run_menu == 1)
    {
        if (isset($_SESSION['scriptcase']['sc_aba_iframe']) && isset($_SESSION['scriptcase']['sc_apl_menu_atual']))
        {
            foreach ($_SESSION['scriptcase']['sc_aba_iframe'] as $aba => $apls_aba)
            {
                if ($aba == $_SESSION['scriptcase']['sc_apl_menu_atual'])
                {
                    unset($_SESSION['scriptcase']['sc_aba_iframe'][$aba]);
                    break;
                }
            }
        }
        $_SESSION['scriptcase']['sc_apl_menu_atual'] = "app_Login";
        $achou = false;
        if (isset($_SESSION['sc_session'][$script_case_init]))
        {
            foreach ($_SESSION['sc_session'][$script_case_init] as $nome_apl => $resto)
            {
                if ($nome_apl == 'app_Login' || $achou)
                {
                    unset($_SESSION['sc_session'][$script_case_init][$nome_apl]);
                    if (!empty($_SESSION['sc_session'][$script_case_init][$nome_apl]))
                    {
                        $achou = true;
                    }
                }
            }
            if (!$achou && isset($nm_apl_menu))
            {
                foreach ($_SESSION['sc_session'][$script_case_init] as $nome_apl => $resto)
                {
                    if ($nome_apl == $nm_apl_menu || $achou)
                    {
                        $achou = true;
                        if ($nome_apl != $nm_apl_menu)
                        {
                            unset($_SESSION['sc_session'][$script_case_init][$nome_apl]);
                        }
                    }
                }
            }
        }
        $_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu']  = true;
        $_SESSION['sc_session'][$script_case_init]['app_Login']['mostra_cab']   = "S";
        $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe']   = "N";
        $_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'] = "";
    }
    else
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe']  = $salva_run;
        $_SESSION['sc_session'][$script_case_init]['app_Login']['iframe_menu'] = $salva_iframe;
    }

    if (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['db_changed']))
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['db_changed'] = false;
    }
    if (isset($_GET['nmgp_outra_jan']) && 'true' == $_GET['nmgp_outra_jan'] && isset($_GET['nmgp_url_saida']) && 'modal' == $_GET['nmgp_url_saida'])
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['db_changed'] = false;
    }

    if (isset($_SESSION['scriptcase']['sc_outra_jan']) && $_SESSION['scriptcase']['sc_outra_jan'] == 'app_Login')
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'] = true;
         unset($_SESSION['scriptcase']['sc_outra_jan']);
    }
    if (isset($nmgp_outra_jan) && $nmgp_outra_jan == 'true')
    {
        if (isset($nmgp_url_saida) && $nmgp_url_saida == "modal")
        {
            $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_modal'] = true;
            $nm_url_saida = "app_Login_fim.php"; 
        }
        $nm_apl_dependente = 0;
        $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'] = true;
    }
    if (!isset($nm_apl_dependente)) {
        $nm_apl_dependente = 0;
    }

    if (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['initialize']))
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['initialize'] = true;
    }
    elseif (!isset($_SERVER['HTTP_REFERER']))
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['initialize'] = false;
    }
    elseif (false === strpos($_SERVER['HTTP_REFERER'], '.php'))
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['initialize'] = true;
    }
    else
    {
        $sReferer = substr($_SERVER['HTTP_REFERER'], 0, strpos($_SERVER['HTTP_REFERER'], '.php'));
        $sReferer = substr($sReferer, strrpos($sReferer, '/') + 1);
        if ('app_Login' == $sReferer || 'app_Login_' == substr($sReferer, 0, 10))
        {
            $_SESSION['sc_session'][$script_case_init]['app_Login']['initialize'] = false;
        }
        else
        {
            $_SESSION['sc_session'][$script_case_init]['app_Login']['initialize'] = true;
        }
    }

    if (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['first_time']))
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['first_time'] = false;
    }
    else
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['first_time'] = true;
    }

    $_SESSION['sc_session'][$script_case_init]['app_Login']['menu_desenv'] = false;   
    if (!defined("SC_ERROR_HANDLER"))
    {
        define("SC_ERROR_HANDLER", 1);
    }
    include_once(dirname(__FILE__) . "/app_Login_erro.php");
    $nm_browser = strpos($_SERVER['HTTP_USER_AGENT'], "Konqueror") ;
    if (is_int($nm_browser))   
    {
        $nm_browser = "Konqueror"; 
    } 
    else  
    {
        $nm_browser = strpos($_SERVER['HTTP_USER_AGENT'], "Opera") ;
        if (is_int($nm_browser))   
        {
            $nm_browser = "Opera"; 
        }
    } 
    $_SESSION['scriptcase']['change_regional_old'] = '';
    $_SESSION['scriptcase']['change_regional_new'] = '';
    if (!empty($nmgp_opcao) && ($nmgp_opcao == "change_lang_t" || $nmgp_opcao == "change_lang_b" || $nmgp_opcao == "change_lang_f" || $nmgp_opcao == "force_lang"))  
    {
        $Temp_lang = $nmgp_opcao == "force_lang" ? explode(";" , $nmgp_idioma) : explode(";" , $nmgp_idioma_novo);  
        if (isset($Temp_lang[0]) && !empty($Temp_lang[0]))  
        { 
            $_SESSION['scriptcase']['str_lang'] = $Temp_lang[0];
        } 
        if (isset($Temp_lang[1]) && !empty($Temp_lang[1])) 
        { 
            $_SESSION['scriptcase']['change_regional_old'] = (isset($_SESSION['scriptcase']['str_conf_reg']) && !empty($_SESSION['scriptcase']['str_conf_reg'])) ? $_SESSION['scriptcase']['str_conf_reg'] : "fr_fr";
            $_SESSION['scriptcase']['str_conf_reg']        = $Temp_lang[1];
            $_SESSION['scriptcase']['change_regional_new'] = $_SESSION['scriptcase']['str_conf_reg'];
        } 
        $nmgp_opcao = $nmgp_opcao == "force_lang" ? "inicio" : "recarga";
    } 
    if (!empty($nmgp_opcao) && ($nmgp_opcao == "change_schema_t" || $nmgp_opcao == "change_schema_b" || $nmgp_opcao == "change_schema_f"))  
    {
        if ($nmgp_opcao == "change_schema_t")  
        {
            $nmgp_schema = $nmgp_schema_t . "/" . $nmgp_schema_t;  
        } 
        elseif ($nmgp_opcao == "change_schema_b")  
        {
            $nmgp_schema = $nmgp_schema_b . "/" . $nmgp_schema_b;  
        } 
        else 
        {
            $nmgp_schema = $nmgp_schema_f . "/" . $nmgp_schema_f;  
        } 
        $_SESSION['scriptcase']['str_schema_all'] = $nmgp_schema;
        $nmgp_opcao = "recarga";  
    } 
    if (!empty($nmgp_opcao) && $nmgp_opcao == "lookup")  
    {
        $nm_opc_lookup = $nmgp_opcao;
    }
    elseif (!empty($nmgp_opcao) && $nmgp_opcao == "formphp")  
    {
        $nm_opc_form_php = $nmgp_opcao;
    }
    else
    {
        if (!empty($nmgp_opcao))  
        {
            $_SESSION['sc_session'][$script_case_init]['app_Login']['opcao'] = $nmgp_opcao ; 
        }
        if (isset($_POST["facebook_error_code"])) 
        {
            $_SESSION['facebook_error_code'] = $_POST["facebook_error_code"];
            nm_limpa_str_app_Login($_SESSION['facebook_error_code']);
        }
        if (isset($_GET["facebook_error_code"])) 
        {
            $_SESSION['facebook_error_code'] = $_GET["facebook_error_code"];
            nm_limpa_str_app_Login($_SESSION['facebook_error_code']);
        }
        if (isset($_POST["facebook_error_msg"])) 
        {
            $_SESSION['facebook_error_msg'] = $_POST["facebook_error_msg"];
            nm_limpa_str_app_Login($_SESSION['facebook_error_msg']);
        }
        if (isset($_GET["facebook_error_msg"])) 
        {
            $_SESSION['facebook_error_msg'] = $_GET["facebook_error_msg"];
            nm_limpa_str_app_Login($_SESSION['facebook_error_msg']);
        }
        if (isset($_POST["facebook_user"])) 
        {
            $_SESSION['facebook_user'] = $_POST["facebook_user"];
            nm_limpa_str_app_Login($_SESSION['facebook_user']);
        }
        if (isset($_GET["facebook_user"])) 
        {
            $_SESSION['facebook_user'] = $_GET["facebook_user"];
            nm_limpa_str_app_Login($_SESSION['facebook_user']);
        }
        if (isset($_POST["facebook_email"])) 
        {
            $_SESSION['facebook_email'] = $_POST["facebook_email"];
            nm_limpa_str_app_Login($_SESSION['facebook_email']);
        }
        if (isset($_GET["facebook_email"])) 
        {
            $_SESSION['facebook_email'] = $_GET["facebook_email"];
            nm_limpa_str_app_Login($_SESSION['facebook_email']);
        }
        if (isset($_POST["facebook_name"])) 
        {
            $_SESSION['facebook_name'] = $_POST["facebook_name"];
            nm_limpa_str_app_Login($_SESSION['facebook_name']);
        }
        if (isset($_GET["facebook_name"])) 
        {
            $_SESSION['facebook_name'] = $_GET["facebook_name"];
            nm_limpa_str_app_Login($_SESSION['facebook_name']);
        }
        if (isset($_POST["google_error_code"])) 
        {
            $_SESSION['google_error_code'] = $_POST["google_error_code"];
            nm_limpa_str_app_Login($_SESSION['google_error_code']);
        }
        if (isset($_GET["google_error_code"])) 
        {
            $_SESSION['google_error_code'] = $_GET["google_error_code"];
            nm_limpa_str_app_Login($_SESSION['google_error_code']);
        }
        if (isset($_POST["google_error_msg"])) 
        {
            $_SESSION['google_error_msg'] = $_POST["google_error_msg"];
            nm_limpa_str_app_Login($_SESSION['google_error_msg']);
        }
        if (isset($_GET["google_error_msg"])) 
        {
            $_SESSION['google_error_msg'] = $_GET["google_error_msg"];
            nm_limpa_str_app_Login($_SESSION['google_error_msg']);
        }
        if (isset($_POST["google_user"])) 
        {
            $_SESSION['google_user'] = $_POST["google_user"];
            nm_limpa_str_app_Login($_SESSION['google_user']);
        }
        if (isset($_GET["google_user"])) 
        {
            $_SESSION['google_user'] = $_GET["google_user"];
            nm_limpa_str_app_Login($_SESSION['google_user']);
        }
        if (isset($_POST["google_email"])) 
        {
            $_SESSION['google_email'] = $_POST["google_email"];
            nm_limpa_str_app_Login($_SESSION['google_email']);
        }
        if (isset($_GET["google_email"])) 
        {
            $_SESSION['google_email'] = $_GET["google_email"];
            nm_limpa_str_app_Login($_SESSION['google_email']);
        }
        if (isset($_POST["google_name"])) 
        {
            $_SESSION['google_name'] = $_POST["google_name"];
            nm_limpa_str_app_Login($_SESSION['google_name']);
        }
        if (isset($_GET["google_name"])) 
        {
            $_SESSION['google_name'] = $_GET["google_name"];
            nm_limpa_str_app_Login($_SESSION['google_name']);
        }
        if (isset($_POST["usr_login"])) 
        {
            $_SESSION['usr_login'] = $_POST["usr_login"];
            nm_limpa_str_app_Login($_SESSION['usr_login']);
        }
        if (isset($_GET["usr_login"])) 
        {
            $_SESSION['usr_login'] = $_GET["usr_login"];
            nm_limpa_str_app_Login($_SESSION['usr_login']);
        }
        if (isset($_POST["usr_email"])) 
        {
            $_SESSION['usr_email'] = $_POST["usr_email"];
            nm_limpa_str_app_Login($_SESSION['usr_email']);
        }
        if (isset($_GET["usr_email"])) 
        {
            $_SESSION['usr_email'] = $_GET["usr_email"];
            nm_limpa_str_app_Login($_SESSION['usr_email']);
        }
        if (isset($_POST["sett_remember_me"])) 
        {
            $_SESSION['sett_remember_me'] = $_POST["sett_remember_me"];
            nm_limpa_str_app_Login($_SESSION['sett_remember_me']);
        }
        if (isset($_GET["sett_remember_me"])) 
        {
            $_SESSION['sett_remember_me'] = $_GET["sett_remember_me"];
            nm_limpa_str_app_Login($_SESSION['sett_remember_me']);
        }
        if (isset($_POST["sett_new_users"])) 
        {
            $_SESSION['sett_new_users'] = $_POST["sett_new_users"];
            nm_limpa_str_app_Login($_SESSION['sett_new_users']);
        }
        if (isset($_GET["sett_new_users"])) 
        {
            $_SESSION['sett_new_users'] = $_GET["sett_new_users"];
            nm_limpa_str_app_Login($_SESSION['sett_new_users']);
        }
        if (isset($_POST["sett_retrieve_password"])) 
        {
            $_SESSION['sett_retrieve_password'] = $_POST["sett_retrieve_password"];
            nm_limpa_str_app_Login($_SESSION['sett_retrieve_password']);
        }
        if (isset($_GET["sett_retrieve_password"])) 
        {
            $_SESSION['sett_retrieve_password'] = $_GET["sett_retrieve_password"];
            nm_limpa_str_app_Login($_SESSION['sett_retrieve_password']);
        }
        if (isset($_POST["usr_priv_admin"])) 
        {
            $_SESSION['usr_priv_admin'] = $_POST["usr_priv_admin"];
            nm_limpa_str_app_Login($_SESSION['usr_priv_admin']);
        }
        if (isset($_GET["usr_priv_admin"])) 
        {
            $_SESSION['usr_priv_admin'] = $_GET["usr_priv_admin"];
            nm_limpa_str_app_Login($_SESSION['usr_priv_admin']);
        }
        if (isset($_POST["usr_name"])) 
        {
            $_SESSION['usr_name'] = $_POST["usr_name"];
            nm_limpa_str_app_Login($_SESSION['usr_name']);
        }
        if (isset($_GET["usr_name"])) 
        {
            $_SESSION['usr_name'] = $_GET["usr_name"];
            nm_limpa_str_app_Login($_SESSION['usr_name']);
        }
        if (isset($_POST["remember_me"])) 
        {
            $_SESSION['remember_me'] = $_POST["remember_me"];
            nm_limpa_str_app_Login($_SESSION['remember_me']);
        }
        if (isset($_GET["remember_me"])) 
        {
            $_SESSION['remember_me'] = $_GET["remember_me"];
            nm_limpa_str_app_Login($_SESSION['remember_me']);
        }
        if (isset($_POST["usr_grp"])) 
        {
            $_SESSION['usr_grp'] = $_POST["usr_grp"];
            nm_limpa_str_app_Login($_SESSION['usr_grp']);
        }
        if (isset($_GET["usr_grp"])) 
        {
            $_SESSION['usr_grp'] = $_GET["usr_grp"];
            nm_limpa_str_app_Login($_SESSION['usr_grp']);
        }
        if (isset($_POST["usr_reset"])) 
        {
            $_SESSION['usr_reset'] = $_POST["usr_reset"];
            nm_limpa_str_app_Login($_SESSION['usr_reset']);
        }
        if (isset($_GET["usr_reset"])) 
        {
            $_SESSION['usr_reset'] = $_GET["usr_reset"];
            nm_limpa_str_app_Login($_SESSION['usr_reset']);
        }
        if (isset($_POST["usr_tel"])) 
        {
            $_SESSION['usr_tel'] = $_POST["usr_tel"];
            nm_limpa_str_app_Login($_SESSION['usr_tel']);
        }
        if (isset($_GET["usr_tel"])) 
        {
            $_SESSION['usr_tel'] = $_GET["usr_tel"];
            nm_limpa_str_app_Login($_SESSION['usr_tel']);
        }
        if (isset($_POST["usr_profession"])) 
        {
            $_SESSION['usr_profession'] = $_POST["usr_profession"];
            nm_limpa_str_app_Login($_SESSION['usr_profession']);
        }
        if (isset($_GET["usr_profession"])) 
        {
            $_SESSION['usr_profession'] = $_GET["usr_profession"];
            nm_limpa_str_app_Login($_SESSION['usr_profession']);
        }
        if (isset($_POST["usr_sql"])) 
        {
            $_SESSION['usr_sql'] = $_POST["usr_sql"];
            nm_limpa_str_app_Login($_SESSION['usr_sql']);
        }
        if (isset($_GET["usr_sql"])) 
        {
            $_SESSION['usr_sql'] = $_GET["usr_sql"];
            nm_limpa_str_app_Login($_SESSION['usr_sql']);
        }
        if (isset($_POST["usr_result"])) 
        {
            $_SESSION['usr_result'] = $_POST["usr_result"];
            nm_limpa_str_app_Login($_SESSION['usr_result']);
        }
        if (isset($_GET["usr_result"])) 
        {
            $_SESSION['usr_result'] = $_GET["usr_result"];
            nm_limpa_str_app_Login($_SESSION['usr_result']);
        }
        if (isset($_POST["group_name_permissions"])) 
        {
            $_SESSION['group_name_permissions'] = $_POST["group_name_permissions"];
            nm_limpa_str_app_Login($_SESSION['group_name_permissions']);
        }
        if (isset($_GET["group_name_permissions"])) 
        {
            $_SESSION['group_name_permissions'] = $_GET["group_name_permissions"];
            nm_limpa_str_app_Login($_SESSION['group_name_permissions']);
        }
        if (isset($_POST["sett_enable_2fa"])) 
        {
            $_SESSION['sett_enable_2fa'] = $_POST["sett_enable_2fa"];
            nm_limpa_str_app_Login($_SESSION['sett_enable_2fa']);
        }
        if (isset($_GET["sett_enable_2fa"])) 
        {
            $_SESSION['sett_enable_2fa'] = $_GET["sett_enable_2fa"];
            nm_limpa_str_app_Login($_SESSION['sett_enable_2fa']);
        }
        if (isset($_POST["selected_language"])) 
        {
            $_SESSION['selected_language'] = $_POST["selected_language"];
            nm_limpa_str_app_Login($_SESSION['selected_language']);
        }
        if (isset($_GET["selected_language"])) 
        {
            $_SESSION['selected_language'] = $_GET["selected_language"];
            nm_limpa_str_app_Login($_SESSION['selected_language']);
        }
        if (isset($_POST["usr_photo"])) 
        {
            $_SESSION['usr_photo'] = $_POST["usr_photo"];
            nm_limpa_str_app_Login($_SESSION['usr_photo']);
        }
        if (isset($_GET["usr_photo"])) 
        {
            $_SESSION['usr_photo'] = $_GET["usr_photo"];
            nm_limpa_str_app_Login($_SESSION['usr_photo']);
        }
        if (isset($_POST["usr_fac"])) 
        {
            $_SESSION['usr_fac'] = $_POST["usr_fac"];
            nm_limpa_str_app_Login($_SESSION['usr_fac']);
        }
        if (isset($_GET["usr_fac"])) 
        {
            $_SESSION['usr_fac'] = $_GET["usr_fac"];
            nm_limpa_str_app_Login($_SESSION['usr_fac']);
        }
        if (isset($_POST["usr_nfac"])) 
        {
            $_SESSION['usr_nfac'] = $_POST["usr_nfac"];
            nm_limpa_str_app_Login($_SESSION['usr_nfac']);
        }
        if (isset($_GET["usr_nfac"])) 
        {
            $_SESSION['usr_nfac'] = $_GET["usr_nfac"];
            nm_limpa_str_app_Login($_SESSION['usr_nfac']);
        }
        if (isset($_POST["usr_ngrp"])) 
        {
            $_SESSION['usr_ngrp'] = $_POST["usr_ngrp"];
            nm_limpa_str_app_Login($_SESSION['usr_ngrp']);
        }
        if (isset($_GET["usr_ngrp"])) 
        {
            $_SESSION['usr_ngrp'] = $_GET["usr_ngrp"];
            nm_limpa_str_app_Login($_SESSION['usr_ngrp']);
        }
        if (isset($_POST["usr_statut"])) 
        {
            $_SESSION['usr_statut'] = $_POST["usr_statut"];
            nm_limpa_str_app_Login($_SESSION['usr_statut']);
        }
        if (isset($_GET["usr_statut"])) 
        {
            $_SESSION['usr_statut'] = $_GET["usr_statut"];
            nm_limpa_str_app_Login($_SESSION['usr_statut']);
        }
        if (isset($_POST["usr_role"])) 
        {
            $_SESSION['usr_role'] = $_POST["usr_role"];
            nm_limpa_str_app_Login($_SESSION['usr_role']);
        }
        if (isset($_GET["usr_role"])) 
        {
            $_SESSION['usr_role'] = $_GET["usr_role"];
            nm_limpa_str_app_Login($_SESSION['usr_role']);
        }
        if (isset($_POST["usr_scope"])) 
        {
            $_SESSION['usr_scope'] = $_POST["usr_scope"];
            nm_limpa_str_app_Login($_SESSION['usr_scope']);
        }
        if (isset($_GET["usr_scope"])) 
        {
            $_SESSION['usr_scope'] = $_GET["usr_scope"];
            nm_limpa_str_app_Login($_SESSION['usr_scope']);
        }
        if (isset($_POST["usr_mobile"])) 
        {
            $_SESSION['usr_mobile'] = $_POST["usr_mobile"];
            nm_limpa_str_app_Login($_SESSION['usr_mobile']);
        }
        if (isset($_GET["usr_mobile"])) 
        {
            $_SESSION['usr_mobile'] = $_GET["usr_mobile"];
            nm_limpa_str_app_Login($_SESSION['usr_mobile']);
        }
        if (isset($_POST["usr_wils_array"])) 
        {
            $_SESSION['usr_wils_array'] = $_POST["usr_wils_array"];
            nm_limpa_str_app_Login($_SESSION['usr_wils_array']);
        }
        if (isset($_GET["usr_wils_array"])) 
        {
            $_SESSION['usr_wils_array'] = $_GET["usr_wils_array"];
            nm_limpa_str_app_Login($_SESSION['usr_wils_array']);
        }
        if (isset($_POST["usr_wils_sql"])) 
        {
            $_SESSION['usr_wils_sql'] = $_POST["usr_wils_sql"];
            nm_limpa_str_app_Login($_SESSION['usr_wils_sql']);
        }
        if (isset($_GET["usr_wils_sql"])) 
        {
            $_SESSION['usr_wils_sql'] = $_GET["usr_wils_sql"];
            nm_limpa_str_app_Login($_SESSION['usr_wils_sql']);
        }
        if (isset($_POST["sett_cookie_expiration_time"])) 
        {
            $_SESSION['sett_cookie_expiration_time'] = $_POST["sett_cookie_expiration_time"];
            nm_limpa_str_app_Login($_SESSION['sett_cookie_expiration_time']);
        }
        if (isset($_GET["sett_cookie_expiration_time"])) 
        {
            $_SESSION['sett_cookie_expiration_time'] = $_GET["sett_cookie_expiration_time"];
            nm_limpa_str_app_Login($_SESSION['sett_cookie_expiration_time']);
        }
        if (isset($_POST["sett_session_expire"])) 
        {
            $_SESSION['sett_session_expire'] = $_POST["sett_session_expire"];
            nm_limpa_str_app_Login($_SESSION['sett_session_expire']);
        }
        if (isset($_GET["sett_session_expire"])) 
        {
            $_SESSION['sett_session_expire'] = $_GET["sett_session_expire"];
            nm_limpa_str_app_Login($_SESSION['sett_session_expire']);
        }
        if (isset($_POST["twitter_user"])) 
        {
            $_SESSION['twitter_user'] = $_POST["twitter_user"];
            nm_limpa_str_app_Login($_SESSION['twitter_user']);
        }
        if (isset($_GET["twitter_user"])) 
        {
            $_SESSION['twitter_user'] = $_GET["twitter_user"];
            nm_limpa_str_app_Login($_SESSION['twitter_user']);
        }
        if (isset($_POST["twitter_email"])) 
        {
            $_SESSION['twitter_email'] = $_POST["twitter_email"];
            nm_limpa_str_app_Login($_SESSION['twitter_email']);
        }
        if (isset($_GET["twitter_email"])) 
        {
            $_SESSION['twitter_email'] = $_GET["twitter_email"];
            nm_limpa_str_app_Login($_SESSION['twitter_email']);
        }
        if (isset($_POST["twitter_name"])) 
        {
            $_SESSION['twitter_name'] = $_POST["twitter_name"];
            nm_limpa_str_app_Login($_SESSION['twitter_name']);
        }
        if (isset($_GET["twitter_name"])) 
        {
            $_SESSION['twitter_name'] = $_GET["twitter_name"];
            nm_limpa_str_app_Login($_SESSION['twitter_name']);
        }
        if (isset($_POST["var_app"])) 
        {
            $_SESSION['var_app'] = $_POST["var_app"];
            nm_limpa_str_app_Login($_SESSION['var_app']);
        }
        if (isset($_GET["var_app"])) 
        {
            $_SESSION['var_app'] = $_GET["var_app"];
            nm_limpa_str_app_Login($_SESSION['var_app']);
        }
        if (isset($_POST["mobile_token"])) 
        {
            $_SESSION['mobile_token'] = $_POST["mobile_token"];
            nm_limpa_str_app_Login($_SESSION['mobile_token']);
        }
        if (isset($_GET["mobile_token"])) 
        {
            $_SESSION['mobile_token'] = $_GET["mobile_token"];
            nm_limpa_str_app_Login($_SESSION['mobile_token']);
        }
        if (isset($_POST["var_dashboard_wilaya"])) 
        {
            $_SESSION['var_dashboard_wilaya'] = $_POST["var_dashboard_wilaya"];
            nm_limpa_str_app_Login($_SESSION['var_dashboard_wilaya']);
        }
        if (isset($_GET["var_dashboard_wilaya"])) 
        {
            $_SESSION['var_dashboard_wilaya'] = $_GET["var_dashboard_wilaya"];
            nm_limpa_str_app_Login($_SESSION['var_dashboard_wilaya']);
        }
        if (isset($_POST["var_dashboard_semep"])) 
        {
            $_SESSION['var_dashboard_semep'] = $_POST["var_dashboard_semep"];
            nm_limpa_str_app_Login($_SESSION['var_dashboard_semep']);
        }
        if (isset($_GET["var_dashboard_semep"])) 
        {
            $_SESSION['var_dashboard_semep'] = $_GET["var_dashboard_semep"];
            nm_limpa_str_app_Login($_SESSION['var_dashboard_semep']);
        }
        if (isset($_POST["wil_fac"])) 
        {
            $_SESSION['wil_fac'] = $_POST["wil_fac"];
            nm_limpa_str_app_Login($_SESSION['wil_fac']);
        }
        if (isset($_GET["wil_fac"])) 
        {
            $_SESSION['wil_fac'] = $_GET["wil_fac"];
            nm_limpa_str_app_Login($_SESSION['wil_fac']);
        }
        if (!empty($_SESSION['sc_session'][$script_case_init]['app_Login']['volta_redirect_apl']))
        {
            $_SESSION['scriptcase']['sc_url_saida'][$script_case_init] = $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_redirect_apl']; 
            $nm_apl_dependente = $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_redirect_tp']; 
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_redirect_apl'] = "";
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_redirect_tp'] = "";
            $nm_url_saida = "app_Login_fim.php"; 
        }
        elseif (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan']) && $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'] == 'true')
        {
               $nm_url_saida = "app_Login_fim.php"; 
        }
        elseif ($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "F" && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "R")
        {
           $nm_url_saida = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""; 
           $nm_url_saida = str_replace("_fim.php", ".php", $nm_url_saida); 
            $nm_saida_global = $nm_url_saida;
            if (!empty($nmgp_url_saida) && empty($_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'])) 
            {
                $_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'] = $nmgp_url_saida ; 
            } 
            if (!empty($_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'])) 
            {
                $nm_url_saida = $_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'] . "?script_case_init=" . $script_case_init;  
                $nm_apl_dependente = 1 ; 
                $nm_saida_global = $nm_url_saida;
            } 
            if ($nm_apl_dependente != 1) 
            { 
                $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] = "N"; 
            } 
            if ($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "F" && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "R" && (!isset($_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_call']) || !$_SESSION['sc_session'][$script_case_init]['app_Login']['embutida_call']))
            { 
                $_SESSION['scriptcase']['sc_url_saida'][$script_case_init] = $nm_url_saida; 
                $nm_url_saida = "app_Login_fim.php"; 
                $_SESSION['scriptcase']['sc_tp_saida'] = "P"; 
                if ($nm_apl_dependente == 1) 
                { 
                    $_SESSION['scriptcase']['sc_tp_saida'] = "D"; 
                } 
                if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno']) && $nm_apl_dependente != 1) 
                { 
                    $_SESSION['scriptcase']['sc_url_saida'][$script_case_init] = $_SESSION['scriptcase']['nm_sc_retorno']; 
                } 
            } 
        }
        if (empty($_SESSION['sc_session'][$script_case_init]['app_Login']['volta_tp']) && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "F" && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "R")
        {
            if (!isset($nm_saida_global)) {
                $nm_saida_global = $nm_url_saida;
            }
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_php'] = $nm_url_saida;
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_apl'] = $nm_saida_global;
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_ss']  = (isset($_SESSION['scriptcase']['sc_url_saida'][$script_case_init])) ? $_SESSION['scriptcase']['sc_url_saida'][$script_case_init] : "";
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_dep'] = (isset($nm_apl_dependente)) ? $nm_apl_dependente : "";
            $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_tp']  = (isset($_SESSION['scriptcase']['sc_tp_saida'])) ? $_SESSION['scriptcase']['sc_tp_saida'] : "";
        }
        $nm_url_saida      = (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['volta_php'])) ? $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_php'] : "";
        $nm_apl_dependente = (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['volta_dep'])) ? $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_dep'] : "";
        $nm_saida_global   = $nm_url_saida;
        if ($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "F" && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "R" && !empty($_SESSION['sc_session'][$script_case_init]['app_Login']['volta_ss'])) 
        { 
            $_SESSION['scriptcase']['sc_url_saida'][$script_case_init] = $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_ss'];
            $_SESSION['scriptcase']['sc_tp_saida']  = $_SESSION['sc_session'][$script_case_init]['app_Login']['volta_tp'];
        } 
        if ($_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] == "F" || $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] == "R") 
        { 
            if (!empty($nmgp_url_saida) && empty($_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'])) 
            {
                $_SESSION['sc_session'][$script_case_init]['app_Login']['retorno_edit'] = $nmgp_url_saida . "?script_case_init=" . $script_case_init; 
            } 
        } 
        if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno']) && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "F" && $_SESSION['sc_session'][$script_case_init]['app_Login']['run_iframe'] != "R") 
        { 
            $_SESSION['sc_session'][$script_case_init]['app_Login']['menu_desenv'] = true;   
        } 
    }
    if (isset($nmgp_redir)) 
    { 
        $_SESSION['sc_session'][$script_case_init]['app_Login']['redir'] = $nmgp_redir;   
    } 
    if (isset($nmgp_outra_jan) && $nmgp_outra_jan == 'true')
    {
        $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'] = true;
         if (isset($nmgp_url_saida) && $nmgp_url_saida == "modal")
         {
             $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_modal'] = true;
             $nm_url_saida = "app_Login_fim.php"; 
         }
    }
    if (isset($_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan']) && $_SESSION['sc_session'][$script_case_init]['app_Login']['sc_outra_jan'])
    {
        $nm_apl_dependente = 0;
    }
    $GLOBALS["NM_ERRO_IBASE"] = 0;  
    $inicial_app_Login = new app_Login_edit();
    $inicial_app_Login->inicializa();

    $inicial_app_Login->contr_app_Login->NM_ajax_info['select_html'] = array();
    $inicial_app_Login->contr_app_Login->NM_ajax_info['select_html']['remember_me'] = " onClick=\"\" ";

    if (!defined('SC_SAJAX_LOADED'))
    {
        include_once(dirname(__FILE__) . '/app_Login_sajax.php');
        define('SC_SAJAX_LOADED', 'YES');
    }
    if (!class_exists('Services_JSON'))
    {
        include_once(dirname(__FILE__) . '/app_Login_json.php');
    }
    $sajax_request_type = "POST";
    sajax_init();
    //$sajax_debug_mode = 1;
    sajax_export("ajax_app_Login_validate_login");
    sajax_export("ajax_app_Login_validate_pswd");
    sajax_export("ajax_app_Login_validate_new_user");
    sajax_export("ajax_app_Login_validate_remember_me");
    sajax_export("ajax_app_Login_validate_retrieve_pswd");
    sajax_export("ajax_app_Login_submit_form");
    sajax_export("ajax_app_Login_navigate_form");
    sajax_handle_client_request();

    if (isset($_POST['wizard_action']) && 'change_step' == $_POST['wizard_action']) {
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'] = true;
        ob_start();
    }

    $inicial_app_Login->contr_app_Login->controle();
//
    function nm_limpa_str_app_Login(&$str)
    {
    }

    function ajax_app_Login_validate_login($login, $script_case_init)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'validate_login';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'login' => NM_utf8_urldecode($login),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_validate_login

    function ajax_app_Login_validate_pswd($pswd, $script_case_init)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'validate_pswd';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'pswd' => NM_utf8_urldecode($pswd),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_validate_pswd

    function ajax_app_Login_validate_new_user($new_user, $script_case_init)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'validate_new_user';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'new_user' => NM_utf8_urldecode($new_user),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_validate_new_user

    function ajax_app_Login_validate_remember_me($remember_me, $script_case_init)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'validate_remember_me';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'remember_me' => NM_utf8_urldecode($remember_me),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_validate_remember_me

    function ajax_app_Login_validate_retrieve_pswd($retrieve_pswd, $script_case_init)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'validate_retrieve_pswd';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'retrieve_pswd' => NM_utf8_urldecode($retrieve_pswd),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_validate_retrieve_pswd

    function ajax_app_Login_submit_form($login, $pswd, $new_user, $remember_me, $retrieve_pswd, $new_user_sc_target_name, $retrieve_pswd_sc_target_name, $nm_form_submit, $nmgp_url_saida, $nmgp_opcao, $nmgp_ancora, $nmgp_num_form, $nmgp_parms, $script_case_init, $csrf_token, $bok)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'submit_form';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'login' => NM_utf8_urldecode($login),
                  'pswd' => NM_utf8_urldecode($pswd),
                  'new_user' => NM_utf8_urldecode($new_user),
                  'remember_me' => NM_utf8_urldecode($remember_me),
                  'retrieve_pswd' => NM_utf8_urldecode($retrieve_pswd),
                  'new_user_sc_target_name' => NM_utf8_urldecode($new_user_sc_target_name),
                  'retrieve_pswd_sc_target_name' => NM_utf8_urldecode($retrieve_pswd_sc_target_name),
                  'nm_form_submit' => NM_utf8_urldecode($nm_form_submit),
                  'nmgp_url_saida' => NM_utf8_urldecode($nmgp_url_saida),
                  'nmgp_opcao' => NM_utf8_urldecode($nmgp_opcao),
                  'nmgp_ancora' => NM_utf8_urldecode($nmgp_ancora),
                  'nmgp_num_form' => NM_utf8_urldecode($nmgp_num_form),
                  'nmgp_parms' => NM_utf8_urldecode($nmgp_parms),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'csrf_token' => NM_utf8_urldecode($csrf_token),
                  'bok' => NM_utf8_urldecode($bok),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_submit_form

    function ajax_app_Login_navigate_form($nm_form_submit, $nmgp_opcao, $nmgp_ordem, $nmgp_arg_dyn_search, $script_case_init)
    {
        global $inicial_app_Login;
        //register_shutdown_function("app_Login_pack_ajax_response");
        $inicial_app_Login->contr_app_Login->NM_ajax_flag          = true;
        $inicial_app_Login->contr_app_Login->NM_ajax_opcao         = 'navigate_form';
        $inicial_app_Login->contr_app_Login->NM_ajax_info['param'] = array(
                  'nm_form_submit' => NM_utf8_urldecode($nm_form_submit),
                  'nmgp_opcao' => NM_utf8_urldecode($nmgp_opcao),
                  'nmgp_ordem' => NM_utf8_urldecode($nmgp_ordem),
                  'nmgp_arg_dyn_search' => NM_utf8_urldecode($nmgp_arg_dyn_search),
                  'script_case_init' => NM_utf8_urldecode($script_case_init),
                  'buffer_output' => true,
                 );
        if ($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
        {
            ob_start();
        }
        $inicial_app_Login->contr_app_Login->controle();
        exit;
    } // ajax_navigate_form


   function app_Login_pack_ajax_response()
   {
      global $inicial_app_Login;
      $aResp = array();

      if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['wizard']))
      {
          $aResp['wizard'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['wizard'];
      }
      if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['empty_filter']))
      {
          $aResp['empty_filter'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['empty_filter'];
      }
      if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['dyn_search']['NM_Dynamic_Search']))
      {
          $aResp['dyn_search']['NM_Dynamic_Search'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['dyn_search']['NM_Dynamic_Search'];
      }
      if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['dyn_search']['id_dyn_search_cmd_str']))
      {
          $aResp['dyn_search']['id_dyn_search_cmd_str'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['dyn_search']['id_dyn_search_cmd_str'];
      }
      if ($inicial_app_Login->contr_app_Login->NM_ajax_info['calendarReload'])
      {
         $aResp['result'] = 'CALENDARRELOAD';
      }
      elseif ('' != $inicial_app_Login->contr_app_Login->NM_ajax_info['autoComp'])
      {
         $aResp['result'] = 'AUTOCOMP';
      }
//mestre_detalhe
      elseif (!empty($inicial_app_Login->contr_app_Login->NM_ajax_info['newline']))
      {
         $aResp['result'] = 'NEWLINE';
         ob_end_clean();
      }
      elseif (!empty($inicial_app_Login->contr_app_Login->NM_ajax_info['tableRefresh']))
      {
         $aResp['result'] = 'TABLEREFRESH';
      }
//-----
      elseif (!empty($inicial_app_Login->contr_app_Login->NM_ajax_info['errList']))
      {
         $aResp['result'] = 'ERROR';
      }
      elseif (!empty($inicial_app_Login->contr_app_Login->NM_ajax_info['fldList']))
      {
         $aResp['result'] = 'SET';
      }
      else
      {
         $aResp['result'] = 'OK';
      }
      if ('AUTOCOMP' == $aResp['result'])
      {
         $aResp = $inicial_app_Login->contr_app_Login->NM_ajax_info['autoComp'];
      }
//mestre_detalhe
      elseif ('NEWLINE' == $aResp['result'])
      {
         $aResp = $inicial_app_Login->contr_app_Login->NM_ajax_info['newline'];
      }
      else
//-----
      {
         $aResp['ajaxRequest'] = $inicial_app_Login->contr_app_Login->NM_ajax_opcao;
         if ('CALENDARRELOAD' == $aResp['result'])
         {
            app_Login_pack_calendar_reload($aResp);
         }
         elseif ('ERROR' == $aResp['result'])
         {
            app_Login_pack_ajax_errors($aResp);
         }
         elseif ('SET' == $aResp['result'])
         {
            app_Login_pack_ajax_set_fields($aResp);
         }
         elseif ('TABLEREFRESH' == $aResp['result'])
         {
            app_Login_pack_ajax_set_fields($aResp);
            $aResp['tableRefresh'] = app_Login_pack_protect_string($inicial_app_Login->contr_app_Login->NM_ajax_info['tableRefresh']);
         }
         if ('OK' == $aResp['result'] || 'SET' == $aResp['result'])
         {
            app_Login_pack_ajax_ok($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['focus']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['focus'])
         {
            $aResp['setFocus'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['focus'];
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['closeLine']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['closeLine'])
         {
            $aResp['closeLine'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['closeLine'];
         }
         else
         {
            $aResp['closeLine'] = 'N';
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['clearUpload']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['clearUpload'])
         {
            $aResp['clearUpload'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['clearUpload'];
         }
         else
         {
            $aResp['clearUpload'] = 'N';
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['btnDisabled']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['btnDisabled'])
         {
            app_Login_pack_btn_disabled($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['btnLabel']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['btnLabel'])
         {
            app_Login_pack_btn_label($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['varList']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['varList']))
         {
            app_Login_pack_var_list($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['masterValue']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['masterValue'])
         {
            app_Login_pack_master_value($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert'])
         {
            app_Login_pack_ajax_alert($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage'])
         {
            app_Login_pack_ajax_message($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxJavascript']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxJavascript'])
         {
            app_Login_pack_ajax_javascript($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['redir']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['redir']))
         {
            app_Login_pack_ajax_redir($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['redirExit']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['redirExit']))
         {
            app_Login_pack_ajax_redir_exit($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['blockDisplay']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['blockDisplay']))
         {
            app_Login_pack_ajax_block_display($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['fieldDisplay']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['fieldDisplay']))
         {
            app_Login_pack_ajax_field_display($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplay']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplay']))
         {
/* mantis 0021191 */            $inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplay'] = $inicial_app_Login->contr_app_Login->nmgp_botoes;
            app_Login_pack_ajax_button_display($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplayVert']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplayVert']))
         {
            app_Login_pack_ajax_button_display_vert($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['fieldLabel']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['fieldLabel']))
         {
            app_Login_pack_ajax_field_label($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['readOnly']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['readOnly']))
         {
            app_Login_pack_ajax_readonly($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']))
         {
            app_Login_pack_ajax_nav_status($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['navSummary']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['navSummary']))
         {
            app_Login_pack_ajax_nav_Summary($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['navPage']))
         {
            app_Login_pack_ajax_navPage($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['btnVars']) && !empty($inicial_app_Login->contr_app_Login->NM_ajax_info['btnVars']))
         {
            app_Login_pack_ajax_btn_vars($aResp);
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['quickSearchRes']) && $inicial_app_Login->contr_app_Login->NM_ajax_info['quickSearchRes'])
         {
            $aResp['quickSearchRes'] = 'Y';
         }
         else
         {
            $aResp['quickSearchRes'] = 'N';
         }
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['event_field']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['event_field'])
         {
            $aResp['eventField'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['event_field'];
         }
         else
         {
            $aResp['eventField'] = '__SC_NO_FIELD';
         }
         $aResp['htmOutput'] = '';
    
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output']) && $inicial_app_Login->contr_app_Login->NM_ajax_info['param']['buffer_output'])
         {
            $aResp['htmOutput'] = ob_get_contents();
            if (false === $aResp['htmOutput'])
            {
               $aResp['htmOutput'] = '';
            }
            else
            {
               $aResp['htmOutput'] = app_Login_pack_protect_string(NM_charset_to_utf8($aResp['htmOutput']));
               ob_end_clean();
            }
         }
      }
      if (is_array($aResp))
      {
          if (isset($aResp['wizard'])) {
              echo json_encode($aResp);
          }
          else {
              $oJson = new Services_JSON();
              echo "var res = " . trim(sajax_get_js_repr($oJson->encode($aResp))) . "; res;";
          }
      }
      else
      {
          echo "var res = " . trim(sajax_get_js_repr($aResp)) . "; res;";
      }
      exit;
   } // app_Login_pack_ajax_response

   function app_Login_pack_calendar_reload(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['calendarReload'] = 'OK';
   } // app_Login_pack_calendar_reload

   function app_Login_pack_ajax_errors(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['errList'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['errList'] as $sField => $aMsg)
      {
         if ('geral_app_Login' == $sField)
         {
             $aMsg = app_Login_pack_ajax_remove_erros($aMsg);
         }
         foreach ($aMsg as $sMsg)
         {
            $iNumLinha = (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['nmgp_refresh_row']) && 'geral_app_Login' != $sField)
                       ? $inicial_app_Login->contr_app_Login->NM_ajax_info['param']['nmgp_refresh_row'] : "";
            $aResp['errList'][] = array('fldName'  => $sField,
                                        'msgText'  => app_Login_pack_protect_string(NM_charset_to_utf8($sMsg)),
                                        'numLinha' => $iNumLinha);
         }
      }
   } // app_Login_pack_ajax_errors

   function app_Login_pack_ajax_remove_erros($aErrors)
   {
       $aNewErrors = array();
       if (!empty($aErrors))
       {
           $sErrorMsgs = str_replace(array('<br />', '<br>', '<BR />'), array('<BR>', '<BR>', '<BR>'), implode('<br />', $aErrors));
           $aErrorMsgs = explode('<BR>', $sErrorMsgs);
           foreach ($aErrorMsgs as $sErrorMsg)
           {
               $sErrorMsg = trim($sErrorMsg);
               if ('' != $sErrorMsg && !in_array($sErrorMsg, $aNewErrors))
               {
                   $aNewErrors[] = $sErrorMsg;
               }
           }
       }
       return $aNewErrors;
   } // app_Login_pack_ajax_remove_erros

   function app_Login_pack_ajax_ok(&$aResp)
   {
      global $inicial_app_Login;
      $iNumLinha = (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['nmgp_refresh_row']))
                 ? $inicial_app_Login->contr_app_Login->NM_ajax_info['param']['nmgp_refresh_row'] : "";
      $aResp['msgDisplay'] = array('msgText'  => app_Login_pack_protect_string($inicial_app_Login->contr_app_Login->NM_ajax_info['msgDisplay']),
                                   'numLinha' => $iNumLinha);
   } // app_Login_pack_ajax_ok

   function app_Login_pack_ajax_set_fields(&$aResp)
   {
      global $inicial_app_Login;
      $iNumLinha = (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['param']['nmgp_refresh_row']))
                 ? $inicial_app_Login->contr_app_Login->NM_ajax_info['param']['nmgp_refresh_row'] : "";
      if ('' != $inicial_app_Login->contr_app_Login->NM_ajax_info['rsSize'])
      {
         $aResp['rsSize'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['rsSize'];
      }
      $aResp['fldList'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['fldList'] as $sField => $aData)
      {
         $aField = array();
         if (isset($aData['colNum']))
         {
            $aField['colNum'] = $aData['colNum'];
         }
         if (isset($aData['row']))
         {
            $aField['row'] = $aData['row'];
         }
         if (isset($aData['imgFile']))
         {
            $aField['imgFile'] = app_Login_pack_protect_string($aData['imgFile']);
         }
         if (isset($aData['imgOrig']))
         {
            $aField['imgOrig'] = app_Login_pack_protect_string($aData['imgOrig']);
         }
         if (isset($aData['imgLink']))
         {
            $aField['imgLink'] = app_Login_pack_protect_string($aData['imgLink']);
         }
         if (isset($aData['keepImg']))
         {
            $aField['keepImg'] = $aData['keepImg'];
         }
         if (isset($aData['hideName']))
         {
            $aField['hideName'] = $aData['hideName'];
         }
         if (isset($aData['docLink']))
         {
            $aField['docLink'] = app_Login_pack_protect_string($aData['docLink']);
         }
         if (isset($aData['docIcon']))
         {
            $aField['docIcon'] = app_Login_pack_protect_string($aData['docIcon']);
         }
         if (isset($aData['docReadonly']))
         {
            $aField['docReadonly'] = app_Login_pack_protect_string($aData['docReadonly']);
         }
         if (isset($aData['keyVal']))
         {
            $aField['keyVal'] = $aData['keyVal'];
         }
         if (isset($aData['optComp']))
         {
            $aField['optComp'] = $aData['optComp'];
         }
         if (isset($aData['optClass']))
         {
            $aField['optClass'] = $aData['optClass'];
         }
         if (isset($aData['optMulti']))
         {
            $aField['optMulti'] = $aData['optMulti'];
         }
         if (isset($aData['switch']))
         {
            $aField['switch'] = $aData['switch'];
         }
         if (isset($aData['lookupCons']))
         {
            $aField['lookupCons'] = $aData['lookupCons'];
         }
         if (isset($aData['imgHtml']))
         {
            $aField['imgHtml'] = app_Login_pack_protect_string($aData['imgHtml']);
         }
         if (isset($aData['mulHtml']))
         {
            $aField['mulHtml'] = app_Login_pack_protect_string($aData['mulHtml']);
         }
         if (isset($aData['updInnerHtml']))
         {
            $aField['updInnerHtml'] = $aData['updInnerHtml'];
         }
         if (isset($aData['htmComp']))
         {
            $aField['htmComp'] = str_replace("'", '__AS__', str_replace('"', '__AD__', $aData['htmComp']));
         }
         $aField['fldName']  = $sField;
         $aField['fldType']  = $aData['type'];
         $aField['numLinha'] = $iNumLinha;
         $aField['valList']  = array();
         foreach ($aData['valList'] as $iIndex => $sValue)
         {
            $aValue = array();
            if (isset($aData['labList'][$iIndex]))
            {
               $aValue['label'] = app_Login_pack_protect_string($aData['labList'][$iIndex]);
            }
            $aValue['value']     = ('_autocomp' != substr($sField, -9)) ? app_Login_pack_protect_string($sValue) : $sValue;
            $aField['valList'][] = $aValue;
         }
         foreach ($aField['valList'] as $iIndex => $aFieldData)
         {
             if ("null" == $aFieldData['value'])
             {
                 $aField['valList'][$iIndex]['value'] = '';
             }
         }
         if (isset($aData['optList']) && false !== $aData['optList'])
         {
            if (is_array($aData['optList']))
            {
               $aField['optList'] = array();
               foreach ($aData['optList'] as $aOptList)
               {
                  foreach ($aOptList as $sValue => $sLabel)
                  {
                     $sOpt = ($sValue !== $sLabel) ? $sValue : $sLabel;
                     $aField['optList'][] = array('value' => app_Login_pack_protect_string($sOpt),
                                                  'label' => app_Login_pack_protect_string($sLabel));
                  }
               }
            }
            else
            {
               $aField['optList'] = $aData['optList'];
            }
         }
         $aResp['fldList'][] = $aField;
      }
   } // app_Login_pack_ajax_set_fields

   function app_Login_pack_ajax_redir(&$aResp)
   {
      global $inicial_app_Login;
      $aInfo              = array('metodo', 'action', 'target', 'nmgp_parms', 'nmgp_outra_jan', 'nmgp_url_saida', 'script_case_init', 'script_case_session', 'h_modal', 'w_modal');
      $aResp['redirInfo'] = array();
      foreach ($aInfo as $sTag)
      {
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['redir'][$sTag]))
         {
            $aResp['redirInfo'][$sTag] = $inicial_app_Login->contr_app_Login->NM_ajax_info['redir'][$sTag];
         }
      }
   } // app_Login_pack_ajax_redir

   function app_Login_pack_ajax_redir_exit(&$aResp)
   {
      global $inicial_app_Login;
      $aInfo                  = array('metodo', 'action', 'target', 'nmgp_parms', 'nmgp_outra_jan', 'nmgp_url_saida', 'script_case_init', 'script_case_session');
      $aResp['redirExitInfo'] = array();
      foreach ($aInfo as $sTag)
      {
         if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['redirExit'][$sTag]))
         {
            $aResp['redirExitInfo'][$sTag] = $inicial_app_Login->contr_app_Login->NM_ajax_info['redirExit'][$sTag];
         }
      }
   } // app_Login_pack_ajax_redir_exit

   function app_Login_pack_var_list(&$aResp)
   {
      global $inicial_app_Login;
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['varList'] as $varData)
      {
         $aResp['varList'][] = array('index' => key($varData),
                                      'value' => current($varData));
      }
   } // app_Login_pack_var_list

   function app_Login_pack_master_value(&$aResp)
   {
      global $inicial_app_Login;
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['masterValue'] as $sIndex => $sValue)
      {
         $aResp['masterValue'][] = array('index' => $sIndex,
                                         'value' => $sValue);
      }
   } // app_Login_pack_master_value

   function app_Login_pack_btn_disabled(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['btnDisabled'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['btnDisabled'] as $btnName => $btnStatus) {
        $aResp['btnDisabled'][$btnName] = $btnStatus;
      }
   } // app_Login_pack_ajax_alert

   function app_Login_pack_btn_label(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['btnLabel'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['btnLabel'] as $btnName => $btnLabel) {
        $aResp['btnLabel'][$btnName] = $btnLabel;
      }
   } // app_Login_pack_ajax_alert

   function app_Login_pack_ajax_alert(&$aResp)
   {
      global $inicial_app_Login;
// PHP 8.0
      if (!isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']['message'])) {
          $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']['message'] = '';
      }
      if (!isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']['params'])) {
          $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']['params'] = '';
      }
//---
      $aResp['ajaxAlert'] = array('message' => $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']['message'], 'params' =>  $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxAlert']['params']);
   } // app_Login_pack_ajax_alert

   function app_Login_pack_ajax_message(&$aResp)
   {
      global $inicial_app_Login;
// PHP 8.0
      if (!isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['message'])) {
          $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['message'] = '';
      }
      if (!isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['title'])) {
          $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['title'] = '';
      }
//---
      $aResp['ajaxMessage'] = array('message'      => app_Login_pack_protect_string($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['message']),
                                    'title'        => app_Login_pack_protect_string($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['title']),
                                    'modal'        => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['modal'])        ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['modal']        : 'N',
                                    'timeout'      => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['timeout'])      ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['timeout']      : '',
                                    'button'       => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['button'])       ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['button']       : '',
                                    'button_label' => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['button_label']) ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['button_label'] : 'Ok',
                                    'top'          => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['top'])          ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['top']          : '',
                                    'left'         => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['left'])         ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['left']         : '',
                                    'width'        => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['width'])        ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['width']        : '',
                                    'height'       => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['height'])       ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['height']       : '',
                                    'redir'        => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['redir'])        ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['redir']        : '',
                                    'show_close'   => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['show_close'])   ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['show_close']   : 'Y',
                                    'body_icon'    => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['body_icon'])    ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['body_icon']    : 'Y',
                                    'toast'        => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['toast'])        ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['toast']        : 'N',
                                    'toast_pos'    => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['toast_pos'])    ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['toast_pos']    : '',
                                    'type'         => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['type'])         ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['type']         : '',
                                    'redir_target' => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['redir_target']) ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['redir_target'] : '',
                                    'redir_par'    => isset($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['redir_par'])    ? $inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxMessage']['redir_par']    : '');
   } // app_Login_pack_ajax_message

   function app_Login_pack_ajax_javascript(&$aResp)
   {
      global $inicial_app_Login;
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['ajaxJavascript'] as $aJsFunc)
      {
         $aResp['ajaxJavascript'][] = $aJsFunc;
      }
   } // app_Login_pack_ajax_javascript

   function app_Login_pack_ajax_block_display(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['blockDisplay'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['blockDisplay'] as $sBlockName => $sBlockStatus)
      {
        $aResp['blockDisplay'][] = array($sBlockName, $sBlockStatus);
      }
   } // app_Login_pack_ajax_block_display

   function app_Login_pack_ajax_field_display(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['fieldDisplay'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['fieldDisplay'] as $sFieldName => $sFieldStatus)
      {
        $aResp['fieldDisplay'][] = array($sFieldName, $sFieldStatus);
      }
   } // app_Login_pack_ajax_field_display

   function app_Login_pack_ajax_button_display(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['buttonDisplay'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplay'] as $sButtonName => $sButtonStatus)
      {
        $aResp['buttonDisplay'][] = array($sButtonName, $sButtonStatus);
      }
   } // app_Login_pack_ajax_button_display

   function app_Login_pack_ajax_button_display_vert(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['buttonDisplayVert'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['buttonDisplayVert'] as $aButtonData)
      {
        $aResp['buttonDisplayVert'][] = $aButtonData;
      }
   } // app_Login_pack_ajax_button_display

   function app_Login_pack_ajax_field_label(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['fieldLabel'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['fieldLabel'] as $sFieldName => $sFieldLabel)
      {
        $aResp['fieldLabel'][] = array($sFieldName, app_Login_pack_protect_string($sFieldLabel));
      }
   } // app_Login_pack_ajax_field_label

   function app_Login_pack_ajax_readonly(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['readOnly'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['readOnly'] as $sFieldName => $sFieldStatus)
      {
        $aResp['readOnly'][] = array($sFieldName, $sFieldStatus);
      }
   } // app_Login_pack_ajax_readonly

   function app_Login_pack_ajax_nav_status(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['navStatus'] = array();
      if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']['ret']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']['ret'])
      {
         $aResp['navStatus']['ret'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']['ret'];
      }
      if (isset($inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']['ava']) && '' != $inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']['ava'])
      {
         $aResp['navStatus']['ava'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['navStatus']['ava'];
      }
   } // app_Login_pack_ajax_nav_status

   function app_Login_pack_ajax_nav_Summary(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['navSummary'] = array();
      $aResp['navSummary']['reg_ini'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['navSummary']['reg_ini'];
      $aResp['navSummary']['reg_qtd'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['navSummary']['reg_qtd'];
      $aResp['navSummary']['reg_tot'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['navSummary']['reg_tot'];
   } // app_Login_pack_ajax_nav_Summary

   function app_Login_pack_ajax_navPage(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['navPage'] = $inicial_app_Login->contr_app_Login->NM_ajax_info['navPage'];
   } // app_Login_pack_ajax_navPage


   function app_Login_pack_ajax_btn_vars(&$aResp)
   {
      global $inicial_app_Login;
      $aResp['btnVars'] = array();
      foreach ($inicial_app_Login->contr_app_Login->NM_ajax_info['btnVars'] as $sBtnName => $sBtnValue)
      {
        $aResp['btnVars'][] = array($sBtnName, app_Login_pack_protect_string($sBtnValue));
      }
   } // app_Login_pack_ajax_btn_vars

   function app_Login_pack_protect_string($sString)
   {
      $sString = (string) $sString;

      if (!empty($sString))
      {
         if (function_exists('NM_is_utf8') && NM_is_utf8($sString))
         {
             return $sString;
         }
         else
         {
/*             return htmlentities($sString, ENT_COMPAT, $_SESSION['scriptcase']['charset']); */
             return sc_htmlentities($sString);
         }
      }
      elseif ('0' === $sString || 0 === $sString)
      {
         return '0';
      }
      else
      {
         return '';
      }
   } // app_Login_pack_protect_string
?>
