<?php
//
class cadastro_DEN_1000_registro_mob_apl
{
   var $has_where_params = false;
   var $NM_is_redirected = false;
   var $NM_non_ajax_info = false;
   var $formatado = false;
   var $use_100perc_fields = false;
   var $classes_100perc_fields = array();
   var $close_modal_after_insert = false;
   var $NM_ajax_flag    = false;
   var $NM_ajax_opcao   = '';
   var $NM_ajax_retorno = '';
   var $NM_ajax_info    = array('result'            => '',
                                'param'             => array(),
                                'autoComp'          => '',
                                'rsSize'            => '',
                                'msgDisplay'        => '',
                                'errList'           => array(),
                                'fldList'           => array(),
                                'varList'           => array(),
                                'focus'             => '',
                                'navStatus'         => array(),
                                'navSummary'        => array(),
                                'redir'             => array(),
                                'blockDisplay'      => array(),
                                'fieldDisplay'      => array(),
                                'fieldLabel'        => array(),
                                'readOnly'          => array(),
                                'btnVars'           => array(),
                                'ajaxAlert'         => array(),
                                'ajaxMessage'       => array(),
                                'ajaxJavascript'    => array(),
                                'buttonDisplay'     => array(),
                                'buttonDisplayVert' => array(),
                                'calendarReload'    => false,
                                'quickSearchRes'    => false,
                                'displayMsg'        => false,
                                'displayMsgTxt'     => '',
                                'dyn_search'        => array(),
                                'empty_filter'      => '',
                                'event_field'       => '',
                                'fieldsWithErrors'  => array(),
                               );
   var $NM_ajax_force_values = false;
   var $captcha_code;
   var $captcha_sent;
   var $Nav_permite_ava     = true;
   var $Nav_permite_ret     = true;
   var $Apl_com_erro        = false;
   var $app_is_initializing = false;
   var $Ini;
   var $Erro;
   var $Db;
   var $chave;
   var $titulo_manifestacao_1000;
   var $desc_manifestacao_1000;
   var $id_categoria_1100;
   var $id_categoria_1100_1;
   var $desc_area_setor_1000;
   var $dt_ocorrido_1000;
   var $ouvd_anonima_1000;
   var $nome_inf_ouvd_1000;
   var $cpf_cnpj_ouvd_1000;
   var $tel_inf_ouvd_1000;
   var $email_inf_ouvd_1000;
   var $dt_ini_inv_ouvd_1000;
   var $andamento_inv_ouvd_1000;
   var $conclusao_inv_ouvd_1000;
   var $nivel_atend_atual_1000;
   var $id_status_ouvd_1000;
   var $id_controlador_1000;
   var $data_hora_cadastro_1000;
   var $data_hora_cadastro_1000_hora;
   var $token_ouvd_1000;
   var $anexo_ouvd_img1_1000;
   var $anexo_ouvd_img1_1000_scfile_name;
   var $anexo_ouvd_img1_1000_ul_name;
   var $anexo_ouvd_img1_1000_scfile_type;
   var $anexo_ouvd_img1_1000_ul_type;
   var $anexo_ouvd_img1_1000_limpa;
   var $anexo_ouvd_img1_1000_salva;
   var $out_anexo_ouvd_img1_1000;
   var $anexo_ouvd_img2_1000;
   var $anexo_ouvd_img2_1000_scfile_name;
   var $anexo_ouvd_img2_1000_ul_name;
   var $anexo_ouvd_img2_1000_scfile_type;
   var $anexo_ouvd_img2_1000_ul_type;
   var $anexo_ouvd_img2_1000_limpa;
   var $anexo_ouvd_img2_1000_salva;
   var $out_anexo_ouvd_img2_1000;
   var $anexo_ouvd_doc1_1000;
   var $anexo_ouvd_doc1_1000_scfile_name;
   var $anexo_ouvd_doc1_1000_ul_name;
   var $anexo_ouvd_doc1_1000_ul_type;
   var $anexo_ouvd_doc1_1000_limpa;
   var $anexo_ouvd_doc1_1000_salva;
   var $anexo_ouvd_doc2_1000;
   var $anexo_ouvd_doc2_1000_scfile_name;
   var $anexo_ouvd_doc2_1000_ul_name;
   var $anexo_ouvd_doc2_1000_ul_type;
   var $anexo_ouvd_doc2_1000_limpa;
   var $anexo_ouvd_doc2_1000_salva;
   var $instr_senha;
   var $codigo;
   var $nm_data;
   var $nmgp_opcao;
   var $nmgp_opc_ant;
   var $sc_evento;
   var $sc_insert_on;
   var $nmgp_clone;
   var $nmgp_return_img = array();
   var $nmgp_dados_form = array();
   var $nmgp_dados_select = array();
   var $nm_location;
   var $nm_flag_iframe;
   var $nm_flag_saida_novo;
   var $nmgp_botoes = array();
   var $nmgp_url_saida;
   var $nmgp_form_show;
   var $nmgp_form_empty;
   var $nmgp_cmp_readonly = array();
   var $nmgp_cmp_hidden   = array();
   var $Field_no_validate  = array();
   var $form_paginacao = 'parcial';
   var $lig_edit_lookup      = false;
   var $lig_edit_lookup_call = false;
   var $lig_edit_lookup_cb   = '';
   var $lig_edit_lookup_row  = '';
   var $is_calendar_app = false;
   var $Embutida_call  = false;
   var $Embutida_ronly = false;
   var $Embutida_proc  = false;
   var $Embutida_form  = false;
   var $Grid_editavel  = false;
   var $url_webhelp = '';
   var $nm_todas_criticas;
   var $Campos_Mens_erro;
   var $nm_new_label = array();
   var $record_insert_ok = false;
   var $record_delete_ok = false;
//
//----- 
   function ini_controle()
   {
        global $nm_url_saida, $teste_validade, $script_case_init, 
               $glo_senha_protect, $nm_apl_dependente, $nm_form_submit, $sc_check_excl, $nm_opc_form_php, $nm_call_php, $nm_opc_lookup;


      if ($this->NM_ajax_flag)
      {
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000']))
          {
              $this->anexo_ouvd_doc1_1000 = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_limpa']))
          {
              $this->anexo_ouvd_doc1_1000_limpa = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_limpa'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_salva']))
          {
              $this->anexo_ouvd_doc1_1000_salva = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_salva'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name']))
          {
              $this->anexo_ouvd_doc1_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_type']))
          {
              $this->anexo_ouvd_doc1_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_type'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000']))
          {
              $this->anexo_ouvd_doc2_1000 = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_limpa']))
          {
              $this->anexo_ouvd_doc2_1000_limpa = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_limpa'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_salva']))
          {
              $this->anexo_ouvd_doc2_1000_salva = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_salva'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name']))
          {
              $this->anexo_ouvd_doc2_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_type']))
          {
              $this->anexo_ouvd_doc2_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_type'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img1_1000']))
          {
              $this->anexo_ouvd_img1_1000 = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img1_1000_limpa']))
          {
              $this->anexo_ouvd_img1_1000_limpa = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_limpa'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img1_1000_salva']))
          {
              $this->anexo_ouvd_img1_1000_salva = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_salva'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name']))
          {
              $this->anexo_ouvd_img1_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_type']))
          {
              $this->anexo_ouvd_img1_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_type'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img2_1000']))
          {
              $this->anexo_ouvd_img2_1000 = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img2_1000_limpa']))
          {
              $this->anexo_ouvd_img2_1000_limpa = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_limpa'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img2_1000_salva']))
          {
              $this->anexo_ouvd_img2_1000_salva = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_salva'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name']))
          {
              $this->anexo_ouvd_img2_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name'];
          }
          if (isset($this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_type']))
          {
              $this->anexo_ouvd_img2_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_type'];
          }
          if (isset($this->NM_ajax_info['param']['chave']))
          {
              $this->chave = $this->NM_ajax_info['param']['chave'];
          }
          if (isset($this->NM_ajax_info['param']['codigo']))
          {
              $this->codigo = $this->NM_ajax_info['param']['codigo'];
          }
          if (isset($this->NM_ajax_info['param']['cpf_cnpj_ouvd_1000']))
          {
              $this->cpf_cnpj_ouvd_1000 = $this->NM_ajax_info['param']['cpf_cnpj_ouvd_1000'];
          }
          if (isset($this->NM_ajax_info['param']['csrf_token']))
          {
              $this->csrf_token = $this->NM_ajax_info['param']['csrf_token'];
          }
          if (isset($this->NM_ajax_info['param']['desc_area_setor_1000']))
          {
              $this->desc_area_setor_1000 = $this->NM_ajax_info['param']['desc_area_setor_1000'];
          }
          if (isset($this->NM_ajax_info['param']['desc_manifestacao_1000']))
          {
              $this->desc_manifestacao_1000 = $this->NM_ajax_info['param']['desc_manifestacao_1000'];
          }
          if (isset($this->NM_ajax_info['param']['dt_ocorrido_1000']))
          {
              $this->dt_ocorrido_1000 = $this->NM_ajax_info['param']['dt_ocorrido_1000'];
          }
          if (isset($this->NM_ajax_info['param']['email_inf_ouvd_1000']))
          {
              $this->email_inf_ouvd_1000 = $this->NM_ajax_info['param']['email_inf_ouvd_1000'];
          }
          if (isset($this->NM_ajax_info['param']['id_categoria_1100']))
          {
              $this->id_categoria_1100 = $this->NM_ajax_info['param']['id_categoria_1100'];
          }
          if (isset($this->NM_ajax_info['param']['instr_senha']))
          {
              $this->instr_senha = $this->NM_ajax_info['param']['instr_senha'];
          }
          if (isset($this->NM_ajax_info['param']['nm_form_submit']))
          {
              $this->nm_form_submit = $this->NM_ajax_info['param']['nm_form_submit'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_ancora']))
          {
              $this->nmgp_ancora = $this->NM_ajax_info['param']['nmgp_ancora'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_arg_dyn_search']))
          {
              $this->nmgp_arg_dyn_search = $this->NM_ajax_info['param']['nmgp_arg_dyn_search'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_num_form']))
          {
              $this->nmgp_num_form = $this->NM_ajax_info['param']['nmgp_num_form'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_opcao']))
          {
              $this->nmgp_opcao = $this->NM_ajax_info['param']['nmgp_opcao'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_ordem']))
          {
              $this->nmgp_ordem = $this->NM_ajax_info['param']['nmgp_ordem'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_parms']))
          {
              $this->nmgp_parms = $this->NM_ajax_info['param']['nmgp_parms'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_url_saida']))
          {
              $this->nmgp_url_saida = $this->NM_ajax_info['param']['nmgp_url_saida'];
          }
          if (isset($this->NM_ajax_info['param']['nome_inf_ouvd_1000']))
          {
              $this->nome_inf_ouvd_1000 = $this->NM_ajax_info['param']['nome_inf_ouvd_1000'];
          }
          if (isset($this->NM_ajax_info['param']['ouvd_anonima_1000']))
          {
              $this->ouvd_anonima_1000 = $this->NM_ajax_info['param']['ouvd_anonima_1000'];
          }
          if (isset($this->NM_ajax_info['param']['script_case_init']))
          {
              $this->script_case_init = $this->NM_ajax_info['param']['script_case_init'];
          }
          if (isset($this->NM_ajax_info['param']['tel_inf_ouvd_1000']))
          {
              $this->tel_inf_ouvd_1000 = $this->NM_ajax_info['param']['tel_inf_ouvd_1000'];
          }
          if (isset($this->NM_ajax_info['param']['titulo_manifestacao_1000']))
          {
              $this->titulo_manifestacao_1000 = $this->NM_ajax_info['param']['titulo_manifestacao_1000'];
          }
          if (isset($this->nmgp_refresh_fields))
          {
              $this->nmgp_refresh_fields = explode('_#fld#_', $this->nmgp_refresh_fields);
              $this->nmgp_opcao          = 'recarga';
          }
          if (!isset($this->nmgp_refresh_row))
          {
              $this->nmgp_refresh_row = '';
          }
      }

      $this->scSajaxReservedWords = array('rs', 'rst', 'rsrnd', 'rsargs');
      $this->sc_conv_var = array();
      if (!empty($_FILES))
      {
          foreach ($_FILES as $nmgp_campo => $nmgp_valores)
          {
               if (!in_array(strtolower($nmgp_campo), $this->scSajaxReservedWords)) {
                   if (isset($this->sc_conv_var[$nmgp_campo]))
                   {
                       $nmgp_campo = $this->sc_conv_var[$nmgp_campo];
                   }
                   elseif (isset($this->sc_conv_var[strtolower($nmgp_campo)]))
                   {
                       $nmgp_campo = $this->sc_conv_var[strtolower($nmgp_campo)];
                   }
               }
               $tmp_scfile_name     = $nmgp_campo . "_scfile_name";
               $tmp_scfile_type     = $nmgp_campo . "_scfile_type";
               $this->$nmgp_campo = is_array($nmgp_valores['tmp_name']) ? $nmgp_valores['tmp_name'][0] : $nmgp_valores['tmp_name'];
               $this->$tmp_scfile_type   = is_array($nmgp_valores['type'])     ? $nmgp_valores['type'][0]     : $nmgp_valores['type'];
               $this->$tmp_scfile_name   = is_array($nmgp_valores['name'])     ? $nmgp_valores['name'][0]     : $nmgp_valores['name'];
          }
      }
      $Sc_lig_md5 = 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 (!in_array(strtolower($nmgp_var), $this->scSajaxReservedWords)) {
                   if (isset($this->sc_conv_var[$nmgp_var]))
                   {
                       $nmgp_var = $this->sc_conv_var[$nmgp_var];
                   }
                   elseif (isset($this->sc_conv_var[strtolower($nmgp_var)]))
                   {
                       $nmgp_var = $this->sc_conv_var[strtolower($nmgp_var)];
                   }
               }
               $nmgp_val = NM_decode_input($nmgp_val);
               $this->$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 (!in_array(strtolower($nmgp_var), $this->scSajaxReservedWords)) {
                   if (isset($this->sc_conv_var[$nmgp_var]))
                   {
                       $nmgp_var = $this->sc_conv_var[$nmgp_var];
                   }
                   elseif (isset($this->sc_conv_var[strtolower($nmgp_var)]))
                   {
                       $nmgp_var = $this->sc_conv_var[strtolower($nmgp_var)];
                   }
               }
               $nmgp_val = NM_decode_input($nmgp_val);
               $this->$nmgp_var = $nmgp_val;
          }
      }
      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($this->usr_controlador) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['usr_controlador'] = $this->usr_controlador;
      }
      if (isset($this->cnpj_controlador) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['cnpj_controlador'] = $this->cnpj_controlador;
      }
      if (isset($this->theme) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['theme'] = $this->theme;
      }
      if (isset($_POST["usr_controlador"]) && isset($this->usr_controlador)) 
      {
          $_SESSION['usr_controlador'] = $this->usr_controlador;
      }
      if (isset($_POST["cnpj_controlador"]) && isset($this->cnpj_controlador)) 
      {
          $_SESSION['cnpj_controlador'] = $this->cnpj_controlador;
      }
      if (isset($_POST["theme"]) && isset($this->theme)) 
      {
          $_SESSION['theme'] = $this->theme;
      }
      if (isset($_GET["usr_controlador"]) && isset($this->usr_controlador)) 
      {
          $_SESSION['usr_controlador'] = $this->usr_controlador;
      }
      if (isset($_GET["cnpj_controlador"]) && isset($this->cnpj_controlador)) 
      {
          $_SESSION['cnpj_controlador'] = $this->cnpj_controlador;
      }
      if (isset($_GET["theme"]) && isset($this->theme)) 
      {
          $_SESSION['theme'] = $this->theme;
      }
      if (isset($this->Refresh_aba_menu)) {
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['Refresh_aba_menu'] = $this->Refresh_aba_menu;
      }
      if (isset($this->nmgp_opcao) && $this->nmgp_opcao == "reload_novo") {
          $_POST['nmgp_opcao'] = "novo";
          $this->nmgp_opcao    = "novo";
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['opcao']   = "novo";
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['opc_ant'] = "inicio";
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['embutida_parms']))
      { 
          $this->nmgp_parms = $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['embutida_parms'];
          unset($_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['embutida_parms']);
      } 
      if (isset($this->nmgp_parms) && !empty($this->nmgp_parms)) 
      { 
          if (isset($_SESSION['nm_aba_bg_color'])) 
          { 
              unset($_SESSION['nm_aba_bg_color']);
          }   
          $nmgp_parms = str_replace("@aspass@", "'", $this->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]];
                }
                 if (isset($this->sc_conv_var[$cadapar[0]]))
                 {
                     $cadapar[0] = $this->sc_conv_var[$cadapar[0]];
                 }
                 elseif (isset($this->sc_conv_var[strtolower($cadapar[0])]))
                 {
                     $cadapar[0] = $this->sc_conv_var[strtolower($cadapar[0])];
                 }
                 nm_limpa_str_cadastro_DEN_1000_registro_mob($cadapar[1]);
                 if ($cadapar[1] == "@ ") {$cadapar[1] = trim($cadapar[1]); }
                 $Tmp_par = $cadapar[0];
                 $this->$Tmp_par = $cadapar[1];
             }
             $ix++;
          }
          if (isset($this->usr_controlador)) 
          {
              $_SESSION['usr_controlador'] = $this->usr_controlador;
          }
          if (isset($this->cnpj_controlador)) 
          {
              $_SESSION['cnpj_controlador'] = $this->cnpj_controlador;
          }
          if (isset($this->theme)) 
          {
              $_SESSION['theme'] = $this->theme;
          }
          if (isset($this->NM_where_filter_form))
          {
              $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['where_filter_form'] = $this->NM_where_filter_form;
              unset($_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['total']);
          }
          if (isset($this->sc_redir_atualiz))
          {
              $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['sc_redir_atualiz'] = $this->sc_redir_atualiz;
          }
          if (isset($this->sc_redir_insert))
          {
              $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['sc_redir_insert'] = $this->sc_redir_insert;
              unset($_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['opc_ant']);
          }
          if (isset($this->usr_controlador)) 
          {
              $_SESSION['usr_controlador'] = $this->usr_controlador;
          }
          if (isset($this->cnpj_controlador)) 
          {
              $_SESSION['cnpj_controlador'] = $this->cnpj_controlador;
          }
          if (isset($this->theme)) 
          {
              $_SESSION['theme'] = $this->theme;
          }
      } 
      elseif (isset($script_case_init) && !empty($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['parms']))
      {
          if ((!isset($this->nmgp_opcao) || ($this->nmgp_opcao != "incluir" && $this->nmgp_opcao != "alterar" && $this->nmgp_opcao != "excluir" && $this->nmgp_opcao != "novo" && $this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")) && (!isset($this->NM_ajax_opcao) || $this->NM_ajax_opcao == ""))
          {
              $todox = str_replace("?#?@?@?", "?#?@ ?@?", $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['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];
                 $this->$Tmp_par = $cadapar[1];
                 $ix++;
              }
          }
      } 

      if (isset($this->nm_run_menu) && $this->nm_run_menu == 1)
      { 
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['nm_run_menu'] = 1;
      } 
      if (!$this->NM_ajax_flag && 'autocomp_' == substr($this->NM_ajax_opcao, 0, 9))
      {
          $this->NM_ajax_flag = true;
      }

      $dir_raiz          = strrpos($_SERVER['PHP_SELF'],"/") ;  
      $dir_raiz          = substr($_SERVER['PHP_SELF'], 0, $dir_raiz + 1) ;  
      if (isset($this->nm_evt_ret_edit) && '' != $this->nm_evt_ret_edit)
      {
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup']     = true;
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup_cb']  = $this->nm_evt_ret_edit;
          $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup_row'] = isset($this->nm_evt_ret_row) ? $this->nm_evt_ret_row : '';
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup']) && $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup'])
      {
          $this->lig_edit_lookup     = true;
          $this->lig_edit_lookup_cb  = $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup_cb'];
          $this->lig_edit_lookup_row = $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['lig_edit_lookup_row'];
      }
      if (!$this->Ini)
      { 
          $this->Ini = new cadastro_DEN_1000_registro_mob_ini(); 
          $this->Ini->init();
          $this->nm_data = new nm_data("pt_br");
          $this->app_is_initializing = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['initialize'];
          $this->Db = $this->Ini->Db; 
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['initialize']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['initialize'])
          {
              $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro']['start'] = 'new';
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
          if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro']))
          {
              foreach ($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro'] as $I_conf => $Conf_opt)
              {
                  $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob'][$I_conf]  = $Conf_opt;
              }
          }
          }
          $this->Ini->init2();
      } 
      else 
      { 
         $this->nm_data = new nm_data("pt_br");
      } 
      $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['upload_field_info'] = array();

      $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['upload_field_info']['anexo_ouvd_img1_1000'] = array(
          'app_dir'            => $this->Ini->path_aplicacao,
          'app_name'           => 'cadastro_DEN_1000_registro_mob',
          'upload_dir'         => $this->Ini->root . $this->Ini->path_imag_temp . '/',
          'upload_url'         => $this->Ini->path_imag_temp . '/',
          'upload_type'        => 'single',
          'upload_allowed_type'  => '/.+$/i',
          'upload_max_size'  => null,
          'upload_file_height' => '0',
          'upload_file_width'  => '0',
          'upload_file_aspect' => 'N',
          'upload_file_type'   => 'I',
      );

      $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['upload_field_info']['anexo_ouvd_img2_1000'] = array(
          'app_dir'            => $this->Ini->path_aplicacao,
          'app_name'           => 'cadastro_DEN_1000_registro_mob',
          'upload_dir'         => $this->Ini->root . $this->Ini->path_imag_temp . '/',
          'upload_url'         => $this->Ini->path_imag_temp . '/',
          'upload_type'        => 'single',
          'upload_allowed_type'  => '/.+$/i',
          'upload_max_size'  => null,
          'upload_file_height' => '0',
          'upload_file_width'  => '0',
          'upload_file_aspect' => 'N',
          'upload_file_type'   => 'I',
      );

      $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['upload_field_info']['anexo_ouvd_doc1_1000'] = array(
          'app_dir'            => $this->Ini->path_aplicacao,
          'app_name'           => 'cadastro_DEN_1000_registro_mob',
          'upload_dir'         => $this->Ini->root . $this->Ini->path_imag_temp . '/',
          'upload_url'         => $this->Ini->path_imag_temp . '/',
          'upload_type'        => 'single',
          'upload_allowed_type'  => '/.+$/i',
          'upload_max_size'  => null,
          'upload_file_height' => '',
          'upload_file_width'  => '',
          'upload_file_aspect' => '',
          'upload_file_type'   => 'N2',
      );

      $_SESSION['sc_session'][$script_case_init]['cadastro_DEN_1000_registro_mob']['upload_field_info']['anexo_ouvd_doc2_1000'] = array(
          'app_dir'            => $this->Ini->path_aplicacao,
          'app_name'           => 'cadastro_DEN_1000_registro_mob',
          'upload_dir'         => $this->Ini->root . $this->Ini->path_imag_temp . '/',
          'upload_url'         => $this->Ini->path_imag_temp . '/',
          'upload_type'        => 'single',
          'upload_allowed_type'  => '/.+$/i',
          'upload_max_size'  => null,
          'upload_file_height' => '',
          'upload_file_width'  => '',
          'upload_file_aspect' => '',
          'upload_file_type'   => 'N3',
      );

      unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['masterValue']);
      $this->Change_Menu = false;
      $run_iframe = (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe']) && ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "R")) ? true : false;
      if (!$run_iframe && isset($_SESSION['scriptcase']['menu_atual']) && !$_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_call'] && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_outra_jan']) || !$_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_outra_jan']))
      {
          $this->sc_init_menu = "x";
          if (isset($_SESSION['scriptcase'][$_SESSION['scriptcase']['menu_atual']]['sc_init']['cadastro_DEN_1000_registro_mob']))
          {
              $this->sc_init_menu = $_SESSION['scriptcase'][$_SESSION['scriptcase']['menu_atual']]['sc_init']['cadastro_DEN_1000_registro_mob'];
          }
          elseif (isset($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']]))
          {
              foreach ($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']] as $init => $resto)
              {
                  if ($this->Ini->sc_page == $init)
                  {
                      $this->sc_init_menu = $init;
                      break;
                  }
              }
          }
          if ($this->Ini->sc_page == $this->sc_init_menu && !isset($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['cadastro_DEN_1000_registro_mob']))
          {
               $_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['cadastro_DEN_1000_registro_mob']['link'] = $this->Ini->sc_protocolo . $this->Ini->server . $this->Ini->path_link . "" . SC_dir_app_name('cadastro_DEN_1000_registro_mob') . "/";
               $_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['cadastro_DEN_1000_registro_mob']['label'] = "Cadastrar Manifestação";
               $this->Change_Menu = true;
          }
          elseif ($this->Ini->sc_page == $this->sc_init_menu)
          {
              $achou = false;
              foreach ($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu] as $apl => $parms)
              {
                  if ($apl == "cadastro_DEN_1000_registro_mob")
                  {
                      $achou = true;
                  }
                  elseif ($achou)
                  {
                      unset($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu][$apl]);
                      $this->Change_Menu = true;
                  }
              }
          }
      }
      if (!function_exists("nmButtonOutput"))
      {
          include_once($this->Ini->path_lib_php . "nm_gp_config_btn.php");
      }
      include("../_lib/css/" . $this->Ini->str_schema_all . "_form.php");
      $this->Ini->Str_btn_form    = trim($str_button);
      include($this->Ini->path_btn . $this->Ini->Str_btn_form . '/' . $this->Ini->Str_btn_form . $_SESSION['scriptcase']['reg_conf']['css_dir'] . '.php');
      $_SESSION['scriptcase']['css_form_help'] = '../_lib/css/' . $this->Ini->str_schema_all . "_form.css";
      $_SESSION['scriptcase']['css_form_help_dir'] = '../_lib/css/' . $this->Ini->str_schema_all . "_form" . $_SESSION['scriptcase']['reg_conf']['css_dir'] . ".css";
      $this->Db = $this->Ini->Db; 
      $this->nm_new_label['nome_inf_ouvd_1000'] = 'Nome completo';

      $this->Ini->str_google_fonts = isset($str_google_fonts)?$str_google_fonts:'';
      $this->Ini->Img_sep_form    = "/" . trim($str_toolbar_separator);
      $this->Ini->Color_bg_ajax   = !isset($str_ajax_bg)         || "" == trim($str_ajax_bg)         ? "#000" : $str_ajax_bg;
      $this->Ini->Border_c_ajax   = !isset($str_ajax_border_c)   || "" == trim($str_ajax_border_c)   ? ""     : $str_ajax_border_c;
      $this->Ini->Border_s_ajax   = !isset($str_ajax_border_s)   || "" == trim($str_ajax_border_s)   ? ""     : $str_ajax_border_s;
      $this->Ini->Border_w_ajax   = !isset($str_ajax_border_w)   || "" == trim($str_ajax_border_w)   ? ""     : $str_ajax_border_w;
      $this->Ini->Block_img_exp   = !isset($str_block_exp)       || "" == trim($str_block_exp)       ? ""     : $str_block_exp;
      $this->Ini->Block_img_col   = !isset($str_block_col)       || "" == trim($str_block_col)       ? ""     : $str_block_col;
      $this->Ini->Msg_ico_title   = !isset($str_msg_ico_title)   || "" == trim($str_msg_ico_title)   ? ""     : $str_msg_ico_title;
      $this->Ini->Msg_ico_body    = !isset($str_msg_ico_body)    || "" == trim($str_msg_ico_body)    ? ""     : $str_msg_ico_body;
      $this->Ini->Err_ico_title   = !isset($str_err_ico_title)   || "" == trim($str_err_ico_title)   ? ""     : $str_err_ico_title;
      $this->Ini->Err_ico_body    = !isset($str_err_ico_body)    || "" == trim($str_err_ico_body)    ? ""     : $str_err_ico_body;
      $this->Ini->Cal_ico_back    = !isset($str_cal_ico_back)    || "" == trim($str_cal_ico_back)    ? ""     : $str_cal_ico_back;
      $this->Ini->Cal_ico_for     = !isset($str_cal_ico_for)     || "" == trim($str_cal_ico_for)     ? ""     : $str_cal_ico_for;
      $this->Ini->Cal_ico_close   = !isset($str_cal_ico_close)   || "" == trim($str_cal_ico_close)   ? ""     : $str_cal_ico_close;
      $this->Ini->Tab_space       = !isset($str_tab_space)       || "" == trim($str_tab_space)       ? ""     : $str_tab_space;
      $this->Ini->Bubble_tail     = !isset($str_bubble_tail)     || "" == trim($str_bubble_tail)     ? ""     : $str_bubble_tail;
      $this->Ini->Label_sort_pos  = !isset($str_label_sort_pos)  || "" == trim($str_label_sort_pos)  ? ""     : $str_label_sort_pos;
      $this->Ini->Label_sort      = !isset($str_label_sort)      || "" == trim($str_label_sort)      ? ""     : $str_label_sort;
      $this->Ini->Label_sort_asc  = !isset($str_label_sort_asc)  || "" == trim($str_label_sort_asc)  ? ""     : $str_label_sort_asc;
      $this->Ini->Label_sort_desc = !isset($str_label_sort_desc) || "" == trim($str_label_sort_desc) ? ""     : $str_label_sort_desc;
      $this->Ini->Img_status_ok       = !isset($str_img_status_ok)  || "" == trim($str_img_status_ok)   ? ""     : $str_img_status_ok;
      $this->Ini->Img_status_err      = !isset($str_img_status_err) || "" == trim($str_img_status_err)  ? ""     : $str_img_status_err;
      $this->Ini->Css_status          = "scFormInputError";
      $this->Ini->Css_status_pwd_box  = "scFormInputErrorPwdBox";
      $this->Ini->Css_status_pwd_text = "scFormInputErrorPwdText";
      $this->Ini->Error_icon_span      = !isset($str_error_icon_span)  || "" == trim($str_error_icon_span)  ? false  : "message" == $str_error_icon_span;
      $this->Ini->Img_qs_search        = !isset($img_qs_search)        || "" == trim($img_qs_search)        ? "scriptcase__NM__qs_lupa.png"  : $img_qs_search;
      $this->Ini->Img_qs_clean         = !isset($img_qs_clean)         || "" == trim($img_qs_clean)         ? "scriptcase__NM__qs_close.png" : $img_qs_clean;
      $this->Ini->Str_qs_image_padding = !isset($str_qs_image_padding) || "" == trim($str_qs_image_padding) ? "0"                            : $str_qs_image_padding;
      $this->Ini->App_div_tree_img_col = trim($app_div_str_tree_col);
      $this->Ini->App_div_tree_img_exp = trim($app_div_str_tree_exp);
      $this->Ini->form_table_width     = isset($str_form_table_width) && '' != trim($str_form_table_width) ? $str_form_table_width : '';
      $this->Ini->Bubble_tail          = trim($str_bubble_tail);

        $this->classes_100perc_fields['table'] = '';
        $this->classes_100perc_fields['input'] = '';
        $this->classes_100perc_fields['span_input'] = '';
        $this->classes_100perc_fields['span_select'] = '';
        $this->classes_100perc_fields['style_category'] = '';
        $this->classes_100perc_fields['keep_field_size'] = true;


      $this->arr_buttons['voltar']['hint']             = "";
      $this->arr_buttons['voltar']['type']             = "button";
      $this->arr_buttons['voltar']['value']            = "Voltar";
      $this->arr_buttons['voltar']['display']          = "text_fontawesomeicon";
      $this->arr_buttons['voltar']['display_position'] = "text_right";
      $this->arr_buttons['voltar']['style']            = "solid_gray_default";
      $this->arr_buttons['voltar']['image']            = "";
      $this->arr_buttons['voltar']['has_fa']            = "true";
      $this->arr_buttons['voltar']['fontawesomeicon']            = "fas fa-arrow-left";


      $_SESSION['scriptcase']['error_icon']['cadastro_DEN_1000_registro_mob']  = "<img src=\"" . $this->Ini->path_icones . "/scriptcase__NM__btn__NM__scriptcase9_Rhino__NM__nm_scriptcase9_Rhino_error.png\" style=\"border-width: 0px\" align=\"top\">&nbsp;";
      $_SESSION['scriptcase']['error_close']['cadastro_DEN_1000_registro_mob'] = "<td>" . nmButtonOutput($this->arr_buttons, "berrm_clse", "document.getElementById('id_error_display_fixed').style.display = 'none'; document.getElementById('id_error_message_fixed').innerHTML = ''; return false", "document.getElementById('id_error_display_fixed').style.display = 'none'; document.getElementById('id_error_message_fixed').innerHTML = ''; return false", "", "", "", "", "", "", "", $this->Ini->path_botoes, "", "", "", "", "", '', '', '', '', '', '', '', '', "") . "</td>";

      $this->Embutida_proc = isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_proc']) ? $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_proc'] : $this->Embutida_proc;
      $this->Embutida_form = isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_form']) ? $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_form'] : $this->Embutida_form;
      $this->Embutida_call = isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_call']) ? $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_call'] : $this->Embutida_call;

      $this->form_3versions_single = false;

       $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['table_refresh'] = false;

      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit'])
      {
          $this->Grid_editavel = ('on' == $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit']) ? true : false;
      }
      if (isset($this->Grid_editavel) && $this->Grid_editavel)
      {
          $this->Embutida_form  = true;
          $this->Embutida_ronly = true;
      }
      $this->Embutida_multi = false;
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_multi']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_multi'])
      {
          $this->Grid_editavel  = false;
          $this->Embutida_form  = false;
          $this->Embutida_ronly = false;
          $this->Embutida_multi = true;
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_tp_pag']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_tp_pag'])
      {
          $this->form_paginacao = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_tp_pag'];
      }

      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_form']) || '' == $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_form'])
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_form'] = $this->Embutida_form;
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit']) || '' == $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit'])
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit'] = $this->Grid_editavel ? 'on' : 'off';
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit']) || '' == $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit'])
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_grid_edit'] = $this->Embutida_call;
      }

      $this->Ini->cor_grid_par = $this->Ini->cor_grid_impar;
      $this->nm_location = $this->Ini->sc_protocolo . $this->Ini->server . $dir_raiz; 
      $this->nmgp_url_saida  = $nm_url_saida;
      $this->nmgp_form_show  = "on";
      $this->nmgp_form_empty = false;
      $this->Ini->sc_Include($this->Ini->path_lib_php . "/nm_valida.php", "C", "NM_Valida") ; 
      $teste_validade = new NM_Valida ;

      if (isset($this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name']) && '' != $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name'])
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img1_1000_ul_name]))
          {
              $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img1_1000_ul_name];
          }
          $this->anexo_ouvd_img1_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name'];
          $this->anexo_ouvd_img1_1000_scfile_name = substr($this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name'], 12);
          $this->anexo_ouvd_img1_1000_scfile_type = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_type'];
          $this->anexo_ouvd_img1_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_name'];
          $this->anexo_ouvd_img1_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_img1_1000_ul_type'];
      }
      elseif (isset($this->anexo_ouvd_img1_1000_ul_name) && '' != $this->anexo_ouvd_img1_1000_ul_name)
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img1_1000_ul_name]))
          {
              $this->anexo_ouvd_img1_1000_ul_name = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img1_1000_ul_name];
          }
          $this->anexo_ouvd_img1_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->anexo_ouvd_img1_1000_ul_name;
          $this->anexo_ouvd_img1_1000_scfile_name = substr($this->anexo_ouvd_img1_1000_ul_name, 12);
          $this->anexo_ouvd_img1_1000_scfile_type = $this->anexo_ouvd_img1_1000_ul_type;
      }
      if (isset($this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name']) && '' != $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name'])
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img2_1000_ul_name]))
          {
              $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img2_1000_ul_name];
          }
          $this->anexo_ouvd_img2_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name'];
          $this->anexo_ouvd_img2_1000_scfile_name = substr($this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name'], 12);
          $this->anexo_ouvd_img2_1000_scfile_type = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_type'];
          $this->anexo_ouvd_img2_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_name'];
          $this->anexo_ouvd_img2_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_img2_1000_ul_type'];
      }
      elseif (isset($this->anexo_ouvd_img2_1000_ul_name) && '' != $this->anexo_ouvd_img2_1000_ul_name)
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img2_1000_ul_name]))
          {
              $this->anexo_ouvd_img2_1000_ul_name = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_img2_1000_ul_name];
          }
          $this->anexo_ouvd_img2_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->anexo_ouvd_img2_1000_ul_name;
          $this->anexo_ouvd_img2_1000_scfile_name = substr($this->anexo_ouvd_img2_1000_ul_name, 12);
          $this->anexo_ouvd_img2_1000_scfile_type = $this->anexo_ouvd_img2_1000_ul_type;
      }
      if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name']) && '' != $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name'])
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc1_1000_ul_name]))
          {
              $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc1_1000_ul_name];
          }
          $this->anexo_ouvd_doc1_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name'];
          $this->anexo_ouvd_doc1_1000_scfile_name = substr($this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name'], 12);
          $this->anexo_ouvd_doc1_1000_scfile_type = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_type'];
          $this->anexo_ouvd_doc1_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_name'];
          $this->anexo_ouvd_doc1_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_doc1_1000_ul_type'];
      }
      elseif (isset($this->anexo_ouvd_doc1_1000_ul_name) && '' != $this->anexo_ouvd_doc1_1000_ul_name)
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc1_1000_ul_name]))
          {
              $this->anexo_ouvd_doc1_1000_ul_name = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc1_1000_ul_name];
          }
          $this->anexo_ouvd_doc1_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->anexo_ouvd_doc1_1000_ul_name;
          $this->anexo_ouvd_doc1_1000_scfile_name = substr($this->anexo_ouvd_doc1_1000_ul_name, 12);
          $this->anexo_ouvd_doc1_1000_scfile_type = $this->anexo_ouvd_doc1_1000_ul_type;
      }
      if (isset($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name']) && '' != $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name'])
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc2_1000_ul_name]))
          {
              $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc2_1000_ul_name];
          }
          $this->anexo_ouvd_doc2_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name'];
          $this->anexo_ouvd_doc2_1000_scfile_name = substr($this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name'], 12);
          $this->anexo_ouvd_doc2_1000_scfile_type = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_type'];
          $this->anexo_ouvd_doc2_1000_ul_name = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_name'];
          $this->anexo_ouvd_doc2_1000_ul_type = $this->NM_ajax_info['param']['anexo_ouvd_doc2_1000_ul_type'];
      }
      elseif (isset($this->anexo_ouvd_doc2_1000_ul_name) && '' != $this->anexo_ouvd_doc2_1000_ul_name)
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc2_1000_ul_name]))
          {
              $this->anexo_ouvd_doc2_1000_ul_name = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_field_ul_name'][$this->anexo_ouvd_doc2_1000_ul_name];
          }
          $this->anexo_ouvd_doc2_1000 = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->anexo_ouvd_doc2_1000_ul_name;
          $this->anexo_ouvd_doc2_1000_scfile_name = substr($this->anexo_ouvd_doc2_1000_ul_name, 12);
          $this->anexo_ouvd_doc2_1000_scfile_type = $this->anexo_ouvd_doc2_1000_ul_type;
      }

      $this->loadFieldConfig();

      if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['first_time'])
      {
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['new']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['update']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['delete']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['first']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['back']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['forward']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['last']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['qsearch']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['dynsearch']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['summary']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['navpage']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['goto']);
      }
      $this->NM_cancel_return_new = (isset($this->NM_cancel_return_new) && $this->NM_cancel_return_new == 1) ? "1" : "";
      $this->NM_cancel_insert_new = ((isset($this->NM_cancel_insert_new) && $this->NM_cancel_insert_new == 1) || $this->NM_cancel_return_new == 1) ? "document.F5.action='" . $nm_url_saida . "';" : "";
      if (isset($this->NM_btn_insert) && '' != $this->NM_btn_insert && (!isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['insert']) || '' == $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['insert']))
      {
          if ('N' == $this->NM_btn_insert)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert'] = 'off';
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert'] = 'on';
          }
      }
      if (isset($this->NM_btn_new) && 'N' == $this->NM_btn_new)
      {
          $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['new'] = 'off';
      }
      if (isset($this->NM_btn_update) && '' != $this->NM_btn_update && (!isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['update']) || '' == $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['update']))
      {
          if ('N' == $this->NM_btn_update)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['update'] = 'off';
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['update'] = 'on';
          }
      }
      if (isset($this->NM_btn_delete) && '' != $this->NM_btn_delete && (!isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['delete']) || '' == $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['delete']))
      {
          if ('N' == $this->NM_btn_delete)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['delete'] = 'off';
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['delete'] = 'on';
          }
      }
      if (isset($this->NM_btn_navega) && '' != $this->NM_btn_navega)
      {
          if ('N' == $this->NM_btn_navega)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['first']     = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['back']      = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['forward']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['last']      = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['qsearch']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['dynsearch'] = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['summary']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['navpage']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['goto']      = 'off';
              $this->Nav_permite_ava = false;
              $this->Nav_permite_ret = false;
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['first']     = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['back']      = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['forward']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['last']      = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['qsearch']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['dynsearch'] = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['summary']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['navpage']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['goto']      = 'on';
          }
      }

      $this->nmgp_botoes['cancel'] = "on";
      $this->nmgp_botoes['exit'] = "off";
      $this->nmgp_botoes['new'] = "on";
      $this->nmgp_botoes['insert'] = "on";
      $this->nmgp_botoes['copy'] = "off";
      $this->nmgp_botoes['update'] = "off";
      $this->nmgp_botoes['delete'] = "off";
      $this->nmgp_botoes['first'] = "on";
      $this->nmgp_botoes['back'] = "on";
      $this->nmgp_botoes['forward'] = "on";
      $this->nmgp_botoes['last'] = "on";
      $this->nmgp_botoes['summary'] = "on";
      $this->nmgp_botoes['navpage'] = "off";
      $this->nmgp_botoes['goto'] = "off";
      $this->nmgp_botoes['qtline'] = "off";
      $this->nmgp_botoes['reload'] = "off";
      $this->nmgp_botoes['Voltar'] = "on";
      if (isset($this->NM_btn_cancel) && 'N' == $this->NM_btn_cancel)
      {
          $this->nmgp_botoes['cancel'] = "off";
      }
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_orig'] = "";
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_pesq']))
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_pesq'] = "";
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_pesq_filtro'] = "";
      }
      $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_orig'];
      $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_pesq'];
      $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_pesq_filtro'];
      if ($this->NM_ajax_flag && 'event_' == substr($this->NM_ajax_opcao, 0, 6)) {
          $this->nmgp_botoes = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['buttonStatus'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['iframe_filtro']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['iframe_filtro'] == "S")
      {
          $this->nmgp_botoes['exit'] = "off";
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['btn_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['btn_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['btn_display'] as $NM_cada_btn => $NM_cada_opc)
          {
              $this->nmgp_botoes[$NM_cada_btn] = $NM_cada_opc;
          }
      }

      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert'];
          $this->nmgp_botoes['insert'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['insert'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['new']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['new'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['new'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['update']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['update'] != '')
      {
          $this->nmgp_botoes['update'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['update'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['delete']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['delete'] != '')
      {
          $this->nmgp_botoes['delete'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['delete'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['first']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['first'] != '')
      {
          $this->nmgp_botoes['first'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['first'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['back']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['back'] != '')
      {
          $this->nmgp_botoes['back'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['back'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['forward']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['forward'] != '')
      {
          $this->nmgp_botoes['forward'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['forward'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['last']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['last'] != '')
      {
          $this->nmgp_botoes['last'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['last'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['qsearch']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['qsearch'] != '')
      {
          $this->nmgp_botoes['qsearch'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['qsearch'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['dynsearch']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['dynsearch'] != '')
      {
          $this->nmgp_botoes['dynsearch'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['dynsearch'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['summary']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['summary'] != '')
      {
          $this->nmgp_botoes['summary'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['summary'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['navpage']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['navpage'] != '')
      {
          $this->nmgp_botoes['navpage'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['navpage'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['goto']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['goto'] != '')
      {
          $this->nmgp_botoes['goto'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['cadastro_DEN_1000_registro_mob']['goto'];
      }

      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_insert']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_insert'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_insert'];
          $this->nmgp_botoes['insert'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_insert'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_update']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_update'] != '')
      {
          $this->nmgp_botoes['update'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_update'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_delete']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_delete'] != '')
      {
          $this->nmgp_botoes['delete'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_delete'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav'] != '')
      {
          $this->nmgp_botoes['first']   = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav'];
          $this->nmgp_botoes['back']    = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav'];
          $this->nmgp_botoes['forward'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav'];
          $this->nmgp_botoes['last']    = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav'];
      }

      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['under_dashboard']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['under_dashboard'] && !$_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['maximized']) {
          $tmpDashboardApp = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['dashboard_app'];
          if (isset($_SESSION['scriptcase']['dashboard_toolbar'][$tmpDashboardApp]['cadastro_DEN_1000_registro_mob'])) {
              $tmpDashboardButtons = $_SESSION['scriptcase']['dashboard_toolbar'][$tmpDashboardApp]['cadastro_DEN_1000_registro_mob'];

              $this->nmgp_botoes['update']     = $tmpDashboardButtons['form_update']    ? 'on' : 'off';
              $this->nmgp_botoes['new']        = $tmpDashboardButtons['form_insert']    ? 'on' : 'off';
              $this->nmgp_botoes['insert']     = $tmpDashboardButtons['form_insert']    ? 'on' : 'off';
              $this->nmgp_botoes['delete']     = $tmpDashboardButtons['form_delete']    ? 'on' : 'off';
              $this->nmgp_botoes['copy']       = $tmpDashboardButtons['form_copy']      ? 'on' : 'off';
              $this->nmgp_botoes['first']      = $tmpDashboardButtons['form_navigate']  ? 'on' : 'off';
              $this->nmgp_botoes['back']       = $tmpDashboardButtons['form_navigate']  ? 'on' : 'off';
              $this->nmgp_botoes['last']       = $tmpDashboardButtons['form_navigate']  ? 'on' : 'off';
              $this->nmgp_botoes['forward']    = $tmpDashboardButtons['form_navigate']  ? 'on' : 'off';
              $this->nmgp_botoes['navpage']    = $tmpDashboardButtons['form_navpage']   ? 'on' : 'off';
              $this->nmgp_botoes['goto']       = $tmpDashboardButtons['form_goto']      ? 'on' : 'off';
              $this->nmgp_botoes['qtline']     = $tmpDashboardButtons['form_lineqty']   ? 'on' : 'off';
              $this->nmgp_botoes['summary']    = $tmpDashboardButtons['form_summary']   ? 'on' : 'off';
              $this->nmgp_botoes['qsearch']    = $tmpDashboardButtons['form_qsearch']   ? 'on' : 'off';
              $this->nmgp_botoes['dynsearch']  = $tmpDashboardButtons['form_dynsearch'] ? 'on' : 'off';
              $this->nmgp_botoes['reload']     = $tmpDashboardButtons['form_reload']    ? 'on' : 'off';
          }
      }

      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['insert']) && $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['insert'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['insert'];
          $this->nmgp_botoes['insert'] = $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['insert'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['update']) && $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['update'] != '')
      {
          $this->nmgp_botoes['update'] = $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['update'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['delete']) && $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['delete'] != '')
      {
          $this->nmgp_botoes['delete'] = $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['delete'];
      }

      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['field_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['field_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['field_display'] as $NM_cada_field => $NM_cada_opc)
          {
              $this->nmgp_cmp_hidden[$NM_cada_field] = $NM_cada_opc;
              $this->NM_ajax_info['fieldDisplay'][$NM_cada_field] = $NM_cada_opc;
          }
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['field_readonly']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['field_readonly']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['field_readonly'] as $NM_cada_field => $NM_cada_opc)
          {
              $this->nmgp_cmp_readonly[$NM_cada_field] = "on";
              $this->NM_ajax_info['readOnly'][$NM_cada_field] = $NM_cada_opc;
          }
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['exit']) && $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['exit'] != '')
      {
          $_SESSION['scriptcase']['sc_url_saida'][$this->Ini->sc_page]       = $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['exit'];
          $_SESSION['scriptcase']['sc_force_url_saida'][$this->Ini->sc_page] = true;
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_form']))
      {
          $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_form'];
          if (!isset($this->chave)){$this->chave = $this->nmgp_dados_form['chave'];} 
          if (!isset($this->dt_ini_inv_ouvd_1000)){$this->dt_ini_inv_ouvd_1000 = $this->nmgp_dados_form['dt_ini_inv_ouvd_1000'];} 
          if (!isset($this->andamento_inv_ouvd_1000)){$this->andamento_inv_ouvd_1000 = $this->nmgp_dados_form['andamento_inv_ouvd_1000'];} 
          if (!isset($this->conclusao_inv_ouvd_1000)){$this->conclusao_inv_ouvd_1000 = $this->nmgp_dados_form['conclusao_inv_ouvd_1000'];} 
          if (!isset($this->nivel_atend_atual_1000)){$this->nivel_atend_atual_1000 = $this->nmgp_dados_form['nivel_atend_atual_1000'];} 
          if (!isset($this->id_status_ouvd_1000)){$this->id_status_ouvd_1000 = $this->nmgp_dados_form['id_status_ouvd_1000'];} 
          if (!isset($this->id_controlador_1000)){$this->id_controlador_1000 = $this->nmgp_dados_form['id_controlador_1000'];} 
          if (!isset($this->data_hora_cadastro_1000)){$this->data_hora_cadastro_1000 = $this->nmgp_dados_form['data_hora_cadastro_1000'];} 
          if (!isset($this->token_ouvd_1000)){$this->token_ouvd_1000 = $this->nmgp_dados_form['token_ouvd_1000'];} 
      }
      $glo_senha_protect = (isset($_SESSION['scriptcase']['glo_senha_protect'])) ? $_SESSION['scriptcase']['glo_senha_protect'] : "S";
      $this->aba_iframe = false;
      if (isset($_SESSION['scriptcase']['sc_aba_iframe']))
      {
          foreach ($_SESSION['scriptcase']['sc_aba_iframe'] as $aba => $apls_aba)
          {
              if (in_array("cadastro_DEN_1000_registro_mob", $apls_aba))
              {
                  $this->aba_iframe = true;
                  break;
              }
          }
      }
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['iframe_menu'] && (!isset($_SESSION['scriptcase']['menu_mobile']) || empty($_SESSION['scriptcase']['menu_mobile'])))
      {
          $this->aba_iframe = true;
      }
      $this->Ini->sc_Include($this->Ini->path_lib_php . "/nm_gp_limpa.php", "F", "nm_limpa_valor") ; 
      $this->Ini->sc_Include($this->Ini->path_libs . "/nm_gc.php", "F", "nm_gc") ; 
      $_SESSION['scriptcase']['sc_tab_meses']['int'] = array(
                                      $this->Ini->Nm_lang['lang_mnth_janu'],
                                      $this->Ini->Nm_lang['lang_mnth_febr'],
                                      $this->Ini->Nm_lang['lang_mnth_marc'],
                                      $this->Ini->Nm_lang['lang_mnth_apri'],
                                      $this->Ini->Nm_lang['lang_mnth_mayy'],
                                      $this->Ini->Nm_lang['lang_mnth_june'],
                                      $this->Ini->Nm_lang['lang_mnth_july'],
                                      $this->Ini->Nm_lang['lang_mnth_augu'],
                                      $this->Ini->Nm_lang['lang_mnth_sept'],
                                      $this->Ini->Nm_lang['lang_mnth_octo'],
                                      $this->Ini->Nm_lang['lang_mnth_nove'],
                                      $this->Ini->Nm_lang['lang_mnth_dece']);
      $_SESSION['scriptcase']['sc_tab_meses']['abr'] = array(
                                      $this->Ini->Nm_lang['lang_shrt_mnth_janu'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_febr'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_marc'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_apri'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_mayy'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_june'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_july'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_augu'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_sept'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_octo'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_nove'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_dece']);
      $_SESSION['scriptcase']['sc_tab_dias']['int'] = array(
                                      $this->Ini->Nm_lang['lang_days_sund'],
                                      $this->Ini->Nm_lang['lang_days_mond'],
                                      $this->Ini->Nm_lang['lang_days_tued'],
                                      $this->Ini->Nm_lang['lang_days_wend'],
                                      $this->Ini->Nm_lang['lang_days_thud'],
                                      $this->Ini->Nm_lang['lang_days_frid'],
                                      $this->Ini->Nm_lang['lang_days_satd']);
      $_SESSION['scriptcase']['sc_tab_dias']['abr'] = array(
                                      $this->Ini->Nm_lang['lang_shrt_days_sund'],
                                      $this->Ini->Nm_lang['lang_shrt_days_mond'],
                                      $this->Ini->Nm_lang['lang_shrt_days_tued'],
                                      $this->Ini->Nm_lang['lang_shrt_days_wend'],
                                      $this->Ini->Nm_lang['lang_shrt_days_thud'],
                                      $this->Ini->Nm_lang['lang_shrt_days_frid'],
                                      $this->Ini->Nm_lang['lang_shrt_days_satd']);
      nm_gc($this->Ini->path_libs);
      $this->Ini->Gd_missing  = true;
      if(function_exists("getProdVersion"))
      {
         $_SESSION['scriptcase']['sc_prod_Version'] = str_replace(".", "", getProdVersion($this->Ini->path_libs));
         if(function_exists("gd_info"))
         {
            $this->Ini->Gd_missing = false;
         }
      }
      $this->Ini->sc_Include($this->Ini->path_lib_php . "/nm_trata_img.php", "C", "nm_trata_img") ; 
      if (isset($_GET['nm_cal_display']))
      {
          if ($this->Embutida_proc)
          { 
              include_once($this->Ini->path_embutida . 'cadastro_DEN_1000_registro/cadastro_DEN_1000_registro_mob_calendar.php');
          }
          else
          { 
              include_once($this->Ini->path_aplicacao . 'cadastro_DEN_1000_registro_mob_calendar.php');
          }
          exit;
      }

      if (is_file($this->Ini->path_aplicacao . 'cadastro_DEN_1000_registro_mob_help.txt'))
      {
          $arr_link_webhelp = file($this->Ini->path_aplicacao . 'cadastro_DEN_1000_registro_mob_help.txt');
          if ($arr_link_webhelp)
          {
              foreach ($arr_link_webhelp as $str_link_webhelp)
              {
                  $str_link_webhelp = trim($str_link_webhelp);
                  if ('form:' == substr($str_link_webhelp, 0, 5))
                  {
                      $arr_link_parts = explode(':', $str_link_webhelp);
                      if ('' != $arr_link_parts[1] && is_file($this->Ini->root . $this->Ini->path_help . $arr_link_parts[1]))
                      {
                          $this->url_webhelp = $this->Ini->path_help . $arr_link_parts[1];
                      }
                  }
              }
          }
      }

      if (is_dir($this->Ini->path_aplicacao . 'img'))
      {
          $Res_dir_img = @opendir($this->Ini->path_aplicacao . 'img');
          if ($Res_dir_img)
          {
              while (FALSE !== ($Str_arquivo = @readdir($Res_dir_img))) 
              {
                 if (@is_file($this->Ini->path_aplicacao . 'img/' . $Str_arquivo) && '.' != $Str_arquivo && '..' != $this->Ini->path_aplicacao . 'img/' . $Str_arquivo)
                 {
                     @unlink($this->Ini->path_aplicacao . 'img/' . $Str_arquivo);
                 }
              }
          }
          @closedir($Res_dir_img);
          rmdir($this->Ini->path_aplicacao . 'img');
      }

      if ($this->Embutida_proc)
      { 
          require_once($this->Ini->path_embutida . 'cadastro_DEN_1000_registro/cadastro_DEN_1000_registro_mob_erro.class.php');
      }
      else
      { 
          require_once($this->Ini->path_aplicacao . "cadastro_DEN_1000_registro_mob_erro.class.php"); 
      }
      $this->Erro      = new cadastro_DEN_1000_registro_mob_erro();
      $this->Erro->Ini = $this->Ini;
      $this->proc_fast_search = false;
      if ((!isset($nm_opc_lookup) || $nm_opc_lookup != "lookup") && (!isset($nm_opc_php) || $nm_opc_php != "formphp"))
      { 
         if (empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao']))
         { 
             if ($this->chave != "")   
             { 
                 $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao'] = "igual" ;  
             }   
         }   
      } 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao']) && empty($this->nmgp_refresh_fields))
      {
          $this->nmgp_opcao = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao'];  
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao'] = "" ;  
          if ($this->nmgp_opcao == "edit_novo")  
          {
             $this->nmgp_opcao = "novo";
             $this->nm_flag_saida_novo = "S";
          }
      } 
      $this->nm_Start_new = false;
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['start']) && $_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['start'] == 'new')
      {
          $this->nmgp_opcao = "novo";
          $this->nm_Start_new = true;
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao'] = "novo";
          unset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro_mob']['start']);
          unset($_SESSION['scriptcase']['sc_apl_conf']['cadastro_DEN_1000_registro']['start']);
      }
      if ($this->nmgp_opcao == "igual")  
      {
          $this->nmgp_opc_ant = $this->nmgp_opcao;
      } 
      else
      {
          $this->nmgp_opc_ant = (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opc_ant'])) ? $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opc_ant'] : "";
      } 
      if ($this->nmgp_opcao == "novo" || empty($this->nmgp_opcao))  
      {
          $this->nmgp_botoes['Voltar'] = "on";
      }
      elseif ($this->nmgp_opcao == "incluir")  
      {
          $this->nmgp_botoes['Voltar'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['botoes']['Voltar'];
      }
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "muda_form")  
      {
          $this->nmgp_botoes = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['botoes'];
          $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['inicio'];
          $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total'] != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['final'];
      }
      else
      {
      }
      $this->nm_flag_iframe = false;
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_form'])) 
      {
         $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_form'];
      }
      if ($this->nmgp_opcao == "edit_novo")  
      {
          $this->nmgp_opcao = "novo";
          $this->nm_flag_saida_novo = "S";
      }
//
      $this->NM_case_insensitive = false;
      $this->sc_evento = $this->nmgp_opcao;
      $this->sc_insert_on = false;
            if ('ajax_check_file' == $this->nmgp_opcao ){
                 ob_start(); 
                 include_once("../_lib/lib/php/nm_api.php"); 
            switch( $_POST['rsargs'] ){
               default:
                   echo 0;exit;
               break;
               }

            $out1_img_cache = $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['glo_nm_path_imag_temp'] . $file_name;
            $orig_img = $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['glo_nm_path_imag_temp']. '/sc_'.md5(date('YmdHis').basename($_POST['AjaxCheckImg'])).'.gif';
            copy($__file_download, $_SERVER['DOCUMENT_ROOT'].$orig_img);
            echo $orig_img . '_@@NM@@_';            copy($__file_download, $_SERVER['DOCUMENT_ROOT'].$out1_img_cache);
            $sc_obj_img = new nm_trata_img($_SERVER['DOCUMENT_ROOT'].$out1_img_cache, true);

            if(!empty($img_width) && !empty($img_height)){
                $sc_obj_img->setWidth($img_width);
                $sc_obj_img->setHeight($img_height);
            }
                $sc_obj_img->setManterAspecto(true);
            $sc_obj_img->createImg($_SERVER['DOCUMENT_ROOT'].$out1_img_cache);
            echo $out1_img_cache;
               exit;
            }
      if (isset($this->titulo_manifestacao_1000)) { $this->nm_limpa_alfa($this->titulo_manifestacao_1000); }
      if (isset($this->desc_manifestacao_1000)) { $this->nm_limpa_alfa($this->desc_manifestacao_1000); }
      if (isset($this->id_categoria_1100)) { $this->nm_limpa_alfa($this->id_categoria_1100); }
      if (isset($this->desc_area_setor_1000)) { $this->nm_limpa_alfa($this->desc_area_setor_1000); }
      if (isset($this->ouvd_anonima_1000)) { $this->nm_limpa_alfa($this->ouvd_anonima_1000); }
      if (isset($this->nome_inf_ouvd_1000)) { $this->nm_limpa_alfa($this->nome_inf_ouvd_1000); }
      if (isset($this->cpf_cnpj_ouvd_1000)) { $this->nm_limpa_alfa($this->cpf_cnpj_ouvd_1000); }
      if (isset($this->tel_inf_ouvd_1000)) { $this->nm_limpa_alfa($this->tel_inf_ouvd_1000); }
      if (isset($this->email_inf_ouvd_1000)) { $this->nm_limpa_alfa($this->email_inf_ouvd_1000); }
      $Campos_Crit       = "";
      $Campos_erro       = "";
      $Campos_Falta      = array();
      $Campos_Erros      = array();
      $dir_raiz          = strrpos($_SERVER['PHP_SELF'],"/") ;  
      $dir_raiz          =  substr($_SERVER['PHP_SELF'], 0, $dir_raiz + 1) ;  
      $this->Field_no_validate = (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Field_no_validate'])) ? $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Field_no_validate'] : array();
      $this->nm_location = $this->Ini->sc_protocolo . $this->Ini->server . $dir_raiz; 
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opc_edit'] = true;  
     if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_select'])) 
     {
        $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_select'];
     }
   }

   function loadFieldConfig()
   {
      $this->field_config = array();
      //-- dt_ocorrido_1000
      $this->field_config['dt_ocorrido_1000']                 = array();
      $this->field_config['dt_ocorrido_1000']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['dt_ocorrido_1000']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['dt_ocorrido_1000']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'dt_ocorrido_1000');
      //-- dt_ini_inv_ouvd_1000
      $this->field_config['dt_ini_inv_ouvd_1000']                 = array();
      $this->field_config['dt_ini_inv_ouvd_1000']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['dt_ini_inv_ouvd_1000']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['dt_ini_inv_ouvd_1000']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'dt_ini_inv_ouvd_1000');
      //-- nivel_atend_atual_1000
      $this->field_config['nivel_atend_atual_1000']               = array();
      $this->field_config['nivel_atend_atual_1000']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['nivel_atend_atual_1000']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['nivel_atend_atual_1000']['symbol_dec'] = '';
      $this->field_config['nivel_atend_atual_1000']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['nivel_atend_atual_1000']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- id_status_ouvd_1000
      $this->field_config['id_status_ouvd_1000']               = array();
      $this->field_config['id_status_ouvd_1000']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['id_status_ouvd_1000']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['id_status_ouvd_1000']['symbol_dec'] = '';
      $this->field_config['id_status_ouvd_1000']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['id_status_ouvd_1000']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- id_controlador_1000
      $this->field_config['id_controlador_1000']               = array();
      $this->field_config['id_controlador_1000']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['id_controlador_1000']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['id_controlador_1000']['symbol_dec'] = '';
      $this->field_config['id_controlador_1000']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['id_controlador_1000']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- data_hora_cadastro_1000
      $this->field_config['data_hora_cadastro_1000']                 = array();
      $this->field_config['data_hora_cadastro_1000']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'] . ';' . $_SESSION['scriptcase']['reg_conf']['time_format'];
      $this->field_config['data_hora_cadastro_1000']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['data_hora_cadastro_1000']['time_sep']     = $_SESSION['scriptcase']['reg_conf']['time_sep'];
      $this->field_config['data_hora_cadastro_1000']['date_display'] = "ddmmaaaa;hhiiss";
      $this->new_date_format('DH', 'data_hora_cadastro_1000');
   }

   function controle()
   {
        global $nm_url_saida, $teste_validade, 
               $glo_senha_protect, $nm_apl_dependente, $nm_form_submit, $sc_check_excl, $nm_opc_form_php, $nm_call_php, $nm_opc_lookup;


      $this->ini_controle();

      if ('' != $_SESSION['scriptcase']['change_regional_old'])
      {
          $_SESSION['scriptcase']['str_conf_reg'] = $_SESSION['scriptcase']['change_regional_old'];
          $this->Ini->regionalDefault($_SESSION['scriptcase']['str_conf_reg']);
          $this->loadFieldConfig();
          $this->nm_tira_formatacao();

          $_SESSION['scriptcase']['str_conf_reg'] = $_SESSION['scriptcase']['change_regional_new'];
          $this->Ini->regionalDefault($_SESSION['scriptcase']['str_conf_reg']);
          $this->loadFieldConfig();
          $guarda_formatado = $this->formatado;
          $this->nm_formatar_campos();
          $this->formatado = $guarda_formatado;

          $_SESSION['scriptcase']['change_regional_old'] = '';
          $_SESSION['scriptcase']['change_regional_new'] = '';
      }

      if ($nm_form_submit == 1 && ($this->nmgp_opcao == 'inicio' || $this->nmgp_opcao == 'igual'))
      {
          $this->nm_tira_formatacao();
      }
      if (!$this->NM_ajax_flag || 'alterar' != $this->nmgp_opcao || 'submit_form' != $this->NM_ajax_opcao)
      {
         $this->instr_senha = "Esta chave permite acompanhar o andamento da sua manifestação na ouvidoria e enviar novas informações, se necessário.

Se a manifestação for anônima, guarde esta chave com cuidado, pois ela será a única forma de acesso ao acompanhamento.

Caso opte por se identificar informando seu e-mail, a chave também será enviada para o endereço eletrônico informado.";
      }
//
//-----> 
//
      if ($this->NM_ajax_flag && 'validate_' == substr($this->NM_ajax_opcao, 0, 9))
      {
          if ('validate_ouvd_anonima_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'ouvd_anonima_1000');
          }
          if ('validate_nome_inf_ouvd_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'nome_inf_ouvd_1000');
          }
          if ('validate_cpf_cnpj_ouvd_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'cpf_cnpj_ouvd_1000');
          }
          if ('validate_email_inf_ouvd_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'email_inf_ouvd_1000');
          }
          if ('validate_tel_inf_ouvd_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'tel_inf_ouvd_1000');
          }
          if ('validate_id_categoria_1100' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'id_categoria_1100');
          }
          if ('validate_desc_area_setor_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'desc_area_setor_1000');
          }
          if ('validate_titulo_manifestacao_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'titulo_manifestacao_1000');
          }
          if ('validate_desc_manifestacao_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'desc_manifestacao_1000');
          }
          if ('validate_dt_ocorrido_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'dt_ocorrido_1000');
          }
          if ('validate_anexo_ouvd_img1_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'anexo_ouvd_img1_1000');
          }
          if ('validate_anexo_ouvd_img2_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'anexo_ouvd_img2_1000');
          }
          if ('validate_anexo_ouvd_doc1_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'anexo_ouvd_doc1_1000');
          }
          if ('validate_anexo_ouvd_doc2_1000' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'anexo_ouvd_doc2_1000');
          }
          if ('validate_codigo' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'codigo');
          }
          cadastro_DEN_1000_registro_mob_pack_ajax_response();
          exit;
      }
      if ($this->NM_ajax_flag && 'event_' == substr($this->NM_ajax_opcao, 0, 6))
      {
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
          if ('event_ouvd_anonima_1000_onclick' == $this->NM_ajax_opcao)
          {
              $this->ouvd_anonima_1000_onClick();
          }
          cadastro_DEN_1000_registro_mob_pack_ajax_response();
          exit;
      }
      if (isset($this->sc_inline_call) && 'Y' == $this->sc_inline_call)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['inline_form_seq'] = $this->sc_seq_row;
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
      }
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "recarga_mobile" || $this->nmgp_opcao == "muda_form") 
      {
          $this->upload_img_doc($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
          $nm_sc_sv_opcao = $this->nmgp_opcao; 
          $this->nmgp_opcao = "nada"; 
          $this->nm_acessa_banco();
          if ($this->NM_ajax_flag)
          {
              $this->ajax_return_values();
              cadastro_DEN_1000_registro_mob_pack_ajax_response();
              exit;
          }
          $this->nm_formatar_campos();
          $this->nmgp_opcao = $nm_sc_sv_opcao; 
          $this->nm_gera_html();
          $this->NM_close_db(); 
          $this->nmgp_opcao = ""; 
          exit; 
      }
      if ($this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "excluir") 
      {
          $this->nome_inf_ouvd_1000 = sc_strip_script($this->nome_inf_ouvd_1000, $_SESSION['scriptcase']['charset']);
          $this->nome_inf_ouvd_1000 = sc_strip_tags($this->nome_inf_ouvd_1000, $_SESSION['scriptcase']['charset']);
          $this->tel_inf_ouvd_1000 = sc_strip_script($this->tel_inf_ouvd_1000, $_SESSION['scriptcase']['charset']);
          $this->tel_inf_ouvd_1000 = sc_strip_tags($this->tel_inf_ouvd_1000, $_SESSION['scriptcase']['charset']);
          $this->codigo = sc_strip_script($this->codigo, $_SESSION['scriptcase']['charset']);
          $this->codigo = sc_strip_tags($this->codigo, $_SESSION['scriptcase']['charset']);
          $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
          if ($Campos_Crit != "") 
          {
              $Campos_Crit = $this->Ini->Nm_lang['lang_errm_flds'] . ' ' . $Campos_Crit ; 
          }
          if ($Campos_Crit != "" || !empty($Campos_Falta) || $this->Campos_Mens_erro != "")
          {
              if ($this->NM_ajax_flag)
              {
                  cadastro_DEN_1000_registro_mob_pack_ajax_response();
                  exit;
              }
              $campos_erro = $this->Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros, 4);
              $this->Campos_Mens_erro = ""; 
              $this->Erro->mensagem(__FILE__, __LINE__, "critica", $campos_erro, '', true, true); 
              $this->nmgp_opc_ant = $this->nmgp_opcao ; 
              if ($this->nmgp_opcao == "incluir" && $nm_apl_dependente == 1) 
              { 
                  $this->nm_flag_saida_novo = "S";; 
              }
              if ($this->nmgp_opcao == "incluir") 
              { 
                  $GLOBALS["erro_incl"] = 1; 
              }
              $this->nmgp_opcao = "nada" ; 
          }
      }
      elseif (isset($nm_form_submit) && 1 == $nm_form_submit && $this->nmgp_opcao != "menu_link" && $this->nmgp_opcao != "recarga_mobile")
      {
      }
//
      if ($this->nmgp_opcao != "nada")
      {
          $this->nm_acessa_banco();
      }
      else
      {
           if ($this->nmgp_opc_ant == "incluir") 
           { 
               $this->nm_proc_onload(false);
           }
           else
           { 
              $this->nm_guardar_campos();
           }
      }
      if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form" && !$this->Apl_com_erro)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['recarga'] = $this->nmgp_opcao;
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_redir_insert']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_redir_insert'] == "ok")
          {
              if ($this->sc_evento == "insert" || ($this->nmgp_opc_ant == "novo" && $this->nmgp_opcao == "novo" && $this->sc_evento == "novo"))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_redir_atualiz']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_redir_atualiz'] == "ok")
          {
              if ($this->sc_evento == "update")
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
              if ($this->sc_evento == "delete")
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
      }
      if ($this->NM_ajax_flag && 'navigate_form' == $this->NM_ajax_opcao)
      {
          $this->ajax_return_values();
          $this->ajax_add_parameters();
          cadastro_DEN_1000_registro_mob_pack_ajax_response();
          exit;
      }
      $this->nm_formatar_campos();
      if ($this->NM_ajax_flag)
      {
          $this->NM_ajax_info['result'] = 'OK';
          if ('alterar' == $this->NM_ajax_info['param']['nmgp_opcao'])
          {
              $this->NM_ajax_info['msgDisplay'] = NM_charset_to_utf8($this->Ini->Nm_lang['lang_othr_ajax_frmu']);
          }
          cadastro_DEN_1000_registro_mob_pack_ajax_response();
          exit;
      }
      $this->nm_gera_html();
      $this->NM_close_db(); 
      $this->nmgp_opcao = ""; 
      if ($this->Change_Menu)
      {
          $apl_menu  = $_SESSION['scriptcase']['menu_atual'];
          $Arr_rastro = array();
          if (isset($_SESSION['scriptcase']['menu_apls'][$apl_menu][$this->sc_init_menu]) && count($_SESSION['scriptcase']['menu_apls'][$apl_menu][$this->sc_init_menu]) > 1)
          {
              foreach ($_SESSION['scriptcase']['menu_apls'][$apl_menu][$this->sc_init_menu] as $menu => $apls)
              {
                 $Arr_rastro[] = "'<a href=\"" . $apls['link'] . "?script_case_init=" . $this->sc_init_menu . "\" target=\"#NMIframe#\">" . $apls['label'] . "</a>'";
              }
              $ult_apl = count($Arr_rastro) - 1;
              unset($Arr_rastro[$ult_apl]);
              $rastro = implode(",", $Arr_rastro);
?>
  <script type="text/javascript">
     link_atual = new Array (<?php echo $rastro ?>);
     if (parent.writeFastMenu)
     {
         parent.writeFastMenu(link_atual);
     }
  </script>
<?php
          }
          else
          {
?>
  <script type="text/javascript">
     if (parent.clearFastMenu)
     {
        parent.clearFastMenu();
     }
  </script>
<?php
          }
      }
   }
  function html_export_print($nm_arquivo_html, $nmgp_password)
  {
      $Html_password = "";
          $Arq_base  = $this->Ini->root . $this->Ini->path_imag_temp . $nm_arquivo_html;
          $Parm_pass = ($Html_password != "") ? " -p" : "";
          $Zip_name = "sc_prt_" . date("YmdHis") . "_" . rand(0, 1000) . "cadastro_DEN_1000_registro_mob.zip";
          $Arq_htm = $this->Ini->path_imag_temp . "/" . $Zip_name;
          $Arq_zip = $this->Ini->root . $Arq_htm;
          $Zip_f     = (FALSE !== strpos($Arq_zip, ' ')) ? " \"" . $Arq_zip . "\"" :  $Arq_zip;
          $Arq_input = (FALSE !== strpos($Arq_base, ' ')) ? " \"" . $Arq_base . "\"" :  $Arq_base;
           if (is_file($Arq_zip)) {
               unlink($Arq_zip);
           }
           $str_zip = "";
           if (FALSE !== strpos(strtolower(php_uname()), 'windows')) 
           {
               chdir($this->Ini->path_third . "/zip/windows");
               $str_zip = "zip.exe " . strtoupper($Parm_pass) . " -j " . $Html_password . " " . $Zip_f . " " . $Arq_input;
           }
           elseif (FALSE !== strpos(strtolower(php_uname()), 'linux')) 
           {
                if (FALSE !== strpos(strtolower(php_uname()), 'i686')) 
                {
                    chdir($this->Ini->path_third . "/zip/linux-i386/bin");
                }
                else
                {
                    chdir($this->Ini->path_third . "/zip/linux-amd64/bin");
                }
               $str_zip = "./7za " . $Parm_pass . $Html_password . " a " . $Zip_f . " " . $Arq_input;
           }
           elseif (FALSE !== strpos(strtolower(php_uname()), 'darwin'))
           {
               chdir($this->Ini->path_third . "/zip/mac/bin");
               $str_zip = "./7za " . $Parm_pass . $Html_password . " a " . $Zip_f . " " . $Arq_input;
           }
           if (!empty($str_zip)) {
               exec($str_zip);
           }
           // ----- ZIP log
           $fp = @fopen(trim(str_replace(array(".zip",'"'), array(".log",""), $Zip_f)), 'w');
           if ($fp)
           {
               @fwrite($fp, $str_zip . "\r\n\r\n");
               @fclose($fp);
           }
           foreach ($this->Ini->Img_export_zip as $cada_img_zip)
           {
               $str_zip      = "";
              $cada_img_zip = '"' . $cada_img_zip . '"';
               if (FALSE !== strpos(strtolower(php_uname()), 'windows')) 
               {
                   $str_zip = "zip.exe " . strtoupper($Parm_pass) . " -j -u " . $Html_password . " " . $Zip_f . " " . $cada_img_zip;
               }
               elseif (FALSE !== strpos(strtolower(php_uname()), 'linux')) 
               {
                   $str_zip = "./7za " . $Parm_pass . $Html_password . " a " . $Zip_f . " " . $cada_img_zip;
               }
               elseif (FALSE !== strpos(strtolower(php_uname()), 'darwin'))
               {
                   $str_zip = "./7za " . $Parm_pass . $Html_password . " a " . $Zip_f . " " . $cada_img_zip;
               }
               if (!empty($str_zip)) {
                   exec($str_zip);
               }
               // ----- ZIP log
               $fp = @fopen(trim(str_replace(array(".zip",'"'), array(".log",""), $Zip_f)), 'a');
               if ($fp)
               {
                   @fwrite($fp, $str_zip . "\r\n\r\n");
                   @fclose($fp);
               }
           }
           if (is_file($Arq_zip)) {
               unlink($Arq_base);
           } 
          $path_doc_md5 = md5($Arq_htm);
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob'][$path_doc_md5][0] = $Arq_htm;
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob'][$path_doc_md5][1] = $Zip_name;
?><!DOCTYPE html>
<HTML<?php echo $_SESSION['scriptcase']['reg_conf']['html_dir'] ?>>
<HEAD>
 <TITLE><?php echo strip_tags("Cadastrar Manifestação") ?></TITLE>
 <META http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['scriptcase']['charset_html'] ?>" />
<?php

if (isset($_SESSION['scriptcase']['device_mobile']) && $_SESSION['scriptcase']['device_mobile'] && $_SESSION['scriptcase']['display_mobile'])
{
?>
 <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<?php
}

?>
 <META http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT"/>
 <META http-equiv="Last-Modified" content="<?php echo gmdate("D, d M Y H:i:s"); ?> GMT"/>
 <META http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate"/>
 <META http-equiv="Cache-Control" content="post-check=0, pre-check=0"/>
 <META http-equiv="Pragma" content="no-cache"/>
  <link rel="stylesheet" type="text/css" href="../_lib/css/<?php echo $this->Ini->str_schema_all ?>_export.css" /> 
  <link rel="stylesheet" type="text/css" href="../_lib/css/<?php echo $this->Ini->str_schema_all ?>_export<?php echo $_SESSION['scriptcase']['reg_conf']['css_dir'] ?>.css" /> 
  <link rel="stylesheet" type="text/css" href="../_lib/buttons/<?php echo $this->Ini->Str_btn_form . '/' . $this->Ini->Str_btn_form ?>.css" /> 
  <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_prod; ?>/third/font-awesome/6/css/all.min.css" /> 
  <link rel="shortcut icon" href="../_lib/img/usr__NM__bg__NM__Grupo 1003.png">
</HEAD>
<BODY class="scExportPage">
<table style="border-collapse: collapse; border-width: 0; height: 100%; width: 100%"><tr><td style="padding: 0; text-align: center; vertical-align: top">
 <table class="scExportTable" align="center">
  <tr>
   <td class="scExportTitle" style="height: 25px">PRINT</td>
  </tr>
  <tr>
   <td class="scExportLine" style="width: 100%">
    <table style="border-collapse: collapse; border-width: 0; width: 100%"><tr><td class="scExportLineFont" style="padding: 3px 0 0 0" id="idMessage">
    <?php echo $this->Ini->Nm_lang['lang_othr_file_msge'] ?>
    </td><td class="scExportLineFont" style="text-align:right; padding: 3px 0 0 0">
   <?php echo nmButtonOutput($this->arr_buttons, "bexportview", "document.Fview.submit()", "document.Fview.submit()", "idBtnView", "", "", "", "absmiddle", "", "0", $this->Ini->path_botoes, "", "", "", "", "", '', '', '', '', '', '', '', '', "");?>

   <?php echo nmButtonOutput($this->arr_buttons, "bdownload", "document.Fdown.submit()", "document.Fdown.submit()", "idBtnDown", "", "", "", "absmiddle", "", "0", $this->Ini->path_botoes, "", "", "", "", "", '', '', '', '', '', '', '', '', "");?>

   <?php echo nmButtonOutput($this->arr_buttons, "bvoltar", "document.F0.submit()", "document.F0.submit()", "idBtnBack", "", "", "", "absmiddle", "", "0", $this->Ini->path_botoes, "", "", "", "", "", '', '', '', '', '', '', '', '', "");?>

    </td></tr></table>
   </td>
  </tr>
 </table>
</td></tr></table>
<form name="Fview" method="get" action="<?php echo  $this->form_encode_input($Arq_htm) ?>" target="_self" style="display: none"> 
</form>
<form name="Fdown" method="get" action="cadastro_DEN_1000_registro_mob_download.php" target="_self" style="display: none"> 
<input type="hidden" name="script_case_init" value="<?php echo $this->form_encode_input($this->Ini->sc_page); ?>"> 
<input type="hidden" name="nm_tit_doc" value="cadastro_DEN_1000_registro_mob"> 
<input type="hidden" name="nm_name_doc" value="<?php echo $path_doc_md5 ?>"> 
</form>
<form name="F0" method=post action="cadastro_DEN_1000_registro_mob.php" target="_self" style="display: none"> 
<input type="hidden" name="script_case_init" value="<?php echo $this->form_encode_input($this->Ini->sc_page); ?>"> 
<input type="hidden" name="nmgp_opcao" value="<?php echo $this->nmgp_opcao ?>"> 
</form> 
         </BODY>
         </HTML>
<?php
          exit;
  }
//
//--------------------------------------------------------------------------------------
   function NM_has_trans()
   {
       return !in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access);
   }
//
//--------------------------------------------------------------------------------------
   function NM_commit_db()
   {
       if ($this->Ini->sc_tem_trans_banco && !$this->Embutida_proc)
       { 
           $this->Db->CommitTrans(); 
           $this->Ini->sc_tem_trans_banco = false;
       } 
   }
//
//--------------------------------------------------------------------------------------
   function NM_rollback_db()
   {
       if ($this->Ini->sc_tem_trans_banco && !$this->Embutida_proc)
       { 
           $this->Db->RollbackTrans(); 
           $this->Ini->sc_tem_trans_banco = false;
       } 
   }
//
//--------------------------------------------------------------------------------------
   function NM_close_db()
   {
       if ($this->Db && !$this->Embutida_proc)
       { 
           $this->Db->Close(); 
       } 
   }
//
//--------------------------------------------------------------------------------------
   function Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros, $mode = 3) 
   {
       switch ($mode)
       {
           case 1:
               $campos_erro = array();
               if (!empty($Campos_Crit))
               {
                   $campos_erro[] = $Campos_Crit;
               }
               if (!empty($Campos_Falta))
               {
                   $campos_erro[] = $this->Formata_Campos_Falta($Campos_Falta);
               }
               if (!empty($this->Campos_Mens_erro))
               {
                   $campos_erro[] = $this->Campos_Mens_erro;
               }
               return implode('<br />', $campos_erro);
               break;

           case 2:
               $campos_erro = array();
               if (!empty($Campos_Crit))
               {
                   $campos_erro[] = $Campos_Crit;
               }
               if (!empty($Campos_Falta))
               {
                   $campos_erro[] = $this->Formata_Campos_Falta($Campos_Falta, true);
               }
               if (!empty($this->Campos_Mens_erro))
               {
                   $campos_erro[] = $this->Campos_Mens_erro;
               }
               return implode('<br />', $campos_erro);
               break;

           case 3:
               $campos_erro = array();
               if (!empty($Campos_Erros))
               {
                   $campos_erro[] = $this->Formata_Campos_Erros($Campos_Erros);
               }
               if (!empty($this->Campos_Mens_erro))
               {
                   $campos_mens_erro = str_replace(array('<br />', '<br>', '<BR />'), array('<BR>', '<BR>', '<BR>'), $this->Campos_Mens_erro);
                   $campos_mens_erro = explode('<BR>', $campos_mens_erro);
                   foreach ($campos_mens_erro as $msg_erro)
                   {
                       if ('' != $msg_erro && !in_array($msg_erro, $campos_erro))
                       {
                           $campos_erro[] = $msg_erro;
                       }
                   }
               }
               return implode('<br />', $campos_erro);
               break;

           case 4:
               $campos_erro = array();
               if (!empty($Campos_Erros))
               {
                   $campos_erro[] = $this->Formata_Campos_Erros_SweetAlert($Campos_Erros);
               }
               if (!empty($this->Campos_Mens_erro))
               {
                   $campos_mens_erro = str_replace(array('<br />', '<br>', '<BR />'), array('<BR>', '<BR>', '<BR>'), $this->Campos_Mens_erro);
                   $campos_mens_erro = explode('<BR>', $campos_mens_erro);
                   foreach ($campos_mens_erro as $msg_erro)
                   {
                       if ('' != $msg_erro && !in_array($msg_erro, $campos_erro))
                       {
                           $campos_erro[] = $msg_erro;
                       }
                   }
               }
               return implode('<br />', $campos_erro);
               break;
       }
   }

   function Formata_Campos_Falta($Campos_Falta, $table = false) 
   {
       $Campos_Falta = array_unique($Campos_Falta);

       if (!$table)
       {
           return $this->Ini->Nm_lang['lang_errm_reqd'] . ' ' . implode('; ', $Campos_Falta);
       }

       $aCols  = array();
       $iTotal = sizeof($Campos_Falta);
       $iCols  = 6 > $iTotal ? 1 : (11 > $iTotal ? 2 : (16 > $iTotal ? 3 : 4));
       $iItems = ceil($iTotal / $iCols);
       $iNowC  = 0;
       $iNowI  = 0;

       foreach ($Campos_Falta as $campo)
       {
           $aCols[$iNowC][] = $campo;
           if ($iItems == ++$iNowI)
           {
               $iNowC++;
               $iNowI = 0;
           }
       }

       $sError  = '<table style="border-collapse: collapse; border-width: 0px">';
       $sError .= '<tr>';
       $sError .= '<td class="scFormErrorMessageFont" style="padding: 0; vertical-align: top; white-space: nowrap">' . $this->Ini->Nm_lang['lang_errm_reqd'] . '</td>';
       foreach ($aCols as $aCol)
       {
           $sError .= '<td class="scFormErrorMessageFont" style="padding: 0 6px; vertical-align: top; white-space: nowrap">' . implode('<br />', $aCol) . '</td>';
       }
       $sError .= '</tr>';
       $sError .= '</table>';

       return $sError;
   }

   function Formata_Campos_Crit($Campos_Crit, $table = false) 
   {
       $Campos_Crit = array_unique($Campos_Crit);

       if (!$table)
       {
           return $this->Ini->Nm_lang['lang_errm_flds'] . ' ' . implode('; ', $Campos_Crit);
       }

       $aCols  = array();
       $iTotal = sizeof($Campos_Crit);
       $iCols  = 6 > $iTotal ? 1 : (11 > $iTotal ? 2 : (16 > $iTotal ? 3 : 4));
       $iItems = ceil($iTotal / $iCols);
       $iNowC  = 0;
       $iNowI  = 0;

       foreach ($Campos_Crit as $campo)
       {
           $aCols[$iNowC][] = $campo;
           if ($iItems == ++$iNowI)
           {
               $iNowC++;
               $iNowI = 0;
           }
       }

       $sError  = '<table style="border-collapse: collapse; border-width: 0px">';
       $sError .= '<tr>';
       $sError .= '<td class="scFormErrorMessageFont" style="padding: 0; vertical-align: top; white-space: nowrap">' . $this->Ini->Nm_lang['lang_errm_flds'] . '</td>';
       foreach ($aCols as $aCol)
       {
           $sError .= '<td class="scFormErrorMessageFont" style="padding: 0 6px; vertical-align: top; white-space: nowrap">' . implode('<br />', $aCol) . '</td>';
       }
       $sError .= '</tr>';
       $sError .= '</table>';

       return $sError;
   }

   function Formata_Campos_Erros($Campos_Erros) 
   {
       $sError  = '<table style="border-collapse: collapse; border-width: 0px">';

       foreach ($Campos_Erros as $campo => $erros)
       {
           $sError .= '<tr>';
           $sError .= '<td class="scFormErrorMessageFont" style="padding: 0; vertical-align: top; white-space: nowrap">' . $this->Recupera_Nome_Campo($campo) . ':</td>';
           $sError .= '<td class="scFormErrorMessageFont" style="padding: 0 6px; vertical-align: top; white-space: nowrap">' . implode('<br />', array_unique($erros)) . '</td>';
           $sError .= '</tr>';
       }

       $sError .= '</table>';

       return $sError;
   }

   function Formata_Campos_Erros_SweetAlert($Campos_Erros) 
   {
       $sError  = '';

       foreach ($Campos_Erros as $campo => $erros)
       {
           $sError .= $this->Recupera_Nome_Campo($campo) . ': ' . implode('<br />', array_unique($erros)) . '<br />';
       }

       return $sError;
   }

   function Recupera_Nome_Campo($campo) 
   {
       switch($campo)
       {
           case 'ouvd_anonima_1000':
               return "Deseja permanecer anônimo?";
               break;
           case 'nome_inf_ouvd_1000':
               return "Nome completo";
               break;
           case 'cpf_cnpj_ouvd_1000':
               return "CPF / CNPJ";
               break;
           case 'email_inf_ouvd_1000':
               return "E-mail";
               break;
           case 'tel_inf_ouvd_1000':
               return "Telefone / Whatsapp";
               break;
           case 'id_categoria_1100':
               return "Categoria";
               break;
           case 'desc_area_setor_1000':
               return "Area / Setor / Pessoas envolvidas";
               break;
           case 'titulo_manifestacao_1000':
               return "Assunto";
               break;
           case 'desc_manifestacao_1000':
               return "Descrição detalhada";
               break;
           case 'dt_ocorrido_1000':
               return "Quando ocorreu?";
               break;
           case 'anexo_ouvd_img1_1000':
               return "Imagem 1";
               break;
           case 'anexo_ouvd_img2_1000':
               return "Imagem 2";
               break;
           case 'anexo_ouvd_doc1_1000':
               return "Documento 1";
               break;
           case 'anexo_ouvd_doc2_1000':
               return "Documento 2";
               break;
           case 'codigo':
               return "Segue abaixo a sua chave de acesso.";
               break;
           case 'instr_senha':
               return "";
               break;
           case 'chave':
               return "Digite sua chave de acesso";
               break;
           case 'dt_ini_inv_ouvd_1000':
               return "Dt Ini Inv Ouvd 1000";
               break;
           case 'andamento_inv_ouvd_1000':
               return "Andamento Inv Ouvd 1000";
               break;
           case 'conclusao_inv_ouvd_1000':
               return "Conclusao Inv Ouvd 1000";
               break;
           case 'nivel_atend_atual_1000':
               return "Nivel Atend Atual 1000";
               break;
           case 'id_status_ouvd_1000':
               return "Id Status Ouvd 1000";
               break;
           case 'id_controlador_1000':
               return "Id Controlador 1000";
               break;
           case 'data_hora_cadastro_1000':
               return "Data Hora Cadastro 1000";
               break;
           case 'token_ouvd_1000':
               return "Token Ouvd 1000";
               break;
       }

       return $campo;
   }

   function dateDefaultFormat()
   {
       if (isset($this->Ini->Nm_conf_reg[$this->Ini->str_conf_reg]['data_format']))
       {
           $sDate = str_replace('yyyy', 'Y', $this->Ini->Nm_conf_reg[$this->Ini->str_conf_reg]['data_format']);
           $sDate = str_replace('mm',   'm', $sDate);
           $sDate = str_replace('dd',   'd', $sDate);
           return substr(chunk_split($sDate, 1, $this->Ini->Nm_conf_reg[$this->Ini->str_conf_reg]['data_sep']), 0, -1);
       }
       elseif ('en_us' == $this->Ini->str_lang)
       {
           return 'm/d/Y';
       }
       else
       {
           return 'd/m/Y';
       }
   } // dateDefaultFormat

//
//--------------------------------------------------------------------------------------
   function Valida_campos(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros, $filtro = '') 
   {
     global $nm_browser, $teste_validade;
     if (is_array($filtro) && empty($filtro)) {
         $filtro = '';
     }
//---------------------------------------------------------
     $this->sc_force_zero = array();

     if (!is_array($filtro) && '' == $filtro && isset($this->nm_form_submit) && '1' == $this->nm_form_submit && $this->scCsrfGetToken() != $this->csrf_token)
     {
          $this->Campos_Mens_erro .= (empty($this->Campos_Mens_erro)) ? "" : "<br />";
          $this->Campos_Mens_erro .= "CSRF: " . $this->Ini->Nm_lang['lang_errm_ajax_csrf'];
          if ($this->NM_ajax_flag)
          {
              if (!isset($this->NM_ajax_info['errList']['geral_cadastro_DEN_1000_registro_mob']) || !is_array($this->NM_ajax_info['errList']['geral_cadastro_DEN_1000_registro_mob']))
              {
                  $this->NM_ajax_info['errList']['geral_cadastro_DEN_1000_registro_mob'] = array();
              }
              $this->NM_ajax_info['errList']['geral_cadastro_DEN_1000_registro_mob'][] = "CSRF: " . $this->Ini->Nm_lang['lang_errm_ajax_csrf'];
          }
     }
      if ((!is_array($filtro) && ('' == $filtro || 'ouvd_anonima_1000' == $filtro)) || (is_array($filtro) && in_array('ouvd_anonima_1000', $filtro)))
        $this->ValidateField_ouvd_anonima_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'nome_inf_ouvd_1000' == $filtro)) || (is_array($filtro) && in_array('nome_inf_ouvd_1000', $filtro)))
        $this->ValidateField_nome_inf_ouvd_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'cpf_cnpj_ouvd_1000' == $filtro)) || (is_array($filtro) && in_array('cpf_cnpj_ouvd_1000', $filtro)))
        $this->ValidateField_cpf_cnpj_ouvd_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'email_inf_ouvd_1000' == $filtro)) || (is_array($filtro) && in_array('email_inf_ouvd_1000', $filtro)))
        $this->ValidateField_email_inf_ouvd_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'tel_inf_ouvd_1000' == $filtro)) || (is_array($filtro) && in_array('tel_inf_ouvd_1000', $filtro)))
        $this->ValidateField_tel_inf_ouvd_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'id_categoria_1100' == $filtro)) || (is_array($filtro) && in_array('id_categoria_1100', $filtro)))
        $this->ValidateField_id_categoria_1100($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'desc_area_setor_1000' == $filtro)) || (is_array($filtro) && in_array('desc_area_setor_1000', $filtro)))
        $this->ValidateField_desc_area_setor_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'titulo_manifestacao_1000' == $filtro)) || (is_array($filtro) && in_array('titulo_manifestacao_1000', $filtro)))
        $this->ValidateField_titulo_manifestacao_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'desc_manifestacao_1000' == $filtro)) || (is_array($filtro) && in_array('desc_manifestacao_1000', $filtro)))
        $this->ValidateField_desc_manifestacao_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'dt_ocorrido_1000' == $filtro)) || (is_array($filtro) && in_array('dt_ocorrido_1000', $filtro)))
        $this->ValidateField_dt_ocorrido_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'anexo_ouvd_img1_1000' == $filtro)) || (is_array($filtro) && in_array('anexo_ouvd_img1_1000', $filtro)))
        $this->ValidateField_anexo_ouvd_img1_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'anexo_ouvd_img2_1000' == $filtro)) || (is_array($filtro) && in_array('anexo_ouvd_img2_1000', $filtro)))
        $this->ValidateField_anexo_ouvd_img2_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'anexo_ouvd_doc1_1000' == $filtro)) || (is_array($filtro) && in_array('anexo_ouvd_doc1_1000', $filtro)))
        $this->ValidateField_anexo_ouvd_doc1_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'anexo_ouvd_doc2_1000' == $filtro)) || (is_array($filtro) && in_array('anexo_ouvd_doc2_1000', $filtro)))
        $this->ValidateField_anexo_ouvd_doc2_1000($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'codigo' == $filtro)) || (is_array($filtro) && in_array('codigo', $filtro)))
        $this->ValidateField_codigo($Campos_Crit, $Campos_Falta, $Campos_Erros);
      $this->upload_img_doc($Campos_Crit, $Campos_Falta, $Campos_Erros);
//-- converter datas   
          $this->nm_converte_datas();
//---

      if (!isset($this->NM_ajax_flag) || 'validate_' != substr($this->NM_ajax_opcao, 0, 9))
      {
      $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_dt_ocorrido_1000 = $this->dt_ocorrido_1000;
    $original_nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000;
    $original_ouvd_anonima_1000 = $this->ouvd_anonima_1000;
}
  date_default_timezone_set("America/Sao_Paulo");
$currentDate = date("Y-m-d");

if(!$this->ouvd_anonima_1000 ) {
	if(empty($this->nome_inf_ouvd_1000 )) {
		
 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 .= "Nome completo: Campo Obrigatório";
 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_cadastro_DEN_1000_registro_mob';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_cadastro_DEN_1000_registro_mob';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = "Nome completo: Campo Obrigatório";
 }
;
	}
	
}

if(!(empty($this->dt_ocorrido_1000 ) || $this->dt_ocorrido_1000  == "null")&& $this->dt_ocorrido_1000  > $currentDate) {
	
 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 .= "A data do ocorrido não deve ser superior a data atual.";
 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_cadastro_DEN_1000_registro_mob';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_cadastro_DEN_1000_registro_mob';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = "A data do ocorrido não deve ser superior a data atual.";
 }
;
}
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_dt_ocorrido_1000 != $this->dt_ocorrido_1000 || (isset($bFlagRead_dt_ocorrido_1000) && $bFlagRead_dt_ocorrido_1000)))
    {
        $this->ajax_return_values_dt_ocorrido_1000(true);
    }
    if (($original_nome_inf_ouvd_1000 != $this->nome_inf_ouvd_1000 || (isset($bFlagRead_nome_inf_ouvd_1000) && $bFlagRead_nome_inf_ouvd_1000)))
    {
        $this->ajax_return_values_nome_inf_ouvd_1000(true);
    }
    if (($original_ouvd_anonima_1000 != $this->ouvd_anonima_1000 || (isset($bFlagRead_ouvd_anonima_1000) && $bFlagRead_ouvd_anonima_1000)))
    {
        $this->ajax_return_values_ouvd_anonima_1000(true);
    }
}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off'; 
      }
      if (!empty($Campos_Crit) || !empty($Campos_Falta) || !empty($this->Campos_Mens_erro))
      {
          if (!empty($this->sc_force_zero))
          {
              foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
              {
                  eval('$this->' . $sc_force_zero_field . ' = "";');
                  unset($this->sc_force_zero[$i_force_zero]);
              }
          }
      }
   }

    function ValidateField_ouvd_anonima_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
   if (isset($this->Field_no_validate['ouvd_anonima_1000'])) {
       return;
   }
      if ($this->ouvd_anonima_1000 == "" && $this->nmgp_opcao != "excluir")
      { 
        if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['ouvd_anonima_1000']) || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['ouvd_anonima_1000'] == "on")
        { 
          $hasError = true;
          $Campos_Falta[] = "Deseja permanecer anônimo?" ; 
          if (!isset($Campos_Erros['ouvd_anonima_1000']))
          {
              $Campos_Erros['ouvd_anonima_1000'] = array();
          }
          $Campos_Erros['ouvd_anonima_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
                  if (!isset($this->NM_ajax_info['errList']['ouvd_anonima_1000']) || !is_array($this->NM_ajax_info['errList']['ouvd_anonima_1000']))
                  {
                      $this->NM_ajax_info['errList']['ouvd_anonima_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['ouvd_anonima_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
        } 
      } 
      if ($this->ouvd_anonima_1000 != "" && !in_array("ouvd_anonima_1000", $this->sc_force_zero))
      { 
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_ouvd_anonima_1000']) && !in_array($this->ouvd_anonima_1000, $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_ouvd_anonima_1000']))
          {
              $hasError = true;
              $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
              if (!isset($Campos_Erros['ouvd_anonima_1000']))
              {
                  $Campos_Erros['ouvd_anonima_1000'] = array();
              }
              $Campos_Erros['ouvd_anonima_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
              if (!isset($this->NM_ajax_info['errList']['ouvd_anonima_1000']) || !is_array($this->NM_ajax_info['errList']['ouvd_anonima_1000']))
              {
                  $this->NM_ajax_info['errList']['ouvd_anonima_1000'] = array();
              }
              $this->NM_ajax_info['errList']['ouvd_anonima_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
          }
      }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'ouvd_anonima_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_ouvd_anonima_1000

    function ValidateField_nome_inf_ouvd_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['nome_inf_ouvd_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->nome_inf_ouvd_1000) > 300) 
          { 
              $hasError = true;
              $Campos_Crit .= "Nome completo " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 300 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['nome_inf_ouvd_1000']))
              {
                  $Campos_Erros['nome_inf_ouvd_1000'] = array();
              }
              $Campos_Erros['nome_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 300 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['nome_inf_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['nome_inf_ouvd_1000']))
              {
                  $this->NM_ajax_info['errList']['nome_inf_ouvd_1000'] = array();
              }
              $this->NM_ajax_info['errList']['nome_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 300 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'nome_inf_ouvd_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_nome_inf_ouvd_1000

    function ValidateField_cpf_cnpj_ouvd_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      nm_limpa_ciccnpj($this->cpf_cnpj_ouvd_1000) ; 
      if (isset($this->Field_no_validate['cpf_cnpj_ouvd_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (trim($this->cpf_cnpj_ouvd_1000) != "")  
          { 
              if (strlen($this->cpf_cnpj_ouvd_1000) < 12)  
              { 
                  if ($teste_validade->CIC($this->cpf_cnpj_ouvd_1000) == false)  
                  { 
                      $hasError = true;
                  $Campos_Crit .= "CPF / CNPJ; " ; 
                  if (!isset($Campos_Erros['cpf_cnpj_ouvd_1000']))
                  {
                      $Campos_Erros['cpf_cnpj_ouvd_1000'] = array();
                  }
                  $Campos_Erros['cpf_cnpj_ouvd_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000']))
                  {
                      $this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  } 
              } 
              else 
              { 
                  if ($teste_validade->CNPJ($this->cpf_cnpj_ouvd_1000) == false)  
                  { 
                      $hasError = true;
                  $Campos_Crit .= "CPF / CNPJ; " ; 
                  if (!isset($Campos_Erros['cpf_cnpj_ouvd_1000']))
                  {
                      $Campos_Erros['cpf_cnpj_ouvd_1000'] = array();
                  }
                  $Campos_Erros['cpf_cnpj_ouvd_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000']))
                  {
                      $this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['cpf_cnpj_ouvd_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  } 
              } 
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'cpf_cnpj_ouvd_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_cpf_cnpj_ouvd_1000

    function ValidateField_email_inf_ouvd_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['email_inf_ouvd_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (trim($this->email_inf_ouvd_1000) != "")  
          { 
              if ($teste_validade->Email($this->email_inf_ouvd_1000) == false)  
              { 
                  $hasError = true;
                      $Campos_Crit .= "E-mail; " ; 
                  if (!isset($Campos_Erros['email_inf_ouvd_1000']))
                  {
                      $Campos_Erros['email_inf_ouvd_1000'] = array();
                  }
                  $Campos_Erros['email_inf_ouvd_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                      if (!isset($this->NM_ajax_info['errList']['email_inf_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['email_inf_ouvd_1000']))
                      {
                          $this->NM_ajax_info['errList']['email_inf_ouvd_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['email_inf_ouvd_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'email_inf_ouvd_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_email_inf_ouvd_1000

    function ValidateField_tel_inf_ouvd_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['tel_inf_ouvd_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      {
          if (!$this->nm_validate_mask($this->tel_inf_ouvd_1000, explode(';', "(99) 9 9999-9999")))  
          { 
              $hasError = true;
              $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
              if (!isset($Campos_Erros['tel_inf_ouvd_1000']))
              {
                  $Campos_Erros['tel_inf_ouvd_1000'] = array();
              }
              $Campos_Erros['tel_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                  if (!isset($this->NM_ajax_info['errList']['tel_inf_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['tel_inf_ouvd_1000']))
                  {
                      $this->NM_ajax_info['errList']['tel_inf_ouvd_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['tel_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
          } 
      }
      $this->nm_tira_mask($this->tel_inf_ouvd_1000, "(99) 9 9999-9999", "(){}[].,;:-+/ "); 
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->tel_inf_ouvd_1000) > 20) 
          { 
              $hasError = true;
              $Campos_Crit .= "Telefone / Whatsapp " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 20 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['tel_inf_ouvd_1000']))
              {
                  $Campos_Erros['tel_inf_ouvd_1000'] = array();
              }
              $Campos_Erros['tel_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 20 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['tel_inf_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['tel_inf_ouvd_1000']))
              {
                  $this->NM_ajax_info['errList']['tel_inf_ouvd_1000'] = array();
              }
              $this->NM_ajax_info['errList']['tel_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 20 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
      $Teste_trab = "01234567890123456789";
      if ($_SESSION['scriptcase']['charset'] != "UTF-8")
      {
          $Teste_trab = NM_conv_charset($Teste_trab, $_SESSION['scriptcase']['charset'], "UTF-8");
      }
;
      $Teste_trab = $Teste_trab . chr(10) . chr(13) ; 
      $Teste_compara = $this->tel_inf_ouvd_1000 ; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          $Teste_critica = 0 ; 
          for ($x = 0; $x < mb_strlen($this->tel_inf_ouvd_1000, $_SESSION['scriptcase']['charset']); $x++) 
          { 
               for ($y = 0; $y < mb_strlen($Teste_trab, $_SESSION['scriptcase']['charset']); $y++) 
               { 
                    if (sc_substr($Teste_compara, $x, 1) == sc_substr($Teste_trab, $y, 1) ) 
                    { 
                        break ; 
                    } 
               } 
               if (sc_substr($Teste_compara, $x, 1) != sc_substr($Teste_trab, $y, 1) )  
               { 
                  $Teste_critica = 1 ; 
               } 
          } 
          if ($Teste_critica == 1) 
          { 
              $hasError = true;
              $Campos_Crit .= "Telefone / Whatsapp " . $this->Ini->Nm_lang['lang_errm_ivch']; 
              if (!isset($Campos_Erros['tel_inf_ouvd_1000']))
              {
                  $Campos_Erros['tel_inf_ouvd_1000'] = array();
              }
              $Campos_Erros['tel_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_ivch'];
              if (!isset($this->NM_ajax_info['errList']['tel_inf_ouvd_1000']) || !is_array($this->NM_ajax_info['errList']['tel_inf_ouvd_1000']))
              {
                  $this->NM_ajax_info['errList']['tel_inf_ouvd_1000'] = array();
              }
              $this->NM_ajax_info['errList']['tel_inf_ouvd_1000'][] = $this->Ini->Nm_lang['lang_errm_ivch'];
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'tel_inf_ouvd_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_tel_inf_ouvd_1000

    function ValidateField_id_categoria_1100(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
   if (isset($this->Field_no_validate['id_categoria_1100'])) {
       return;
   }
   if ($this->nmgp_opcao == "incluir")
   {
      if ($this->id_categoria_1100 == "" && $this->nmgp_opcao != "excluir" && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['id_categoria_1100']) || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['id_categoria_1100'] == "on"))
      {
          $hasError = true;
          $Campos_Falta[] = "Categoria" ; 
          if (!isset($Campos_Erros['id_categoria_1100']))
          {
              $Campos_Erros['id_categoria_1100'] = array();
          }
          $Campos_Erros['id_categoria_1100'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
          if (!isset($this->NM_ajax_info['errList']['id_categoria_1100']) || !is_array($this->NM_ajax_info['errList']['id_categoria_1100']))
          {
              $this->NM_ajax_info['errList']['id_categoria_1100'] = array();
          }
          $this->NM_ajax_info['errList']['id_categoria_1100'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
      }
          if (!empty($this->id_categoria_1100) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']) && !in_array($this->id_categoria_1100, $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']))
          {
              $hasError = true;
              $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
              if (!isset($Campos_Erros['id_categoria_1100']))
              {
                  $Campos_Erros['id_categoria_1100'] = array();
              }
              $Campos_Erros['id_categoria_1100'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
              if (!isset($this->NM_ajax_info['errList']['id_categoria_1100']) || !is_array($this->NM_ajax_info['errList']['id_categoria_1100']))
              {
                  $this->NM_ajax_info['errList']['id_categoria_1100'] = array();
              }
              $this->NM_ajax_info['errList']['id_categoria_1100'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
          }
   }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'id_categoria_1100';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_id_categoria_1100

    function ValidateField_desc_area_setor_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['desc_area_setor_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->desc_area_setor_1000) > 255) 
          { 
              $hasError = true;
              $Campos_Crit .= "Area / Setor / Pessoas envolvidas " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 255 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['desc_area_setor_1000']))
              {
                  $Campos_Erros['desc_area_setor_1000'] = array();
              }
              $Campos_Erros['desc_area_setor_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 255 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['desc_area_setor_1000']) || !is_array($this->NM_ajax_info['errList']['desc_area_setor_1000']))
              {
                  $this->NM_ajax_info['errList']['desc_area_setor_1000'] = array();
              }
              $this->NM_ajax_info['errList']['desc_area_setor_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 255 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'desc_area_setor_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_desc_area_setor_1000

    function ValidateField_titulo_manifestacao_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['titulo_manifestacao_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir" && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['titulo_manifestacao_1000']) || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['titulo_manifestacao_1000'] == "on")) 
      { 
          if ($this->titulo_manifestacao_1000 == "")  
          { 
              $hasError = true;
              $Campos_Falta[] =  "Assunto" ; 
              if (!isset($Campos_Erros['titulo_manifestacao_1000']))
              {
                  $Campos_Erros['titulo_manifestacao_1000'] = array();
              }
              $Campos_Erros['titulo_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
                  if (!isset($this->NM_ajax_info['errList']['titulo_manifestacao_1000']) || !is_array($this->NM_ajax_info['errList']['titulo_manifestacao_1000']))
                  {
                      $this->NM_ajax_info['errList']['titulo_manifestacao_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['titulo_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
          } 
      } 
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->titulo_manifestacao_1000) > 180) 
          { 
              $hasError = true;
              $Campos_Crit .= "Assunto " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 180 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['titulo_manifestacao_1000']))
              {
                  $Campos_Erros['titulo_manifestacao_1000'] = array();
              }
              $Campos_Erros['titulo_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 180 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['titulo_manifestacao_1000']) || !is_array($this->NM_ajax_info['errList']['titulo_manifestacao_1000']))
              {
                  $this->NM_ajax_info['errList']['titulo_manifestacao_1000'] = array();
              }
              $this->NM_ajax_info['errList']['titulo_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 180 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'titulo_manifestacao_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_titulo_manifestacao_1000

    function ValidateField_desc_manifestacao_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['desc_manifestacao_1000'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir" && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['desc_manifestacao_1000']) || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['php_cmp_required']['desc_manifestacao_1000'] == "on")) 
      { 
          if ($this->desc_manifestacao_1000 == "")  
          { 
              $hasError = true;
              $Campos_Falta[] =  "Descrição detalhada" ; 
              if (!isset($Campos_Erros['desc_manifestacao_1000']))
              {
                  $Campos_Erros['desc_manifestacao_1000'] = array();
              }
              $Campos_Erros['desc_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
                  if (!isset($this->NM_ajax_info['errList']['desc_manifestacao_1000']) || !is_array($this->NM_ajax_info['errList']['desc_manifestacao_1000']))
                  {
                      $this->NM_ajax_info['errList']['desc_manifestacao_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['desc_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
          } 
      } 
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->desc_manifestacao_1000) > 32767) 
          { 
              $hasError = true;
              $Campos_Crit .= "Descrição detalhada " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['desc_manifestacao_1000']))
              {
                  $Campos_Erros['desc_manifestacao_1000'] = array();
              }
              $Campos_Erros['desc_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['desc_manifestacao_1000']) || !is_array($this->NM_ajax_info['errList']['desc_manifestacao_1000']))
              {
                  $this->NM_ajax_info['errList']['desc_manifestacao_1000'] = array();
              }
              $this->NM_ajax_info['errList']['desc_manifestacao_1000'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'desc_manifestacao_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_desc_manifestacao_1000

    function ValidateField_dt_ocorrido_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      nm_limpa_data($this->dt_ocorrido_1000, $this->field_config['dt_ocorrido_1000']['date_sep']) ; 
      if (isset($this->Field_no_validate['dt_ocorrido_1000'])) {
          return;
      }
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          $guarda_datahora = $this->field_config['dt_ocorrido_1000']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['dt_ocorrido_1000']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['dt_ocorrido_1000']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['dt_ocorrido_1000']['date_sep']) ; 
          if (trim($this->dt_ocorrido_1000) != "")  
          { 
              $validateTest = $teste_validade->Data($this->dt_ocorrido_1000, $Format_Data, $trab_dt_min, $trab_dt_max);
              if ($validateTest == false)
              { 
                  $hasError = true;
                  $Campos_Crit .= "Quando ocorreu?; " ; 
                  if (!isset($Campos_Erros['dt_ocorrido_1000']))
                  {
                      $Campos_Erros['dt_ocorrido_1000'] = array();
                  }
                  $Campos_Erros['dt_ocorrido_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['dt_ocorrido_1000']) || !is_array($this->NM_ajax_info['errList']['dt_ocorrido_1000']))
                  {
                      $this->NM_ajax_info['errList']['dt_ocorrido_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['dt_ocorrido_1000'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['dt_ocorrido_1000']['date_format'] = $guarda_datahora; 
       } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'dt_ocorrido_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_dt_ocorrido_1000

    function ValidateField_anexo_ouvd_img1_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['anexo_ouvd_img1_1000'])) {
          return;
      }
        if ($this->nmgp_opcao != "excluir")
        {
            $sTestFile = $this->anexo_ouvd_img1_1000;
            if ("" != $this->anexo_ouvd_img1_1000 && "S" != $this->anexo_ouvd_img1_1000_limpa && !$teste_validade->ArqExtensao($this->anexo_ouvd_img1_1000, array()))
            {
                $hasError = true;
                $Campos_Crit .= "Imagem 1: " . $this->Ini->Nm_lang['lang_errm_file_invl']; 
                if (!isset($Campos_Erros['anexo_ouvd_img1_1000']))
                {
                    $Campos_Erros['anexo_ouvd_img1_1000'] = array();
                }
                $Campos_Erros['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
                if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']))
                {
                    $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'] = array();
                }
                $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
            }
        }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'anexo_ouvd_img1_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_anexo_ouvd_img1_1000

    function ValidateField_anexo_ouvd_img2_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['anexo_ouvd_img2_1000'])) {
          return;
      }
        if ($this->nmgp_opcao != "excluir")
        {
            $sTestFile = $this->anexo_ouvd_img2_1000;
            if ("" != $this->anexo_ouvd_img2_1000 && "S" != $this->anexo_ouvd_img2_1000_limpa && !$teste_validade->ArqExtensao($this->anexo_ouvd_img2_1000, array()))
            {
                $hasError = true;
                $Campos_Crit .= "Imagem 2: " . $this->Ini->Nm_lang['lang_errm_file_invl']; 
                if (!isset($Campos_Erros['anexo_ouvd_img2_1000']))
                {
                    $Campos_Erros['anexo_ouvd_img2_1000'] = array();
                }
                $Campos_Erros['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
                if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']))
                {
                    $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'] = array();
                }
                $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
            }
        }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'anexo_ouvd_img2_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_anexo_ouvd_img2_1000

    function ValidateField_anexo_ouvd_doc1_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['anexo_ouvd_doc1_1000'])) {
          return;
      }
        if ($this->nmgp_opcao != "excluir")
        {
            $sTestFile = $this->anexo_ouvd_doc1_1000;
            if (!function_exists('sc_upload_unprotect_chars'))
            {
                include_once 'cadastro_DEN_1000_registro_mob_doc_name.php';
            }
            $this->anexo_ouvd_doc1_1000 = sc_upload_unprotect_chars($this->anexo_ouvd_doc1_1000, true);
            $this->anexo_ouvd_doc1_1000_scfile_name = sc_upload_unprotect_chars($this->anexo_ouvd_doc1_1000_scfile_name, true);
            if ("" != $this->anexo_ouvd_doc1_1000 && "S" != $this->anexo_ouvd_doc1_1000_limpa && !$teste_validade->ArqExtensao($this->anexo_ouvd_doc1_1000, array()))
            {
                $hasError = true;
                $Campos_Crit .= "Documento 1: " . $this->Ini->Nm_lang['lang_errm_file_invl']; 
                if (!isset($Campos_Erros['anexo_ouvd_doc1_1000']))
                {
                    $Campos_Erros['anexo_ouvd_doc1_1000'] = array();
                }
                $Campos_Erros['anexo_ouvd_doc1_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
                if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000']))
                {
                    $this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000'] = array();
                }
                $this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
            }
        }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'anexo_ouvd_doc1_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_anexo_ouvd_doc1_1000

    function ValidateField_anexo_ouvd_doc2_1000(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['anexo_ouvd_doc2_1000'])) {
          return;
      }
        if ($this->nmgp_opcao != "excluir")
        {
            $sTestFile = $this->anexo_ouvd_doc2_1000;
            if (!function_exists('sc_upload_unprotect_chars'))
            {
                include_once 'cadastro_DEN_1000_registro_mob_doc_name.php';
            }
            $this->anexo_ouvd_doc2_1000 = sc_upload_unprotect_chars($this->anexo_ouvd_doc2_1000, true);
            $this->anexo_ouvd_doc2_1000_scfile_name = sc_upload_unprotect_chars($this->anexo_ouvd_doc2_1000_scfile_name, true);
            if ("" != $this->anexo_ouvd_doc2_1000 && "S" != $this->anexo_ouvd_doc2_1000_limpa && !$teste_validade->ArqExtensao($this->anexo_ouvd_doc2_1000, array()))
            {
                $hasError = true;
                $Campos_Crit .= "Documento 2: " . $this->Ini->Nm_lang['lang_errm_file_invl']; 
                if (!isset($Campos_Erros['anexo_ouvd_doc2_1000']))
                {
                    $Campos_Erros['anexo_ouvd_doc2_1000'] = array();
                }
                $Campos_Erros['anexo_ouvd_doc2_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
                if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000']))
                {
                    $this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000'] = array();
                }
                $this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
            }
        }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'anexo_ouvd_doc2_1000';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_anexo_ouvd_doc2_1000

    function ValidateField_codigo(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['codigo'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (trim($this->codigo) != "")  
          { 
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'codigo';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_codigo
//
//--------------------------------------------------------------------------------------
   function upload_img_doc(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros, $filtro = '') 
   {
     global $nm_browser;
     if (!empty($Campos_Crit) || !empty($Campos_Falta))
     {
          return;
     }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->anexo_ouvd_img1_1000 == "none") 
          { 
              $this->anexo_ouvd_img1_1000 = ""; 
          } 
          if ($this->anexo_ouvd_img1_1000 != "") 
          { 
              if (!function_exists('sc_upload_unprotect_chars'))
              {
                  include_once 'cadastro_DEN_1000_registro_mob_doc_name.php';
              }
              $this->anexo_ouvd_img1_1000 = sc_upload_unprotect_chars($this->anexo_ouvd_img1_1000, true);
              $this->anexo_ouvd_img1_1000_scfile_name = sc_upload_unprotect_chars($this->anexo_ouvd_img1_1000_scfile_name, true);
              if ($nm_browser == "Opera")  
              { 
                  $this->anexo_ouvd_img1_1000_scfile_type = substr($this->anexo_ouvd_img1_1000_scfile_type, 0, strpos($this->anexo_ouvd_img1_1000_scfile_type, ";")) ; 
              } 
              if ($this->anexo_ouvd_img1_1000_scfile_type == "image/pjpeg" || $this->anexo_ouvd_img1_1000_scfile_type == "image/jpeg" || $this->anexo_ouvd_img1_1000_scfile_type == "image/gif" ||  
                  $this->anexo_ouvd_img1_1000_scfile_type == "image/png" || $this->anexo_ouvd_img1_1000_scfile_type == "image/x-png" || $this->anexo_ouvd_img1_1000_scfile_type == "image/bmp")  
              { 
                  if (!is_file($this->anexo_ouvd_img1_1000) && isset($_SESSION['scriptcase']['charset']) && $_SESSION['scriptcase']['charset'] != 'UTF-8') {
                      $mbConvertFileName = mb_convert_encoding($this->anexo_ouvd_img1_1000, $_SESSION['scriptcase']['charset'], 'UTF-8');
                      $mbConvertScFileName = mb_convert_encoding($this->anexo_ouvd_img1_1000_scfile_name, $_SESSION['scriptcase']['charset'], 'UTF-8');
                      if (is_file($mbConvertFileName)) {
                          $this->anexo_ouvd_img1_1000 = $mbConvertFileName;
                          $this->anexo_ouvd_img1_1000_scfile_name = $mbConvertScFileName;
                      }
                  }
                  if (is_file($this->anexo_ouvd_img1_1000))  
                  { 
                      $this->NM_size_docs[$this->anexo_ouvd_img1_1000_scfile_name] = $this->sc_file_size($this->anexo_ouvd_img1_1000);
                      if ($this->nmgp_opcao == "incluir")
                      { 
                          $this->SC_IMG_anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000;
                      } 
                      else 
                      { 
                          $arq_anexo_ouvd_img1_1000 = fopen($this->anexo_ouvd_img1_1000, "r") ; 
                          $reg_anexo_ouvd_img1_1000 = fread($arq_anexo_ouvd_img1_1000, filesize($this->anexo_ouvd_img1_1000)) ; 
                          fclose($arq_anexo_ouvd_img1_1000) ;  
                      } 
                      $this->anexo_ouvd_img1_1000 =  trim($this->anexo_ouvd_img1_1000_scfile_name) ;  
                      $dir_img = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                     if ($this->nmgp_opcao != "incluir")
                     { 
                      if (nm_mkdir($dir_img))  
                      { 
                          $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_img1_1000_scfile_name, $dir_img, "anexo_ouvd_img1_1000");
                          if (trim($this->anexo_ouvd_img1_1000_scfile_name) != $_test_file)
                          {
                              $this->anexo_ouvd_img1_1000_scfile_name = $_test_file;
                              $this->anexo_ouvd_img1_1000 = $_test_file;
                          }
                          $arq_anexo_ouvd_img1_1000 = fopen($dir_img . trim($this->anexo_ouvd_img1_1000_scfile_name), "w") ; 
                          fwrite($arq_anexo_ouvd_img1_1000, $reg_anexo_ouvd_img1_1000) ;  
                          fclose($arq_anexo_ouvd_img1_1000) ;  
                      } 
                      else 
                      { 
                          $Campos_Crit .= "Imagem 1: " . $this->Ini->Nm_lang['lang_errm_ivdr']; 
                          $this->anexo_ouvd_img1_1000 = "";
                          if (!isset($Campos_Erros['anexo_ouvd_img1_1000']))
                          {
                              $Campos_Erros['anexo_ouvd_img1_1000'] = array();
                          }
                          $Campos_Erros['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                          if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']))
                          {
                              $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'] = array();
                          }
                          $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                      } 
                     } 
                  } 
                  else 
                  { 
                      $Campos_Crit .= "Imagem 1 " . $this->Ini->Nm_lang['lang_errm_upld']; 
                      $this->anexo_ouvd_img1_1000 = "";
                      if (!isset($Campos_Erros['anexo_ouvd_img1_1000']))
                      {
                          $Campos_Erros['anexo_ouvd_img1_1000'] = array();
                      }
                      $Campos_Erros['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                      if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']))
                      {
                          $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                  } 
              } 
              else 
              { 
                  if ($nm_browser == "Konqueror")  
                  { 
                      $this->anexo_ouvd_img1_1000 = "" ; 
                  } 
                  else 
                  { 
                      $Campos_Crit .= "Imagem 1 " . $this->Ini->Nm_lang['lang_errm_ivtp']; 
                      if (!isset($Campos_Erros['anexo_ouvd_img1_1000']))
                      {
                          $Campos_Erros['anexo_ouvd_img1_1000'] = array();
                      }
                      $Campos_Erros['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['geracao_tp_inval'];
                      if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img1_1000']))
                      {
                          $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['anexo_ouvd_img1_1000'][] = $this->Ini->Nm_lang['geracao_tp_inval'];
                  } 
              } 
          } 
          elseif (!empty($this->anexo_ouvd_img1_1000_salva) && $this->anexo_ouvd_img1_1000_limpa != "S")
          {
              $this->anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000_salva;
          }
      } 
      elseif (!empty($this->anexo_ouvd_img1_1000_salva) && $this->anexo_ouvd_img1_1000_limpa != "S")
      {
          $this->anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000_salva;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->anexo_ouvd_img2_1000 == "none") 
          { 
              $this->anexo_ouvd_img2_1000 = ""; 
          } 
          if ($this->anexo_ouvd_img2_1000 != "") 
          { 
              if (!function_exists('sc_upload_unprotect_chars'))
              {
                  include_once 'cadastro_DEN_1000_registro_mob_doc_name.php';
              }
              $this->anexo_ouvd_img2_1000 = sc_upload_unprotect_chars($this->anexo_ouvd_img2_1000, true);
              $this->anexo_ouvd_img2_1000_scfile_name = sc_upload_unprotect_chars($this->anexo_ouvd_img2_1000_scfile_name, true);
              if ($nm_browser == "Opera")  
              { 
                  $this->anexo_ouvd_img2_1000_scfile_type = substr($this->anexo_ouvd_img2_1000_scfile_type, 0, strpos($this->anexo_ouvd_img2_1000_scfile_type, ";")) ; 
              } 
              if ($this->anexo_ouvd_img2_1000_scfile_type == "image/pjpeg" || $this->anexo_ouvd_img2_1000_scfile_type == "image/jpeg" || $this->anexo_ouvd_img2_1000_scfile_type == "image/gif" ||  
                  $this->anexo_ouvd_img2_1000_scfile_type == "image/png" || $this->anexo_ouvd_img2_1000_scfile_type == "image/x-png" || $this->anexo_ouvd_img2_1000_scfile_type == "image/bmp")  
              { 
                  if (!is_file($this->anexo_ouvd_img2_1000) && isset($_SESSION['scriptcase']['charset']) && $_SESSION['scriptcase']['charset'] != 'UTF-8') {
                      $mbConvertFileName = mb_convert_encoding($this->anexo_ouvd_img2_1000, $_SESSION['scriptcase']['charset'], 'UTF-8');
                      $mbConvertScFileName = mb_convert_encoding($this->anexo_ouvd_img2_1000_scfile_name, $_SESSION['scriptcase']['charset'], 'UTF-8');
                      if (is_file($mbConvertFileName)) {
                          $this->anexo_ouvd_img2_1000 = $mbConvertFileName;
                          $this->anexo_ouvd_img2_1000_scfile_name = $mbConvertScFileName;
                      }
                  }
                  if (is_file($this->anexo_ouvd_img2_1000))  
                  { 
                      $this->NM_size_docs[$this->anexo_ouvd_img2_1000_scfile_name] = $this->sc_file_size($this->anexo_ouvd_img2_1000);
                      if ($this->nmgp_opcao == "incluir")
                      { 
                          $this->SC_IMG_anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000;
                      } 
                      else 
                      { 
                          $arq_anexo_ouvd_img2_1000 = fopen($this->anexo_ouvd_img2_1000, "r") ; 
                          $reg_anexo_ouvd_img2_1000 = fread($arq_anexo_ouvd_img2_1000, filesize($this->anexo_ouvd_img2_1000)) ; 
                          fclose($arq_anexo_ouvd_img2_1000) ;  
                      } 
                      $this->anexo_ouvd_img2_1000 =  trim($this->anexo_ouvd_img2_1000_scfile_name) ;  
                      $dir_img = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                     if ($this->nmgp_opcao != "incluir")
                     { 
                      if (nm_mkdir($dir_img))  
                      { 
                          $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_img2_1000_scfile_name, $dir_img, "anexo_ouvd_img2_1000");
                          if (trim($this->anexo_ouvd_img2_1000_scfile_name) != $_test_file)
                          {
                              $this->anexo_ouvd_img2_1000_scfile_name = $_test_file;
                              $this->anexo_ouvd_img2_1000 = $_test_file;
                          }
                          $arq_anexo_ouvd_img2_1000 = fopen($dir_img . trim($this->anexo_ouvd_img2_1000_scfile_name), "w") ; 
                          fwrite($arq_anexo_ouvd_img2_1000, $reg_anexo_ouvd_img2_1000) ;  
                          fclose($arq_anexo_ouvd_img2_1000) ;  
                      } 
                      else 
                      { 
                          $Campos_Crit .= "Imagem 2: " . $this->Ini->Nm_lang['lang_errm_ivdr']; 
                          $this->anexo_ouvd_img2_1000 = "";
                          if (!isset($Campos_Erros['anexo_ouvd_img2_1000']))
                          {
                              $Campos_Erros['anexo_ouvd_img2_1000'] = array();
                          }
                          $Campos_Erros['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                          if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']))
                          {
                              $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'] = array();
                          }
                          $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                      } 
                     } 
                  } 
                  else 
                  { 
                      $Campos_Crit .= "Imagem 2 " . $this->Ini->Nm_lang['lang_errm_upld']; 
                      $this->anexo_ouvd_img2_1000 = "";
                      if (!isset($Campos_Erros['anexo_ouvd_img2_1000']))
                      {
                          $Campos_Erros['anexo_ouvd_img2_1000'] = array();
                      }
                      $Campos_Erros['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                      if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']))
                      {
                          $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                  } 
              } 
              else 
              { 
                  if ($nm_browser == "Konqueror")  
                  { 
                      $this->anexo_ouvd_img2_1000 = "" ; 
                  } 
                  else 
                  { 
                      $Campos_Crit .= "Imagem 2 " . $this->Ini->Nm_lang['lang_errm_ivtp']; 
                      if (!isset($Campos_Erros['anexo_ouvd_img2_1000']))
                      {
                          $Campos_Erros['anexo_ouvd_img2_1000'] = array();
                      }
                      $Campos_Erros['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['geracao_tp_inval'];
                      if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_img2_1000']))
                      {
                          $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['anexo_ouvd_img2_1000'][] = $this->Ini->Nm_lang['geracao_tp_inval'];
                  } 
              } 
          } 
          elseif (!empty($this->anexo_ouvd_img2_1000_salva) && $this->anexo_ouvd_img2_1000_limpa != "S")
          {
              $this->anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000_salva;
          }
      } 
      elseif (!empty($this->anexo_ouvd_img2_1000_salva) && $this->anexo_ouvd_img2_1000_limpa != "S")
      {
          $this->anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000_salva;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->anexo_ouvd_doc1_1000 == "none") 
          { 
              $this->anexo_ouvd_doc1_1000 = ""; 
          } 
          if ($this->anexo_ouvd_doc1_1000 != "") 
          { 
              if (!is_file($this->anexo_ouvd_doc1_1000) && isset($_SESSION['scriptcase']['charset']) && $_SESSION['scriptcase']['charset'] != 'UTF-8') {
                  $mbConvertFileName = mb_convert_encoding($this->anexo_ouvd_doc1_1000, $_SESSION['scriptcase']['charset'], 'UTF-8');
                  if (is_file($mbConvertFileName)) {
                      $this->anexo_ouvd_doc1_1000 = $mbConvertFileName;
                  }
              }
              if (is_file($this->anexo_ouvd_doc1_1000))  
              { 
                  if ($this->nmgp_opcao == "incluir")
                  { 
                      $this->SC_DOC_anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000;
                  } 
                  else 
                  { 
                      $arq_anexo_ouvd_doc1_1000 = fopen($this->anexo_ouvd_doc1_1000, "r") ; 
                      $reg_anexo_ouvd_doc1_1000 = fread($arq_anexo_ouvd_doc1_1000, filesize($this->anexo_ouvd_doc1_1000)) ; 
                      fclose($arq_anexo_ouvd_doc1_1000) ;  
                  } 
                  $this->NM_size_docs[$this->anexo_ouvd_doc1_1000_scfile_name] = $this->sc_file_size($this->anexo_ouvd_doc1_1000);
                  $this->anexo_ouvd_doc1_1000 =  trim($this->anexo_ouvd_doc1_1000_scfile_name) ;  
                  $dir_doc = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                 if ($this->nmgp_opcao != "incluir")
                 { 
                  if (nm_mkdir($dir_doc))  
                  { 
                      $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_doc1_1000_scfile_name, $dir_doc, "anexo_ouvd_doc1_1000");
                      if (trim($this->anexo_ouvd_doc1_1000_scfile_name) != $_test_file)
                      {
                          $this->anexo_ouvd_doc1_1000_scfile_name = $_test_file;
                          $this->anexo_ouvd_doc1_1000 = $_test_file;
                      }
                      $arq_anexo_ouvd_doc1_1000 = fopen($dir_doc . trim($this->anexo_ouvd_doc1_1000_scfile_name), "w") ; 
                      fwrite($arq_anexo_ouvd_doc1_1000, $reg_anexo_ouvd_doc1_1000) ;  
                      fclose($arq_anexo_ouvd_doc1_1000) ;  
                  } 
                  else 
                  { 
                      $Campos_Crit .= "Documento 1: " . $this->Ini->Nm_lang['lang_errm_ivdr']; 
                      if (!isset($Campos_Erros['anexo_ouvd_doc1_1000']))
                      {
                          $Campos_Erros['anexo_ouvd_doc1_1000'] = array();
                      }
                      $Campos_Erros['anexo_ouvd_doc1_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                      if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000']))
                      {
                          $this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                  } 
                 } 
              } 
              else 
              { 
                  $Campos_Crit .= "Documento 1 " . $this->Ini->Nm_lang['lang_errm_upld']; 
                  $this->anexo_ouvd_doc1_1000 = "";
                  if (!isset($Campos_Erros['anexo_ouvd_doc1_1000']))
                  {
                      $Campos_Erros['anexo_ouvd_doc1_1000'] = array();
                  }
                  $Campos_Erros['anexo_ouvd_doc1_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                  if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000']))
                  {
                      $this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['anexo_ouvd_doc1_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
              } 
          } 
          elseif (!empty($this->anexo_ouvd_doc1_1000_salva) && $this->anexo_ouvd_doc1_1000_limpa != "S")
          {
              $this->anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000_salva;
          }
      } 
      elseif (!empty($this->anexo_ouvd_doc1_1000_salva) && $this->anexo_ouvd_doc1_1000_limpa != "S")
      {
          $this->anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000_salva;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->anexo_ouvd_doc2_1000 == "none") 
          { 
              $this->anexo_ouvd_doc2_1000 = ""; 
          } 
          if ($this->anexo_ouvd_doc2_1000 != "") 
          { 
              if (!is_file($this->anexo_ouvd_doc2_1000) && isset($_SESSION['scriptcase']['charset']) && $_SESSION['scriptcase']['charset'] != 'UTF-8') {
                  $mbConvertFileName = mb_convert_encoding($this->anexo_ouvd_doc2_1000, $_SESSION['scriptcase']['charset'], 'UTF-8');
                  if (is_file($mbConvertFileName)) {
                      $this->anexo_ouvd_doc2_1000 = $mbConvertFileName;
                  }
              }
              if (is_file($this->anexo_ouvd_doc2_1000))  
              { 
                  if ($this->nmgp_opcao == "incluir")
                  { 
                      $this->SC_DOC_anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000;
                  } 
                  else 
                  { 
                      $arq_anexo_ouvd_doc2_1000 = fopen($this->anexo_ouvd_doc2_1000, "r") ; 
                      $reg_anexo_ouvd_doc2_1000 = fread($arq_anexo_ouvd_doc2_1000, filesize($this->anexo_ouvd_doc2_1000)) ; 
                      fclose($arq_anexo_ouvd_doc2_1000) ;  
                  } 
                  $this->NM_size_docs[$this->anexo_ouvd_doc2_1000_scfile_name] = $this->sc_file_size($this->anexo_ouvd_doc2_1000);
                  $this->anexo_ouvd_doc2_1000 =  trim($this->anexo_ouvd_doc2_1000_scfile_name) ;  
                  $dir_doc = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                 if ($this->nmgp_opcao != "incluir")
                 { 
                  if (nm_mkdir($dir_doc))  
                  { 
                      $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_doc2_1000_scfile_name, $dir_doc, "anexo_ouvd_doc2_1000");
                      if (trim($this->anexo_ouvd_doc2_1000_scfile_name) != $_test_file)
                      {
                          $this->anexo_ouvd_doc2_1000_scfile_name = $_test_file;
                          $this->anexo_ouvd_doc2_1000 = $_test_file;
                      }
                      $arq_anexo_ouvd_doc2_1000 = fopen($dir_doc . trim($this->anexo_ouvd_doc2_1000_scfile_name), "w") ; 
                      fwrite($arq_anexo_ouvd_doc2_1000, $reg_anexo_ouvd_doc2_1000) ;  
                      fclose($arq_anexo_ouvd_doc2_1000) ;  
                  } 
                  else 
                  { 
                      $Campos_Crit .= "Documento 2: " . $this->Ini->Nm_lang['lang_errm_ivdr']; 
                      if (!isset($Campos_Erros['anexo_ouvd_doc2_1000']))
                      {
                          $Campos_Erros['anexo_ouvd_doc2_1000'] = array();
                      }
                      $Campos_Erros['anexo_ouvd_doc2_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                      if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000']))
                      {
                          $this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000'] = array();
                      }
                      $this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                  } 
                 } 
              } 
              else 
              { 
                  $Campos_Crit .= "Documento 2 " . $this->Ini->Nm_lang['lang_errm_upld']; 
                  $this->anexo_ouvd_doc2_1000 = "";
                  if (!isset($Campos_Erros['anexo_ouvd_doc2_1000']))
                  {
                      $Campos_Erros['anexo_ouvd_doc2_1000'] = array();
                  }
                  $Campos_Erros['anexo_ouvd_doc2_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                  if (!isset($this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000']) || !is_array($this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000']))
                  {
                      $this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000'] = array();
                  }
                  $this->NM_ajax_info['errList']['anexo_ouvd_doc2_1000'][] = $this->Ini->Nm_lang['lang_errm_upld'];
              } 
          } 
          elseif (!empty($this->anexo_ouvd_doc2_1000_salva) && $this->anexo_ouvd_doc2_1000_limpa != "S")
          {
              $this->anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000_salva;
          }
      } 
      elseif (!empty($this->anexo_ouvd_doc2_1000_salva) && $this->anexo_ouvd_doc2_1000_limpa != "S")
      {
          $this->anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000_salva;
      }
   }

    function removeDuplicateDttmError($aErrDate, &$aErrTime)
    {
        if (empty($aErrDate) || empty($aErrTime))
        {
            return;
        }

        foreach ($aErrDate as $sErrDate)
        {
            foreach ($aErrTime as $iErrTime => $sErrTime)
            {
                if ($sErrDate == $sErrTime)
                {
                    unset($aErrTime[$iErrTime]);
                }
            }
        }
    } // removeDuplicateDttmError

   function nm_guardar_campos()
   {
    global
           $sc_seq_vert;
    $this->nmgp_dados_form['ouvd_anonima_1000'] = $this->ouvd_anonima_1000;
    $this->nmgp_dados_form['nome_inf_ouvd_1000'] = $this->nome_inf_ouvd_1000;
    $this->nmgp_dados_form['cpf_cnpj_ouvd_1000'] = $this->cpf_cnpj_ouvd_1000;
    $this->nmgp_dados_form['email_inf_ouvd_1000'] = $this->email_inf_ouvd_1000;
    $this->nmgp_dados_form['tel_inf_ouvd_1000'] = $this->tel_inf_ouvd_1000;
    $this->nmgp_dados_form['id_categoria_1100'] = $this->id_categoria_1100;
    $this->nmgp_dados_form['desc_area_setor_1000'] = $this->desc_area_setor_1000;
    $this->nmgp_dados_form['titulo_manifestacao_1000'] = $this->titulo_manifestacao_1000;
    $this->nmgp_dados_form['desc_manifestacao_1000'] = $this->desc_manifestacao_1000;
    $this->nmgp_dados_form['dt_ocorrido_1000'] = (strlen(trim($this->dt_ocorrido_1000)) > 19) ? str_replace(".", ":", $this->dt_ocorrido_1000) : trim($this->dt_ocorrido_1000);
    if (empty($this->anexo_ouvd_img1_1000))
    {
        $this->anexo_ouvd_img1_1000 = $this->nmgp_dados_form['anexo_ouvd_img1_1000'];
    }
    $this->nmgp_dados_form['anexo_ouvd_img1_1000'] = $this->anexo_ouvd_img1_1000;
    $this->nmgp_dados_form['anexo_ouvd_img1_1000_limpa'] = $this->anexo_ouvd_img1_1000_limpa;
    if (empty($this->anexo_ouvd_img2_1000))
    {
        $this->anexo_ouvd_img2_1000 = $this->nmgp_dados_form['anexo_ouvd_img2_1000'];
    }
    $this->nmgp_dados_form['anexo_ouvd_img2_1000'] = $this->anexo_ouvd_img2_1000;
    $this->nmgp_dados_form['anexo_ouvd_img2_1000_limpa'] = $this->anexo_ouvd_img2_1000_limpa;
    if (empty($this->anexo_ouvd_doc1_1000))
    {
        $this->anexo_ouvd_doc1_1000 = $this->nmgp_dados_form['anexo_ouvd_doc1_1000'];
    }
    $this->nmgp_dados_form['anexo_ouvd_doc1_1000'] = $this->anexo_ouvd_doc1_1000;
    $this->nmgp_dados_form['anexo_ouvd_doc1_1000_limpa'] = $this->anexo_ouvd_doc1_1000_limpa;
    if (empty($this->anexo_ouvd_doc2_1000))
    {
        $this->anexo_ouvd_doc2_1000 = $this->nmgp_dados_form['anexo_ouvd_doc2_1000'];
    }
    $this->nmgp_dados_form['anexo_ouvd_doc2_1000'] = $this->anexo_ouvd_doc2_1000;
    $this->nmgp_dados_form['anexo_ouvd_doc2_1000_limpa'] = $this->anexo_ouvd_doc2_1000_limpa;
    $this->nmgp_dados_form['codigo'] = $this->codigo;
    $this->nmgp_dados_form['instr_senha'] = $this->instr_senha;
    $this->nmgp_dados_form['chave'] = $this->chave;
    $this->nmgp_dados_form['dt_ini_inv_ouvd_1000'] = $this->dt_ini_inv_ouvd_1000;
    $this->nmgp_dados_form['andamento_inv_ouvd_1000'] = $this->andamento_inv_ouvd_1000;
    $this->nmgp_dados_form['conclusao_inv_ouvd_1000'] = $this->conclusao_inv_ouvd_1000;
    $this->nmgp_dados_form['nivel_atend_atual_1000'] = $this->nivel_atend_atual_1000;
    $this->nmgp_dados_form['id_status_ouvd_1000'] = $this->id_status_ouvd_1000;
    $this->nmgp_dados_form['id_controlador_1000'] = $this->id_controlador_1000;
    $this->nmgp_dados_form['data_hora_cadastro_1000'] = $this->data_hora_cadastro_1000;
    $this->nmgp_dados_form['token_ouvd_1000'] = $this->token_ouvd_1000;
    $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_form'] = $this->nmgp_dados_form;
   }
   function nm_tira_formatacao()
   {
      global $nm_form_submit;
         $this->Before_unformat = array();
         $this->formatado = false;
      $this->Before_unformat['cpf_cnpj_ouvd_1000'] = $this->cpf_cnpj_ouvd_1000;
      nm_limpa_ciccnpj($this->cpf_cnpj_ouvd_1000) ; 
      $this->Before_unformat['tel_inf_ouvd_1000'] = $this->tel_inf_ouvd_1000;
      $this->nm_tira_mask($this->tel_inf_ouvd_1000, "(99) 9 9999-9999", "(){}[].,;:-+/ "); 
      $this->Before_unformat['dt_ocorrido_1000'] = $this->dt_ocorrido_1000;
      nm_limpa_data($this->dt_ocorrido_1000, $this->field_config['dt_ocorrido_1000']['date_sep']) ; 
      $this->Before_unformat['dt_ini_inv_ouvd_1000'] = $this->dt_ini_inv_ouvd_1000;
      nm_limpa_data($this->dt_ini_inv_ouvd_1000, $this->field_config['dt_ini_inv_ouvd_1000']['date_sep']) ; 
      $this->Before_unformat['nivel_atend_atual_1000'] = $this->nivel_atend_atual_1000;
      nm_limpa_numero($this->nivel_atend_atual_1000, $this->field_config['nivel_atend_atual_1000']['symbol_grp']) ; 
      $this->Before_unformat['id_status_ouvd_1000'] = $this->id_status_ouvd_1000;
      nm_limpa_numero($this->id_status_ouvd_1000, $this->field_config['id_status_ouvd_1000']['symbol_grp']) ; 
      $this->Before_unformat['id_controlador_1000'] = $this->id_controlador_1000;
      nm_limpa_numero($this->id_controlador_1000, $this->field_config['id_controlador_1000']['symbol_grp']) ; 
      $this->Before_unformat['data_hora_cadastro_1000'] = $this->data_hora_cadastro_1000;
      $this->Before_unformat['data_hora_cadastro_1000_hora'] = $this->data_hora_cadastro_1000_hora;
      nm_limpa_data($this->data_hora_cadastro_1000, $this->field_config['data_hora_cadastro_1000']['date_sep']) ; 
      nm_limpa_hora($this->data_hora_cadastro_1000_hora, $this->field_config['data_hora_cadastro_1000']['time_sep']) ; 
   }
   function sc_add_currency(&$value, $symbol, $pos)
   {
       if ('' == $value)
       {
           return;
       }
       $value = (1 == $pos || 3 == $pos) ? $symbol . ' ' . $value : $value . ' ' . $symbol;
   }
   function sc_remove_currency(&$value, $symbol_dec, $symbol_tho, $symbol_mon)
   {
       $value = preg_replace('~&#x0*([0-9a-f]+);~i', '', $value);
       $sNew  = str_replace($symbol_mon, '', $value);
       if ($sNew != $value)
       {
           $value = str_replace(' ', '', $sNew);
           return;
       }
       $aTest = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', $symbol_dec, $symbol_tho);
       $sNew  = '';
       for ($i = 0; $i < strlen($value); $i++)
       {
           if ($this->sc_test_currency_char($value[$i], $aTest))
           {
               $sNew .= $value[$i];
           }
       }
       $value = $sNew;
   }
   function sc_test_currency_char($char, $test)
   {
       $found = false;
       foreach ($test as $test_char)
       {
           if ($char === $test_char)
           {
               $found = true;
           }
       }
       return $found;
   }
   function nm_clear_val($Nome_Campo)
   {
      if ($Nome_Campo == "cpf_cnpj_ouvd_1000")
      {
          nm_limpa_ciccnpj($this->cpf_cnpj_ouvd_1000) ; 
      }
      if ($Nome_Campo == "tel_inf_ouvd_1000")
      {
          $this->nm_tira_mask($this->tel_inf_ouvd_1000, "(99) 9 9999-9999", "(){}[].,;:-+/ "); 
      }
      if ($Nome_Campo == "nivel_atend_atual_1000")
      {
          nm_limpa_numero($this->nivel_atend_atual_1000, $this->field_config['nivel_atend_atual_1000']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "id_status_ouvd_1000")
      {
          nm_limpa_numero($this->id_status_ouvd_1000, $this->field_config['id_status_ouvd_1000']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "id_controlador_1000")
      {
          nm_limpa_numero($this->id_controlador_1000, $this->field_config['id_controlador_1000']['symbol_grp']) ; 
      }
   }
   function nm_formatar_campos($format_fields = array())
   {
      global $nm_form_submit;
     if (isset($this->formatado) && $this->formatado)
     {
         return;
     }
     $this->formatado = true;
      if (!empty($this->cpf_cnpj_ouvd_1000) || (!empty($format_fields) && isset($format_fields['cpf_cnpj_ouvd_1000'])))
      {
          nmgp_Form_CicCnpj($this->cpf_cnpj_ouvd_1000) ; 
      }
      if (!empty($this->tel_inf_ouvd_1000) || (!empty($format_fields) && isset($format_fields['tel_inf_ouvd_1000'])))
      {
          $this->nm_gera_mask($this->tel_inf_ouvd_1000, "(99) 9 9999-9999"); 
      }
      if ((!empty($this->dt_ocorrido_1000) && 'null' != $this->dt_ocorrido_1000) || (!empty($format_fields) && isset($format_fields['dt_ocorrido_1000'])))
      {
          nm_volta_data($this->dt_ocorrido_1000, $this->field_config['dt_ocorrido_1000']['date_format']) ; 
          nmgp_Form_Datas($this->dt_ocorrido_1000, $this->field_config['dt_ocorrido_1000']['date_format'], $this->field_config['dt_ocorrido_1000']['date_sep']) ;  
      }
      elseif ('null' == $this->dt_ocorrido_1000 || '' == $this->dt_ocorrido_1000)
      {
          $this->dt_ocorrido_1000 = '';
      }
   }
   function nm_gera_mask(&$nm_campo, $nm_mask)
   { 
      $trab_campo = $nm_campo;
      $trab_mask  = $nm_mask;
      $tam_campo  = strlen($nm_campo);
      $trab_saida = "";

      if (false !== strpos($nm_mask, '9') || false !== strpos($nm_mask, 'a') || false !== strpos($nm_mask, '*'))
      {
          $new_campo = '';
          $a_mask_ord  = array();
          $i_mask_size = -1;

          foreach (explode(';', $nm_mask) as $str_mask)
          {
              $a_mask_ord[ $this->nm_conta_mask_chars($str_mask) ] = $str_mask;
          }
          ksort($a_mask_ord);

          foreach ($a_mask_ord as $i_size => $s_mask)
          {
              if (-1 == $i_mask_size)
              {
                  $i_mask_size = $i_size;
              }
              elseif (strlen($nm_campo) >= $i_size && strlen($nm_campo) > $i_mask_size)
              {
                  $i_mask_size = $i_size;
              }
          }
          $nm_mask = $a_mask_ord[$i_mask_size];

          for ($i = 0; $i < strlen($nm_mask); $i++)
          {
              $test_mask = substr($nm_mask, $i, 1);
              
              if ('9' == $test_mask || 'a' == $test_mask || '*' == $test_mask)
              {
                  $new_campo .= substr($nm_campo, 0, 1);
                  $nm_campo   = substr($nm_campo, 1);
              }
              else
              {
                  $new_campo .= $test_mask;
              }
          }

                  $nm_campo = $new_campo;

          return;
      }

      $mask_num = false;
      for ($x=0; $x < strlen($trab_mask); $x++)
      {
          if (substr($trab_mask, $x, 1) == "#")
          {
              $mask_num = true;
              break;
          }
      }
      if ($mask_num )
      {
          $ver_duas = explode(";", $trab_mask);
          if (isset($ver_duas[1]) && !empty($ver_duas[1]))
          {
              $cont1 = count(explode("#", $ver_duas[0])) - 1;
              $cont2 = count(explode("#", $ver_duas[1])) - 1;
              if ($cont1 < $cont2 && $tam_campo <= $cont2 && $tam_campo > $cont1)
              {
                  $trab_mask = $ver_duas[1];
              }
              elseif ($cont1 > $cont2 && $tam_campo <= $cont2)
              {
                  $trab_mask = $ver_duas[1];
              }
              else
              {
                  $trab_mask = $ver_duas[0];
              }
          }
          $tam_mask = strlen($trab_mask);
          $xdados = 0;
          for ($x=0; $x < $tam_mask; $x++)
          {
              if (substr($trab_mask, $x, 1) == "#" && $xdados < $tam_campo)
              {
                  $trab_saida .= substr($trab_campo, $xdados, 1);
                  $xdados++;
              }
              elseif ($xdados < $tam_campo)
              {
                  $trab_saida .= substr($trab_mask, $x, 1);
              }
          }
          if ($xdados < $tam_campo)
          {
              $trab_saida .= substr($trab_campo, $xdados);
          }
          $nm_campo = $trab_saida;
          return;
      }
      for ($ix = strlen($trab_mask); $ix > 0; $ix--)
      {
           $char_mask = substr($trab_mask, $ix - 1, 1);
           if ($char_mask != "x" && $char_mask != "z")
           {
               $trab_saida = $char_mask . $trab_saida;
           }
           else
           {
               if ($tam_campo != 0)
               {
                   $trab_saida = substr($trab_campo, $tam_campo - 1, 1) . $trab_saida;
                   $tam_campo--;
               }
               else
               {
                   $trab_saida = "0" . $trab_saida;
               }
           }
      }
      if ($tam_campo != 0)
      {
          $trab_saida = substr($trab_campo, 0, $tam_campo) . $trab_saida;
          $trab_mask  = str_repeat("z", $tam_campo) . $trab_mask;
      }
   
      $iz = 0; 
      for ($ix = 0; $ix < strlen($trab_mask); $ix++)
      {
           $char_mask = substr($trab_mask, $ix, 1);
           if ($char_mask != "x" && $char_mask != "z")
           {
               if ($char_mask == "." || $char_mask == ",")
               {
                   $trab_saida = substr($trab_saida, 0, $iz) . substr($trab_saida, $iz + 1);
               }
               else
               {
                   $iz++;
               }
           }
           elseif ($char_mask == "x" || substr($trab_saida, $iz, 1) != "0")
           {
               $ix = strlen($trab_mask) + 1;
           }
           else
           {
               $trab_saida = substr($trab_saida, 0, $iz) . substr($trab_saida, $iz + 1);
           }
      }
      $nm_campo = $trab_saida;
   } 
   function nm_conta_mask_chars($sMask)
   {
       $iLength = 0;

       for ($i = 0; $i < strlen($sMask); $i++)
       {
           if (in_array($sMask[$i], array('9', 'a', '*')))
           {
               $iLength++;
           }
       }

       return $iLength;
   }
   function nm_tira_mask(&$nm_campo, $nm_mask, $nm_chars = '')
   { 
      $mask_dados = $nm_campo;
      $trab_mask  = $nm_mask;
      $tam_campo  = strlen($nm_campo);
      $tam_mask   = strlen($nm_mask);
      $trab_saida = "";

      if (false !== strpos($nm_mask, '9') || false !== strpos($nm_mask, 'a') || false !== strpos($nm_mask, '*'))
      {
          $raw_campo = $this->sc_clear_mask($nm_campo, $nm_chars);
          $raw_mask  = $this->sc_clear_mask($nm_mask, $nm_chars);
          $new_campo = '';

          $test_mask = substr($raw_mask, 0, 1);
          $raw_mask  = substr($raw_mask, 1);

          while ('' != $raw_campo)
          {
              $test_val  = substr($raw_campo, 0, 1);
              $raw_campo = substr($raw_campo, 1);
              $ord       = ord($test_val);
              $found     = false;

              switch ($test_mask)
              {
                  case '9':
                      if (48 <= $ord && 57 >= $ord)
                      {
                          $new_campo .= $test_val;
                          $found      = true;
                      }
                      break;

                  case 'a':
                      if ((65 <= $ord && 90 >= $ord) || (97 <= $ord && 122 >= $ord))
                      {
                          $new_campo .= $test_val;
                          $found      = true;
                      }
                      break;

                  case '*':
                      if ((48 <= $ord && 57 >= $ord) || (65 <= $ord && 90 >= $ord) || (97 <= $ord && 122 >= $ord))
                      {
                          $new_campo .= $test_val;
                          $found      = true;
                      }
                      break;
              }

              if ($found)
              {
                  $test_mask = substr($raw_mask, 0, 1);
                  $raw_mask  = substr($raw_mask, 1);
              }
          }

          $nm_campo = $new_campo;

          return;
      }

      $mask_num = false;
      for ($x=0; $x < strlen($trab_mask); $x++)
      {
          if (substr($trab_mask, $x, 1) == "#")
          {
              $mask_num = true;
              break;
          }
      }
      if ($mask_num )
      {
          for ($x=0; $x < strlen($mask_dados); $x++)
          {
              if (is_numeric(substr($mask_dados, $x, 1)))
              {
                  $trab_saida .= substr($mask_dados, $x, 1);
              }
          }
          $nm_campo = $trab_saida;
          return;
      }
      if ($tam_mask > $tam_campo)
      {
         $mask_desfaz = "";
         for ($mask_ind = 0; $tam_mask > $tam_campo; $mask_ind++)
         {
              $mask_char = substr($trab_mask, $mask_ind, 1);
              if ($mask_char == "z")
              {
                  $tam_mask--;
              }
              else
              {
                  $mask_desfaz .= $mask_char;
              }
              if ($mask_ind == $tam_campo)
              {
                  $tam_mask = $tam_campo;
              }
         }
         $trab_mask = $mask_desfaz . substr($trab_mask, $mask_ind);
      }
      $mask_saida = "";
      for ($mask_ind = strlen($trab_mask); $mask_ind > 0; $mask_ind--)
      {
          $mask_char = substr($trab_mask, $mask_ind - 1, 1);
          if ($mask_char == "x" || $mask_char == "z")
          {
              if ($tam_campo > 0)
              {
                  $mask_saida = substr($mask_dados, $tam_campo - 1, 1) . $mask_saida;
              }
          }
          else
          {
              if ($mask_char != substr($mask_dados, $tam_campo - 1, 1) && $tam_campo > 0)
              {
                  $mask_saida = substr($mask_dados, $tam_campo - 1, 1) . $mask_saida;
                  $mask_ind--;
              }
          }
          $tam_campo--;
      }
      if ($tam_campo > 0)
      {
         $mask_saida = substr($mask_dados, 0, $tam_campo) . $mask_saida;
      }
      $nm_campo = $mask_saida;
   }

   function sc_clear_mask($value, $chars)
   {
       $new = '';

       for ($i = 0; $i < strlen($value); $i++)
       {
           if (false === strpos($chars, $value[$i]))
           {
               $new .= $value[$i];
           }
       }

       return $new;
   }
   function nm_validate_mask($value, $mask_list)
   {
       if ('' == $value)
       {
           return true;
       }

       $size_ok   = false;
       $test_mask = '';
       foreach ($mask_list as $tmp_mask)
       {
           if (mb_strlen($value) == strlen($tmp_mask))
           {
               $size_ok   = true;
               $test_mask = $tmp_mask;
           }
       }

       if (!$size_ok)
       {
           return false;
       }

       $i           = 0;
       $thisPointer = 0;
       while (false !== ($test_char = $this->nm_next_char($value, $thisPointer)))
       {
           if (!$this->nm_validate_mask_char($test_char, $test_mask[$i]))
           {
               return false;
           }
           $i++;
       }

       return true;
       for ($i = 0; $i < strlen($value); $i++)
       {
           if (!$this->nm_validate_mask_char($value[$i], $test_mask[$i]))
           {
               return false;
           }
       }

       return true;
   }

   function nm_validate_mask_char($value_char, $mask_char)
   {
       switch ($mask_char)
       {
           case '9':
               return false !== strpos('0123456789', $value_char);
               break;

           case 'a':
               return false !== strpos('abcdefghijklmnopqrstuvwxyz', strtolower($value_char));
               break;

           case '*':
               if (false !== strpos('abcdefghijklmnopqrstuvwxyz0123456789', strtolower($value_char))) {
                   return true;
               }
               if (preg_match("/\p{Arabic}/u", $value_char)) {
                   return true;
               }

               return false;
               break;

           default:
               return $value_char == $mask_char;
               break;
       }
   }

   function nm_next_char($string, &$pointer) {
       if (!isset($string[$pointer])) {
           return false;
       }

       $char = ord($string[$pointer]);

       if ($char < 128) {
           return $string[$pointer++];
       }
       else {
           if ($char < 224) {
               $bytes = 2;
           }
           elseif ($char < 240) {
               $bytes = 3;
           }
           elseif ($char < 248) {
               $bytes = 4;
           }
           elseif($char == 252) {
               $bytes = 5;
           }
           else {
               $bytes = 6;
           }

           $str      = substr($string, $pointer, $bytes);
           $pointer += $bytes;

           return $str;
       }
   }
//
   function nm_limpa_alfa(&$str)
   {
   }
//
//-- 
   function nm_converte_datas($use_null = true, $bForce = false)
   {
      $guarda_format_hora = $this->field_config['dt_ocorrido_1000']['date_format'];
      if ($this->dt_ocorrido_1000 != "")  
      { 
          nm_conv_data($this->dt_ocorrido_1000, $this->field_config['dt_ocorrido_1000']['date_format']) ; 
          $this->dt_ocorrido_1000_hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->dt_ocorrido_1000_hora = substr($this->dt_ocorrido_1000_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->dt_ocorrido_1000_hora = substr($this->dt_ocorrido_1000_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->dt_ocorrido_1000_hora = substr($this->dt_ocorrido_1000_hora, 0, -4);
          }
      } 
      if ($this->dt_ocorrido_1000 == "" && $use_null)  
      { 
          $this->dt_ocorrido_1000 = "null" ; 
      } 
      $this->field_config['dt_ocorrido_1000']['date_format'] = $guarda_format_hora;
   }
//
   function nm_prep_date_change($cmp_date, $format_dt)
   {
       $vl_return  = "";
       if ($cmp_date != 'null') {
           $vl_return .= (strpos($format_dt, "yy") !== false) ? substr($cmp_date,  0, 4) : "";
           $vl_return .= (strpos($format_dt, "mm") !== false) ? substr($cmp_date,  5, 2) : "";
           $vl_return .= (strpos($format_dt, "dd") !== false) ? substr($cmp_date,  8, 2) : "";
           $vl_return .= (strpos($format_dt, "hh") !== false) ? substr($cmp_date, 11, 2) : "";
           $vl_return .= (strpos($format_dt, "ii") !== false) ? substr($cmp_date, 14, 2) : "";
           $vl_return .= (strpos($format_dt, "ss") !== false) ? substr($cmp_date, 17, 2) : "";
       }
       return $vl_return;
   }
   function nm_conv_data_db($dt_in, $form_in, $form_out, $replaces = array())
   {
       $dt_out = $dt_in;
       if (strtoupper($form_in) == "DB_FORMAT") {
           if ($dt_out == "null" || $dt_out == "")
           {
               $dt_out = "";
               return $dt_out;
           }
           $form_in = "AAAA-MM-DD";
       }
       if (strtoupper($form_out) == "DB_FORMAT") {
           if (empty($dt_out))
           {
               $dt_out = "null";
               return $dt_out;
           }
           $form_out = "AAAA-MM-DD";
       }
       if (strtoupper($form_out) == "SC_FORMAT_REGION") {
           $this->nm_data->SetaData($dt_in, strtoupper($form_in));
           $prep_out  = (strpos(strtolower($form_in), "dd") !== false) ? "dd" : "";
           $prep_out .= (strpos(strtolower($form_in), "mm") !== false) ? "mm" : "";
           $prep_out .= (strpos(strtolower($form_in), "aa") !== false) ? "aaaa" : "";
           $prep_out .= (strpos(strtolower($form_in), "yy") !== false) ? "aaaa" : "";
           return $this->nm_data->FormataSaida($this->nm_data->FormatRegion("DT", $prep_out));
       }
       else {
           nm_conv_form_data($dt_out, $form_in, $form_out, $replaces);
           return $dt_out;
       }
   }

   function returnWhere($aCond, $sOp = 'AND')
   {
       $aWhere = array();
       foreach ($aCond as $sCond)
       {
           $this->handleWhereCond($sCond);
           if ('' != $sCond)
           {
               $aWhere[] = $sCond;
           }
       }
       if (empty($aWhere))
       {
           return '';
       }
       else
       {
           return ' WHERE (' . implode(') ' . $sOp . ' (', $aWhere) . ')';
       }
   } // returnWhere

   function handleWhereCond(&$sCond)
   {
       $sCond = trim($sCond);
       if ('where' == strtolower(substr($sCond, 0, 5)))
       {
           $sCond = trim(substr($sCond, 5));
       }
   } // handleWhereCond

   function ajax_return_values()
   {
          $this->ajax_return_values_ouvd_anonima_1000();
          $this->ajax_return_values_nome_inf_ouvd_1000();
          $this->ajax_return_values_cpf_cnpj_ouvd_1000();
          $this->ajax_return_values_email_inf_ouvd_1000();
          $this->ajax_return_values_tel_inf_ouvd_1000();
          $this->ajax_return_values_id_categoria_1100();
          $this->ajax_return_values_desc_area_setor_1000();
          $this->ajax_return_values_titulo_manifestacao_1000();
          $this->ajax_return_values_desc_manifestacao_1000();
          $this->ajax_return_values_dt_ocorrido_1000();
          $this->ajax_return_values_anexo_ouvd_img1_1000();
          $this->ajax_return_values_anexo_ouvd_img2_1000();
          $this->ajax_return_values_anexo_ouvd_doc1_1000();
          $this->ajax_return_values_anexo_ouvd_doc2_1000();
          $this->ajax_return_values_codigo();
          $this->ajax_return_values_instr_senha();
          $this->ajax_return_values_chave();
          if ('navigate_form' == $this->NM_ajax_opcao)
          {
              $this->NM_ajax_info['clearUpload']      = 'S';
              $this->NM_ajax_info['navStatus']['ret'] = $this->Nav_permite_ret ? 'S' : 'N';
              $this->NM_ajax_info['navStatus']['ava'] = $this->Nav_permite_ava ? 'S' : 'N';
              $this->NM_ajax_info['fldList']['chave']['keyVal'] = cadastro_DEN_1000_registro_mob_pack_protect_string($this->nmgp_dados_form['chave']);
          }
   } // ajax_return_values

          //----- ouvd_anonima_1000
   function ajax_return_values_ouvd_anonima_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("ouvd_anonima_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->ouvd_anonima_1000);
              $aLookup = array();
              $this->_tmp_lookup_ouvd_anonima_1000 = $this->ouvd_anonima_1000;

$aLookup[] = array(cadastro_DEN_1000_registro_mob_pack_protect_string('1') => str_replace('<', '&lt;',cadastro_DEN_1000_registro_mob_pack_protect_string("Sim")));
$aLookup[] = array(cadastro_DEN_1000_registro_mob_pack_protect_string('0') => str_replace('<', '&lt;',cadastro_DEN_1000_registro_mob_pack_protect_string("Não")));
$_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_ouvd_anonima_1000'][] = '1';
$_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_ouvd_anonima_1000'][] = '0';
          $aLookupOrig = $aLookup;
          $sOptComp = "";
          if (isset($this->NM_ajax_info['select_html']['ouvd_anonima_1000']) && !empty($this->NM_ajax_info['select_html']['ouvd_anonima_1000']))
          {
              $sOptComp = str_replace('{SC_100PERC_CLASS_INPUT}', $this->classes_100perc_fields['input'], $this->NM_ajax_info['select_html']['ouvd_anonima_1000']);
          }
          $this->NM_ajax_info['fldList']['ouvd_anonima_1000'] = array(
                       'row'    => '',
               'type'    => 'radio',
               'switch'  => false,
               'valList' => array($sTmpValue),
               'colNum'  => 2,
               'optComp'  => $sOptComp,
              );
          $aLabel     = array();
          $aLabelTemp = array();
          foreach ($this->NM_ajax_info['fldList']['ouvd_anonima_1000']['valList'] as $i => $v)
          {
              $this->NM_ajax_info['fldList']['ouvd_anonima_1000']['valList'][$i] = cadastro_DEN_1000_registro_mob_pack_protect_string($v);
          }
          foreach ($aLookupOrig as $aValData)
          {
              if (in_array(key($aValData), $this->NM_ajax_info['fldList']['ouvd_anonima_1000']['valList']))
              {
                  $aLabelTemp[key($aValData)] = current($aValData);
              }
          }
          foreach ($this->NM_ajax_info['fldList']['ouvd_anonima_1000']['valList'] as $iIndex => $sValue)
          {
              $aLabel[$iIndex] = (isset($aLabelTemp[$sValue])) ? $aLabelTemp[$sValue] : $sValue;
          }
          $this->NM_ajax_info['fldList']['ouvd_anonima_1000']['labList'] = $aLabel;
          }
   }

          //----- nome_inf_ouvd_1000
   function ajax_return_values_nome_inf_ouvd_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("nome_inf_ouvd_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->nome_inf_ouvd_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['nome_inf_ouvd_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($this->form_encode_input($sTmpValue)),
              );
          }
   }

          //----- cpf_cnpj_ouvd_1000
   function ajax_return_values_cpf_cnpj_ouvd_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("cpf_cnpj_ouvd_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->cpf_cnpj_ouvd_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['cpf_cnpj_ouvd_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

          //----- email_inf_ouvd_1000
   function ajax_return_values_email_inf_ouvd_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("email_inf_ouvd_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->email_inf_ouvd_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['email_inf_ouvd_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

          //----- tel_inf_ouvd_1000
   function ajax_return_values_tel_inf_ouvd_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("tel_inf_ouvd_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->tel_inf_ouvd_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['tel_inf_ouvd_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($this->form_encode_input($sTmpValue)),
              );
          }
   }

          //----- id_categoria_1100
   function ajax_return_values_id_categoria_1100($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("id_categoria_1100", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->id_categoria_1100);
              $aLookup = array();
              $this->_tmp_lookup_id_categoria_1100 = $this->id_categoria_1100;

 
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'] = array(); 
}
   if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
   { 
       $GLOBALS["NM_ERRO_IBASE"] = 1;  
   } 
   $nm_nao_carga = false;
   $nmgp_def_dados = "" ; 

   $old_value_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
   $old_value_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
   $old_value_dt_ocorrido_1000 = $this->dt_ocorrido_1000;
   $this->nm_tira_formatacao();
   if ($this->nmgp_opcao != "nada") {
       $this->nm_converte_datas(false);
   }


   $unformatted_value_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
   $unformatted_value_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
   $unformatted_value_dt_ocorrido_1000 = $this->dt_ocorrido_1000;

   $nm_comando = "SELECT id_categoria_ouvd_1100, titulo_categoria_1100 FROM OUVD_1100_categoria WHERE ind_cat_atv_1100 = 1 AND id_controlador_1000 = " . $_SESSION['usr_controlador'] . "";

   $this->cpf_cnpj_ouvd_1000 = $old_value_cpf_cnpj_ouvd_1000;
   $this->tel_inf_ouvd_1000 = $old_value_tel_inf_ouvd_1000;
   $this->dt_ocorrido_1000 = $old_value_dt_ocorrido_1000;

   $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
   $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
   if ($nm_comando != "" && $rs = $this->Db->Execute($nm_comando))
   {
       while (!$rs->EOF) 
       { 
              $rs->fields[0] = str_replace(',', '.', $rs->fields[0]);
              $rs->fields[0] = (strpos(strtolower($rs->fields[0]), "e")) ? (float)$rs->fields[0] : $rs->fields[0];
              $rs->fields[0] = (string)$rs->fields[0];
              $aLookup[] = array(cadastro_DEN_1000_registro_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[0])) => str_replace('<', '&lt;', cadastro_DEN_1000_registro_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[1]))));
              $nmgp_def_dados .= $rs->fields[1] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'][] = $rs->fields[0];
              $rs->MoveNext() ; 
       } 
       $rs->Close() ; 
   } 
   elseif ($GLOBALS["NM_ERRO_IBASE"] != 1 && $nm_comando != "")  
   {  
       $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
       exit; 
   } 
   $GLOBALS["NM_ERRO_IBASE"] = 0; 
          $aLookupOrig = $aLookup;
          $sSelComp = "name=\"id_categoria_1100\"";
          if (isset($this->NM_ajax_info['select_html']['id_categoria_1100']) && !empty($this->NM_ajax_info['select_html']['id_categoria_1100']))
          {
              $sSelComp = str_replace('{SC_100PERC_CLASS_INPUT}', $this->classes_100perc_fields['input'], $this->NM_ajax_info['select_html']['id_categoria_1100']);
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->id_categoria_1100 == $sValue)
                  {
                      $this->_tmp_lookup_id_categoria_1100 = $sLabel;
                  }

                  $sOpt     = ($sValue !== $sLabel) ? $sValue : $sLabel;
                  $sLookup .= "<option value=\"" . $sOpt . "\">" . $sLabel . "</option>";
              }
          }
          $aLookup  = $sLookup;
          $Nm_tp_obj = (isset($this->nmgp_refresh_fields) && in_array("id_categoria_1100", $this->nmgp_refresh_fields)) ? 'select' : 'text';
          $this->NM_ajax_info['fldList']['id_categoria_1100'] = array(
                       'row'    => '',
               'type'    => $Nm_tp_obj,
               'valList' => array($sTmpValue),
               'optList' => $aLookup,
              );
          $aLabel     = array();
          $aLabelTemp = array();
          foreach ($this->NM_ajax_info['fldList']['id_categoria_1100']['valList'] as $i => $v)
          {
              $this->NM_ajax_info['fldList']['id_categoria_1100']['valList'][$i] = cadastro_DEN_1000_registro_mob_pack_protect_string($v);
          }
          foreach ($aLookupOrig as $aValData)
          {
              if (in_array(key($aValData), $this->NM_ajax_info['fldList']['id_categoria_1100']['valList']))
              {
                  $aLabelTemp[key($aValData)] = current($aValData);
              }
          }
          foreach ($this->NM_ajax_info['fldList']['id_categoria_1100']['valList'] as $iIndex => $sValue)
          {
              $aLabel[$iIndex] = (isset($aLabelTemp[$sValue])) ? $aLabelTemp[$sValue] : $sValue;
          }
          $this->NM_ajax_info['fldList']['id_categoria_1100']['labList'] = $aLabel;
          }
   }

          //----- desc_area_setor_1000
   function ajax_return_values_desc_area_setor_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("desc_area_setor_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->desc_area_setor_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['desc_area_setor_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($this->form_encode_input($sTmpValue)),
              );
          }
   }

          //----- titulo_manifestacao_1000
   function ajax_return_values_titulo_manifestacao_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("titulo_manifestacao_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->titulo_manifestacao_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['titulo_manifestacao_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($this->form_encode_input($sTmpValue)),
              );
          }
   }

          //----- desc_manifestacao_1000
   function ajax_return_values_desc_manifestacao_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("desc_manifestacao_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->desc_manifestacao_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['desc_manifestacao_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($this->form_encode_input($sTmpValue)),
              );
          }
   }

          //----- dt_ocorrido_1000
   function ajax_return_values_dt_ocorrido_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("dt_ocorrido_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->dt_ocorrido_1000);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['dt_ocorrido_1000'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

          //----- anexo_ouvd_img1_1000
   function ajax_return_values_anexo_ouvd_img1_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("anexo_ouvd_img1_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->anexo_ouvd_img1_1000);
              $aLookup = array();
   $out_anexo_ouvd_img1_1000 = '';
   $out1_anexo_ouvd_img1_1000 = '';
   if ($this->anexo_ouvd_img1_1000 != "" && $this->anexo_ouvd_img1_1000 != "none")   
   { 
       $path_anexo_ouvd_img1_1000 = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/" . $this->anexo_ouvd_img1_1000;
       $md5_anexo_ouvd_img1_1000  = md5("/ouvidoria/" . $_SESSION['cnpj_controlador'] . $this->anexo_ouvd_img1_1000);
       nm_fix_SubDirUpload($this->anexo_ouvd_img1_1000,$this->Ini->root . $this->Ini->path_imagens,"/ouvidoria/" . $_SESSION['cnpj_controlador']);
        if (is_file($path_anexo_ouvd_img1_1000))  
       { 
           $NM_ler_img = true;
           $out_anexo_ouvd_img1_1000 = $this->Ini->path_imag_temp . "/sc_anexo_ouvd_img1_1000_" . $md5_anexo_ouvd_img1_1000 . ".gif" ;  
           $out1_anexo_ouvd_img1_1000 = $out_anexo_ouvd_img1_1000; 
           if (is_file($this->Ini->root . $out_anexo_ouvd_img1_1000))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_anexo_ouvd_img1_1000) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_ler_img = false;
               } 
           } 
           if ($NM_ler_img) 
           { 
               $tmp_anexo_ouvd_img1_1000 = fopen($path_anexo_ouvd_img1_1000, "r") ; 
               $reg_anexo_ouvd_img1_1000 = fread($tmp_anexo_ouvd_img1_1000, filesize($path_anexo_ouvd_img1_1000)) ; 
               fclose($tmp_anexo_ouvd_img1_1000) ;  
               $arq_anexo_ouvd_img1_1000 = fopen($this->Ini->root . $out_anexo_ouvd_img1_1000, "w") ;  
               fwrite($arq_anexo_ouvd_img1_1000, $reg_anexo_ouvd_img1_1000) ;  
               fclose($arq_anexo_ouvd_img1_1000) ;  
           } 
       } 
   } 
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['anexo_ouvd_img1_1000'] = array(
                       'row'    => '',
               'type'    => 'imagem',
               'valList' => array($sTmpValue),
               'imgFile' => $out_anexo_ouvd_img1_1000,
               'imgOrig' => $out1_anexo_ouvd_img1_1000,
               'keepImg' => $sKeepImage,
              );
          }
   }

          //----- anexo_ouvd_img2_1000
   function ajax_return_values_anexo_ouvd_img2_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("anexo_ouvd_img2_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->anexo_ouvd_img2_1000);
              $aLookup = array();
   $out_anexo_ouvd_img2_1000 = '';
   $out1_anexo_ouvd_img2_1000 = '';
   if ($this->anexo_ouvd_img2_1000 != "" && $this->anexo_ouvd_img2_1000 != "none")   
   { 
       $path_anexo_ouvd_img2_1000 = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/" . $this->anexo_ouvd_img2_1000;
       $md5_anexo_ouvd_img2_1000  = md5("/ouvidoria/" . $_SESSION['cnpj_controlador'] . $this->anexo_ouvd_img2_1000);
       nm_fix_SubDirUpload($this->anexo_ouvd_img2_1000,$this->Ini->root . $this->Ini->path_imagens,"/ouvidoria/" . $_SESSION['cnpj_controlador']);
        if (is_file($path_anexo_ouvd_img2_1000))  
       { 
           $NM_ler_img = true;
           $out_anexo_ouvd_img2_1000 = $this->Ini->path_imag_temp . "/sc_anexo_ouvd_img2_1000_" . $md5_anexo_ouvd_img2_1000 . ".gif" ;  
           $out1_anexo_ouvd_img2_1000 = $out_anexo_ouvd_img2_1000; 
           if (is_file($this->Ini->root . $out_anexo_ouvd_img2_1000))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_anexo_ouvd_img2_1000) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_ler_img = false;
               } 
           } 
           if ($NM_ler_img) 
           { 
               $tmp_anexo_ouvd_img2_1000 = fopen($path_anexo_ouvd_img2_1000, "r") ; 
               $reg_anexo_ouvd_img2_1000 = fread($tmp_anexo_ouvd_img2_1000, filesize($path_anexo_ouvd_img2_1000)) ; 
               fclose($tmp_anexo_ouvd_img2_1000) ;  
               $arq_anexo_ouvd_img2_1000 = fopen($this->Ini->root . $out_anexo_ouvd_img2_1000, "w") ;  
               fwrite($arq_anexo_ouvd_img2_1000, $reg_anexo_ouvd_img2_1000) ;  
               fclose($arq_anexo_ouvd_img2_1000) ;  
           } 
       } 
   } 
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['anexo_ouvd_img2_1000'] = array(
                       'row'    => '',
               'type'    => 'imagem',
               'valList' => array($sTmpValue),
               'imgFile' => $out_anexo_ouvd_img2_1000,
               'imgOrig' => $out1_anexo_ouvd_img2_1000,
               'keepImg' => $sKeepImage,
              );
          }
   }

          //----- anexo_ouvd_doc1_1000
   function ajax_return_values_anexo_ouvd_doc1_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("anexo_ouvd_doc1_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->anexo_ouvd_doc1_1000);
              $aLookup = array();
              $sTmpExtension = pathinfo($this->anexo_ouvd_doc1_1000, PATHINFO_EXTENSION);
              $sTmpExtension = null == $sTmpExtension ? '' : '.' . $sTmpExtension;
              $sTmpFile      = 'sc_anexo_ouvd_doc1_1000_' . md5(mt_rand(1, 1000) . microtime() . session_id()) . $sTmpExtension;
              if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'] = array();
              }
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'][$sTmpFile] = $this->anexo_ouvd_doc1_1000;
              $tmp_file_anexo_ouvd_doc1_1000 = trim(NM_charset_to_utf8($this->anexo_ouvd_doc1_1000));
              $tmp_icon_anexo_ouvd_doc1_1000 = '';
              if ('' != $tmp_file_anexo_ouvd_doc1_1000)
              {
                  $tmp_icon_anexo_ouvd_doc1_1000 = $this->gera_icone($tmp_file_anexo_ouvd_doc1_1000);
              }
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['anexo_ouvd_doc1_1000'] = array(
                       'row'    => '',
               'type'    => 'documento',
               'valList' => array($sTmpValue),
               'docLink' => "<a href=\"javascript:nm_mostra_doc('2', '" . $sTmpFile . "', 'cadastro_DEN_1000_registro')\">" . $tmp_file_anexo_ouvd_doc1_1000 . "</a>",
               'docIcon' => $tmp_icon_anexo_ouvd_doc1_1000,
               'docReadonly' => "N",
              );
              if ('navigate_form' == $this->NM_ajax_opcao)
              {
                  $this->NM_ajax_info['fldList']['anexo_ouvd_doc1_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }
          }
   }

          //----- anexo_ouvd_doc2_1000
   function ajax_return_values_anexo_ouvd_doc2_1000($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("anexo_ouvd_doc2_1000", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->anexo_ouvd_doc2_1000);
              $aLookup = array();
              $sTmpExtension = pathinfo($this->anexo_ouvd_doc2_1000, PATHINFO_EXTENSION);
              $sTmpExtension = null == $sTmpExtension ? '' : '.' . $sTmpExtension;
              $sTmpFile      = 'sc_anexo_ouvd_doc2_1000_' . md5(mt_rand(1, 1000) . microtime() . session_id()) . $sTmpExtension;
              if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'] = array();
              }
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'][$sTmpFile] = $this->anexo_ouvd_doc2_1000;
              $tmp_file_anexo_ouvd_doc2_1000 = trim(NM_charset_to_utf8($this->anexo_ouvd_doc2_1000));
              $tmp_icon_anexo_ouvd_doc2_1000 = '';
              if ('' != $tmp_file_anexo_ouvd_doc2_1000)
              {
                  $tmp_icon_anexo_ouvd_doc2_1000 = $this->gera_icone($tmp_file_anexo_ouvd_doc2_1000);
              }
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['anexo_ouvd_doc2_1000'] = array(
                       'row'    => '',
               'type'    => 'documento',
               'valList' => array($sTmpValue),
               'docLink' => "<a href=\"javascript:nm_mostra_doc('3', '" . $sTmpFile . "', 'cadastro_DEN_1000_registro')\">" . $tmp_file_anexo_ouvd_doc2_1000 . "</a>",
               'docIcon' => $tmp_icon_anexo_ouvd_doc2_1000,
               'docReadonly' => "N",
              );
              if ('navigate_form' == $this->NM_ajax_opcao)
              {
                  $this->NM_ajax_info['fldList']['anexo_ouvd_doc2_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }
          }
   }

          //----- codigo
   function ajax_return_values_codigo($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("codigo", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->codigo);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['codigo'] = array(
                       'row'    => '',
               'type'    => 'label',
               'valList' => array($sTmpValue),
              );
          }
   }

          //----- instr_senha
   function ajax_return_values_instr_senha($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("instr_senha", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->instr_senha);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['instr_senha'] = array(
                       'row'    => '',
               'type'    => 'label',
               'valList' => array($sTmpValue),
              );
          }
   }

          //----- chave
   function ajax_return_values_chave($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("chave", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->chave);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['chave'] = array(
                       'row'    => '',
               'type'    => 'label',
               'valList' => array($this->form_encode_input($sTmpValue)),
               'labList' => array($this->form_format_readonly("chave", $this->form_encode_input($sTmpValue))),
              );
          }
   }

    function fetchUniqueUploadName($originalName, $uploadDir, $fieldName)
    {
        $originalName = trim($originalName);
        if ('' == $originalName)
        {
            return $originalName;
        }
        if (!@is_dir($uploadDir))
        {
            return $originalName;
        }
        if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName]))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName] = array();
            $resDir = @opendir($uploadDir);
            if (!$resDir)
            {
                return $originalName;
            }
            while (false !== ($fileName = @readdir($resDir)))
            {
                if (@is_file($uploadDir . $fileName))
                {
                    $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName][] = $fileName;
                }
            }
            @closedir($resDir);
        }
        if (!in_array($originalName, $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName]))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName][] = $originalName;
            return $originalName;
        }
        else
        {
            $newName = $this->fetchFileNextName($originalName, $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName]);
            $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['upload_dir'][$fieldName][] = $newName;
            return $newName;
        }
    } // fetchUniqueUploadName

    function fetchFileNextName($uniqueName, $uniqueList)
    {
        $aPathinfo     = pathinfo($uniqueName);
        $fileExtension = $aPathinfo['extension'];
        $fileName      = $aPathinfo['filename'];
        $foundName     = false;
        $nameIt        = 1;
        if ('' != $fileExtension)
        {
            $fileExtension = '.' . $fileExtension;
        }
        while (!$foundName)
        {
            $testName = $fileName . '(' . $nameIt . ')' . $fileExtension;
            if (in_array($testName, $uniqueList))
            {
                $nameIt++;
            }
            else
            {
                $foundName = true;
                return $testName;
            }
        }
    } // fetchFileNextName

   function ajax_add_parameters()
   {
       $this->NM_ajax_info['summary_line'] = $this->getSummaryLine();
   } // ajax_add_parameters
  function nm_proc_onload($bFormat = true)
  {
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Field_no_validate'] = array();
      if (!$this->NM_ajax_flag || !isset($this->nmgp_refresh_fields)) {
      $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_codigo = $this->codigo;
    $original_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
    $original_email_inf_ouvd_1000 = $this->email_inf_ouvd_1000;
    $original_nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000;
    $original_ouvd_anonima_1000 = $this->ouvd_anonima_1000;
    $original_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
}
if (!isset($this->sc_temp_theme)) {$this->sc_temp_theme = (isset($_SESSION['theme'])) ? $_SESSION['theme'] : "";}
  $this->applyThemeAdjustments($this->sc_temp_theme);

$this->getCNPJController();

$sc_tmp_field_name = 'nome_inf_ouvd_1000';
$this->NM_ajax_info['fieldLabel'][$sc_tmp_field_name] = $this->nm_new_label[$sc_tmp_field_name] = 'Nome completo <span class="scFormRequiredMarkOdd">*</span>';

$acessCodePass = $this->geraSenha(10, true, true, true);

$this->token_ouvd_1000  = $acessCodePass;
$this->codigo  = $acessCodePass;

if(!$this->ouvd_anonima_1000 ) {
	$this->nmgp_cmp_hidden["nome_inf_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['nome_inf_ouvd_1000'] = 'on';
	$this->nmgp_cmp_hidden["email_inf_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['email_inf_ouvd_1000'] = 'on';
	$this->nmgp_cmp_hidden["tel_inf_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['tel_inf_ouvd_1000'] = 'on';
	$this->nmgp_cmp_hidden["cpf_cnpj_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['cpf_cnpj_ouvd_1000'] = 'on';
} else {
	$this->nmgp_cmp_hidden["nome_inf_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['nome_inf_ouvd_1000'] = 'off';
	$this->nmgp_cmp_hidden["email_inf_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['email_inf_ouvd_1000'] = 'off';
	$this->nmgp_cmp_hidden["tel_inf_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['tel_inf_ouvd_1000'] = 'off';
	$this->nmgp_cmp_hidden["cpf_cnpj_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['cpf_cnpj_ouvd_1000'] = 'off';
}
if (isset($this->sc_temp_theme)) { $_SESSION['theme'] = $this->sc_temp_theme;}
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_codigo != $this->codigo || (isset($bFlagRead_codigo) && $bFlagRead_codigo)))
    {
        $this->ajax_return_values_codigo(true);
    }
    if (($original_cpf_cnpj_ouvd_1000 != $this->cpf_cnpj_ouvd_1000 || (isset($bFlagRead_cpf_cnpj_ouvd_1000) && $bFlagRead_cpf_cnpj_ouvd_1000)))
    {
        $this->ajax_return_values_cpf_cnpj_ouvd_1000(true);
    }
    if (($original_email_inf_ouvd_1000 != $this->email_inf_ouvd_1000 || (isset($bFlagRead_email_inf_ouvd_1000) && $bFlagRead_email_inf_ouvd_1000)))
    {
        $this->ajax_return_values_email_inf_ouvd_1000(true);
    }
    if (($original_nome_inf_ouvd_1000 != $this->nome_inf_ouvd_1000 || (isset($bFlagRead_nome_inf_ouvd_1000) && $bFlagRead_nome_inf_ouvd_1000)))
    {
        $this->ajax_return_values_nome_inf_ouvd_1000(true);
    }
    if (($original_ouvd_anonima_1000 != $this->ouvd_anonima_1000 || (isset($bFlagRead_ouvd_anonima_1000) && $bFlagRead_ouvd_anonima_1000)))
    {
        $this->ajax_return_values_ouvd_anonima_1000(true);
    }
    if (($original_tel_inf_ouvd_1000 != $this->tel_inf_ouvd_1000 || (isset($bFlagRead_tel_inf_ouvd_1000) && $bFlagRead_tel_inf_ouvd_1000)))
    {
        $this->ajax_return_values_tel_inf_ouvd_1000(true);
    }
}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off'; 
      }
      if (empty($this->data_hora_cadastro_1000))
      {
          $this->data_hora_cadastro_1000_hora = $this->data_hora_cadastro_1000;
      }
      $this->nm_guardar_campos();
      if ($bFormat) $this->nm_formatar_campos();
  }
//
//----------------------------------------------------
//-----> 
//----------------------------------------------------
//----------- 


   function temRegistros($sWhere)
   {
       if ('' == $sWhere)
       {
           return false;
       }
       $nmgp_sel_count = 'SELECT COUNT(*) AS countTest FROM ' . $this->Ini->nm_tabela . ' WHERE ' . $sWhere;
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_sel_count; 
       $rsc = $this->Db->Execute($nmgp_sel_count); 
       if ($rsc === false && !$rsc->EOF)
       {
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg());
           exit; 
       }
       $iTotal = $rsc->fields[0];
       $rsc->Close();
       return 0 < $iTotal;
   } // temRegistros

   function deletaRegistros($sWhere)
   {
       if ('' == $sWhere)
       {
           return false;
       }
       $nmgp_sel_count = 'DELETE FROM ' . $this->Ini->nm_tabela . ' WHERE ' . $sWhere;
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_sel_count; 
       $rsc = $this->Db->Execute($nmgp_sel_count); 
       $bResult = $rsc;
       $rsc->Close();
       return $bResult == true;
   } // deletaRegistros
    function handleDbErrorMessage(&$dbErrorMessage, $dbErrorCode)
    {
        if (1267 == $dbErrorCode) {
            $dbErrorMessage = $this->Ini->Nm_lang['lang_errm_db_invalid_collation'];
        }
    }

   function restore_zeros_null()
   {
      if (!empty($this->sc_force_zero))
      {
          foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
          {
              eval('if ($this->' . $sc_force_zero_field . ' == 0) {$this->' . $sc_force_zero_field . ' = "";}');
          }
      }
      $this->sc_force_zero = array();
      if (!empty($this->NM_val_null))
      {
          foreach ($this->NM_val_null as $i_val_null => $sc_val_null_field)
          {
              eval('$this->' . $sc_val_null_field . ' = "";');
          }
      }
      $this->NM_val_null = array();
   }

   function nm_acessa_banco() 
   { 
      global  $nm_form_submit, $teste_validade, $sc_where;
 
      $this->NM_val_null = array();
      $NM_val_form = array();
      $this->sc_erro_insert = "";
      $this->sc_erro_update = "";
      $this->sc_erro_delete = "";
      $this->restore_zeros_null();
    if ("incluir" == $this->nmgp_opcao) {
      $this->sc_evento = $this->nmgp_opcao;
      $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
    $original_email_inf_ouvd_1000 = $this->email_inf_ouvd_1000;
    $original_nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000;
    $original_ouvd_anonima_1000 = $this->ouvd_anonima_1000;
    $original_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
}
if (!isset($this->sc_temp_usr_controlador)) {$this->sc_temp_usr_controlador = (isset($_SESSION['usr_controlador'])) ? $_SESSION['usr_controlador'] : "";}
  date_default_timezone_set("America/Sao_Paulo");
$currentDate = date("Y-m-d H:i:s");

$this->id_status_ouvd_1000  = 1;
$this->nivel_atend_atual_1000  = 1;
$this->id_controlador_1000  = $this->sc_temp_usr_controlador;

$this->data_hora_cadastro_1000  = $currentDate;

if($this->ouvd_anonima_1000 ) {
	$this->nome_inf_ouvd_1000  = null;
	$this->cpf_cnpj_ouvd_1000  = null;
	$this->tel_inf_ouvd_1000  = null;
	$this->email_inf_ouvd_1000  = null;
}

$checkFields = [
	"titulo_manifestacao_1000",
	"desc_manifestacao_1000",
	"nome_inf_ouvd_1000",
	"cpf_cnpj_ouvd_1000",
	"tel_inf_ouvd_1000",
	"email_inf_ouvd_1000",
	"desc_area_setor_1000",
	"anexo_ouvd_img1_1000",
	"anexo_ouvd_img2_1000",
	"anexo_ouvd_doc1_1000",
	"anexo_ouvd_doc2_1000"
];

$this->clear_white_spaces($checkFields);
$this->assign_null_if_empty($checkFields);
if (isset($this->sc_temp_usr_controlador)) { $_SESSION['usr_controlador'] = $this->sc_temp_usr_controlador;}
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_cpf_cnpj_ouvd_1000 != $this->cpf_cnpj_ouvd_1000 || (isset($bFlagRead_cpf_cnpj_ouvd_1000) && $bFlagRead_cpf_cnpj_ouvd_1000)))
    {
        $this->ajax_return_values_cpf_cnpj_ouvd_1000(true);
    }
    if (($original_email_inf_ouvd_1000 != $this->email_inf_ouvd_1000 || (isset($bFlagRead_email_inf_ouvd_1000) && $bFlagRead_email_inf_ouvd_1000)))
    {
        $this->ajax_return_values_email_inf_ouvd_1000(true);
    }
    if (($original_nome_inf_ouvd_1000 != $this->nome_inf_ouvd_1000 || (isset($bFlagRead_nome_inf_ouvd_1000) && $bFlagRead_nome_inf_ouvd_1000)))
    {
        $this->ajax_return_values_nome_inf_ouvd_1000(true);
    }
    if (($original_ouvd_anonima_1000 != $this->ouvd_anonima_1000 || (isset($bFlagRead_ouvd_anonima_1000) && $bFlagRead_ouvd_anonima_1000)))
    {
        $this->ajax_return_values_ouvd_anonima_1000(true);
    }
    if (($original_tel_inf_ouvd_1000 != $this->tel_inf_ouvd_1000 || (isset($bFlagRead_tel_inf_ouvd_1000) && $bFlagRead_tel_inf_ouvd_1000)))
    {
        $this->ajax_return_values_tel_inf_ouvd_1000(true);
    }
}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off'; 
    }
      if (!empty($this->Campos_Mens_erro)) 
      {
          $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro); 
          $this->Campos_Mens_erro = ""; 
          $this->nmgp_opc_ant = $this->nmgp_opcao ; 
          if ($this->nmgp_opcao == "incluir") 
          { 
              $GLOBALS["erro_incl"] = 1; 
          }
          else
          { 
              $this->sc_evento = ""; 
          }
          if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "excluir") 
          {
              $this->nmgp_opcao = "nada"; 
          } 
          $this->NM_rollback_db(); 
          $this->Campos_Mens_erro = ""; 
      }
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $salva_opcao = $this->nmgp_opcao; 
      if ($this->sc_evento != "novo" && $this->sc_evento != "incluir") 
      { 
          $this->sc_evento = ""; 
      } 
      if ((!isset($this->Ini->nm_bases_access) || !in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access)) && !$this->Ini->sc_tem_trans_banco && in_array($this->nmgp_opcao, array('excluir', 'incluir', 'alterar')))
      { 
          $this->Ini->sc_tem_trans_banco = $this->Db->BeginTrans(); 
      } 
      if ('incluir' == $this->nmgp_opcao && $this->andamento_inv_ouvd_1000 == ""){$this->andamento_inv_ouvd_1000 = "null"; $this->NM_val_null[] = "andamento_inv_ouvd_1000";}  
      if (('alterar' == $this->nmgp_opcao || 'igual' == $this->nmgp_opcao) && $this->andamento_inv_ouvd_1000 == ""){$this->andamento_inv_ouvd_1000 = "null"; $this->NM_val_null[] = "andamento_inv_ouvd_1000";}  
      if ('incluir' == $this->nmgp_opcao && $this->conclusao_inv_ouvd_1000 == ""){$this->conclusao_inv_ouvd_1000 = "null"; $this->NM_val_null[] = "conclusao_inv_ouvd_1000";}  
      if (('alterar' == $this->nmgp_opcao || 'igual' == $this->nmgp_opcao) && $this->conclusao_inv_ouvd_1000 == ""){$this->conclusao_inv_ouvd_1000 = "null"; $this->NM_val_null[] = "conclusao_inv_ouvd_1000";}  
      $NM_val_form['ouvd_anonima_1000'] = $this->ouvd_anonima_1000;
      $NM_val_form['nome_inf_ouvd_1000'] = $this->nome_inf_ouvd_1000;
      $NM_val_form['cpf_cnpj_ouvd_1000'] = $this->cpf_cnpj_ouvd_1000;
      $NM_val_form['email_inf_ouvd_1000'] = $this->email_inf_ouvd_1000;
      $NM_val_form['tel_inf_ouvd_1000'] = $this->tel_inf_ouvd_1000;
      $NM_val_form['id_categoria_1100'] = $this->id_categoria_1100;
      $NM_val_form['desc_area_setor_1000'] = $this->desc_area_setor_1000;
      $NM_val_form['titulo_manifestacao_1000'] = $this->titulo_manifestacao_1000;
      $NM_val_form['desc_manifestacao_1000'] = $this->desc_manifestacao_1000;
      $NM_val_form['dt_ocorrido_1000'] = $this->dt_ocorrido_1000;
      $NM_val_form['anexo_ouvd_img1_1000'] = $this->anexo_ouvd_img1_1000;
      $NM_val_form['anexo_ouvd_img2_1000'] = $this->anexo_ouvd_img2_1000;
      $NM_val_form['anexo_ouvd_doc1_1000'] = $this->anexo_ouvd_doc1_1000;
      $NM_val_form['anexo_ouvd_doc2_1000'] = $this->anexo_ouvd_doc2_1000;
      $NM_val_form['codigo'] = $this->codigo;
      $NM_val_form['instr_senha'] = $this->instr_senha;
      $NM_val_form['chave'] = $this->chave;
      $NM_val_form['dt_ini_inv_ouvd_1000'] = $this->dt_ini_inv_ouvd_1000;
      $NM_val_form['andamento_inv_ouvd_1000'] = $this->andamento_inv_ouvd_1000;
      $NM_val_form['conclusao_inv_ouvd_1000'] = $this->conclusao_inv_ouvd_1000;
      $NM_val_form['nivel_atend_atual_1000'] = $this->nivel_atend_atual_1000;
      $NM_val_form['id_status_ouvd_1000'] = $this->id_status_ouvd_1000;
      $NM_val_form['id_controlador_1000'] = $this->id_controlador_1000;
      $NM_val_form['data_hora_cadastro_1000'] = $this->data_hora_cadastro_1000;
      $NM_val_form['token_ouvd_1000'] = $this->token_ouvd_1000;
      if ($this->id_categoria_1100 === "" || is_null($this->id_categoria_1100))  
      { 
          $this->id_categoria_1100 = 0;
          $this->sc_force_zero[] = 'id_categoria_1100';
      } 
      if ($this->ouvd_anonima_1000 === "" || is_null($this->ouvd_anonima_1000))  
      { 
          $this->ouvd_anonima_1000 = 0;
          $this->sc_force_zero[] = 'ouvd_anonima_1000';
      } 
      if ($this->nivel_atend_atual_1000 === "" || is_null($this->nivel_atend_atual_1000))  
      { 
          $this->nivel_atend_atual_1000 = 0;
          $this->sc_force_zero[] = 'nivel_atend_atual_1000';
      } 
      if ($this->id_status_ouvd_1000 === "" || is_null($this->id_status_ouvd_1000))  
      { 
          $this->id_status_ouvd_1000 = 0;
          $this->sc_force_zero[] = 'id_status_ouvd_1000';
      } 
      if ($this->id_controlador_1000 === "" || is_null($this->id_controlador_1000))  
      { 
          $this->id_controlador_1000 = 0;
          $this->sc_force_zero[] = 'id_controlador_1000';
      } 
      $nm_bases_lob_geral = array_merge($this->Ini->nm_bases_ibase, $this->Ini->nm_bases_mysql, $this->Ini->nm_bases_access, $this->Ini->nm_bases_sqlite);
      if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir") 
      {
          $this->titulo_manifestacao_1000_before_qstr = $this->titulo_manifestacao_1000;
          $this->titulo_manifestacao_1000 = substr($this->Db->qstr($this->titulo_manifestacao_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->titulo_manifestacao_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->titulo_manifestacao_1000);
          }
          if ($this->titulo_manifestacao_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->titulo_manifestacao_1000 = "null"; 
              $this->NM_val_null[] = "titulo_manifestacao_1000";
          } 
          $this->desc_manifestacao_1000_before_qstr = $this->desc_manifestacao_1000;
          $this->desc_manifestacao_1000 = substr($this->Db->qstr($this->desc_manifestacao_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->desc_manifestacao_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->desc_manifestacao_1000);
          }
          if ($this->desc_manifestacao_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->desc_manifestacao_1000 = "null"; 
              $this->NM_val_null[] = "desc_manifestacao_1000";
          } 
          $this->desc_area_setor_1000_before_qstr = $this->desc_area_setor_1000;
          $this->desc_area_setor_1000 = substr($this->Db->qstr($this->desc_area_setor_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->desc_area_setor_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->desc_area_setor_1000);
          }
          if ($this->desc_area_setor_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->desc_area_setor_1000 = "null"; 
              $this->NM_val_null[] = "desc_area_setor_1000";
          } 
          if ($this->dt_ocorrido_1000 == "")  
          { 
              $this->dt_ocorrido_1000 = "null"; 
              $this->NM_val_null[] = "dt_ocorrido_1000";
          } 
          $this->nome_inf_ouvd_1000_before_qstr = $this->nome_inf_ouvd_1000;
          $this->nome_inf_ouvd_1000 = substr($this->Db->qstr($this->nome_inf_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->nome_inf_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->nome_inf_ouvd_1000);
          }
          if ($this->nome_inf_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->nome_inf_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "nome_inf_ouvd_1000";
          } 
          $this->cpf_cnpj_ouvd_1000_before_qstr = $this->cpf_cnpj_ouvd_1000;
          $this->cpf_cnpj_ouvd_1000 = substr($this->Db->qstr($this->cpf_cnpj_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->cpf_cnpj_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->cpf_cnpj_ouvd_1000);
          }
          if ($this->cpf_cnpj_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->cpf_cnpj_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "cpf_cnpj_ouvd_1000";
          } 
          $this->tel_inf_ouvd_1000_before_qstr = $this->tel_inf_ouvd_1000;
          $this->tel_inf_ouvd_1000 = substr($this->Db->qstr($this->tel_inf_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->tel_inf_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->tel_inf_ouvd_1000);
          }
          if ($this->tel_inf_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->tel_inf_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "tel_inf_ouvd_1000";
          } 
          $this->email_inf_ouvd_1000_before_qstr = $this->email_inf_ouvd_1000;
          $this->email_inf_ouvd_1000 = substr($this->Db->qstr($this->email_inf_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->email_inf_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->email_inf_ouvd_1000);
          }
          if ($this->email_inf_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->email_inf_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "email_inf_ouvd_1000";
          } 
          if ($this->dt_ini_inv_ouvd_1000 == "")  
          { 
              $this->dt_ini_inv_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "dt_ini_inv_ouvd_1000";
          } 
          $this->andamento_inv_ouvd_1000_before_qstr = $this->andamento_inv_ouvd_1000;
          $this->andamento_inv_ouvd_1000 = substr($this->Db->qstr($this->andamento_inv_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->andamento_inv_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->andamento_inv_ouvd_1000);
          }
          if ($this->andamento_inv_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->andamento_inv_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "andamento_inv_ouvd_1000";
          } 
          $this->conclusao_inv_ouvd_1000_before_qstr = $this->conclusao_inv_ouvd_1000;
          $this->conclusao_inv_ouvd_1000 = substr($this->Db->qstr($this->conclusao_inv_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->conclusao_inv_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->conclusao_inv_ouvd_1000);
          }
          if ($this->conclusao_inv_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->conclusao_inv_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "conclusao_inv_ouvd_1000";
          } 
          if ($this->data_hora_cadastro_1000 == "")  
          { 
              $this->data_hora_cadastro_1000 = "null"; 
              $this->NM_val_null[] = "data_hora_cadastro_1000";
          } 
          $this->token_ouvd_1000_before_qstr = $this->token_ouvd_1000;
          $this->token_ouvd_1000 = substr($this->Db->qstr($this->token_ouvd_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->token_ouvd_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->token_ouvd_1000);
          }
          if ($this->token_ouvd_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->token_ouvd_1000 = "null"; 
              $this->NM_val_null[] = "token_ouvd_1000";
          } 
          $this->anexo_ouvd_img1_1000_before_qstr = $this->anexo_ouvd_img1_1000;
          $this->anexo_ouvd_img1_1000 = substr($this->Db->qstr($this->anexo_ouvd_img1_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->anexo_ouvd_img1_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->anexo_ouvd_img1_1000);
          }
          if ($this->anexo_ouvd_img1_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->anexo_ouvd_img1_1000 = "null"; 
              $this->NM_val_null[] = "anexo_ouvd_img1_1000";
          } 
          $this->anexo_ouvd_img2_1000_before_qstr = $this->anexo_ouvd_img2_1000;
          $this->anexo_ouvd_img2_1000 = substr($this->Db->qstr($this->anexo_ouvd_img2_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->anexo_ouvd_img2_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->anexo_ouvd_img2_1000);
          }
          if ($this->anexo_ouvd_img2_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->anexo_ouvd_img2_1000 = "null"; 
              $this->NM_val_null[] = "anexo_ouvd_img2_1000";
          } 
          $this->anexo_ouvd_doc1_1000_original_filename = $this->anexo_ouvd_doc1_1000; 
          $this->anexo_ouvd_doc1_1000_before_qstr = $this->anexo_ouvd_doc1_1000;
          $this->anexo_ouvd_doc1_1000 = substr($this->Db->qstr($this->anexo_ouvd_doc1_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->anexo_ouvd_doc1_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->anexo_ouvd_doc1_1000);
          }
          if ($this->anexo_ouvd_doc1_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->anexo_ouvd_doc1_1000 = "null"; 
              $this->NM_val_null[] = "anexo_ouvd_doc1_1000";
          } 
          $this->anexo_ouvd_doc2_1000_original_filename = $this->anexo_ouvd_doc2_1000; 
          $this->anexo_ouvd_doc2_1000_before_qstr = $this->anexo_ouvd_doc2_1000;
          $this->anexo_ouvd_doc2_1000 = substr($this->Db->qstr($this->anexo_ouvd_doc2_1000), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->anexo_ouvd_doc2_1000 = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->anexo_ouvd_doc2_1000);
          }
          if ($this->anexo_ouvd_doc2_1000 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->anexo_ouvd_doc2_1000 = "null"; 
              $this->NM_val_null[] = "anexo_ouvd_doc2_1000";
          } 
      }
      if ($this->nmgp_opcao == "alterar") 
      {
          $SC_fields_update = array(); 
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where  ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where  "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where  ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where  "); 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              if ($this->NM_ajax_flag)
              {
                 cadastro_DEN_1000_registro_mob_pack_ajax_response();
              }
              exit; 
          }  
          $bUpdateOk = true;
          $tmp_result = (int) $rs1->fields[0]; 
          if ($tmp_result != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_nfnd']); 
              $this->nmgp_opcao = "nada"; 
              $bUpdateOk = false;
              $this->sc_evento = 'update';
          } 
          $aUpdateOk = array();
          $bUpdateOk = $bUpdateOk && empty($aUpdateOk);
          if ($bUpdateOk)
          { 
              $rs1->Close(); 
              $aDoNotUpdate = array();
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "titulo_manifestacao_1000 = '$this->titulo_manifestacao_1000', desc_manifestacao_1000 = '$this->desc_manifestacao_1000', desc_area_setor_1000 = '$this->desc_area_setor_1000', dt_ocorrido_1000 = #$this->dt_ocorrido_1000#, ouvd_anonima_1000 = $this->ouvd_anonima_1000, nome_inf_ouvd_1000 = '$this->nome_inf_ouvd_1000', cpf_cnpj_ouvd_1000 = '$this->cpf_cnpj_ouvd_1000', tel_inf_ouvd_1000 = '$this->tel_inf_ouvd_1000', email_inf_ouvd_1000 = '$this->email_inf_ouvd_1000'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "titulo_manifestacao_1000 = '$this->titulo_manifestacao_1000', desc_manifestacao_1000 = '$this->desc_manifestacao_1000', desc_area_setor_1000 = '$this->desc_area_setor_1000', dt_ocorrido_1000 = " . $this->Ini->date_delim . $this->dt_ocorrido_1000 . $this->Ini->date_delim1 . ", ouvd_anonima_1000 = $this->ouvd_anonima_1000, nome_inf_ouvd_1000 = '$this->nome_inf_ouvd_1000', cpf_cnpj_ouvd_1000 = '$this->cpf_cnpj_ouvd_1000', tel_inf_ouvd_1000 = '$this->tel_inf_ouvd_1000', email_inf_ouvd_1000 = '$this->email_inf_ouvd_1000'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "titulo_manifestacao_1000 = '$this->titulo_manifestacao_1000', desc_manifestacao_1000 = '$this->desc_manifestacao_1000', desc_area_setor_1000 = '$this->desc_area_setor_1000', dt_ocorrido_1000 = " . $this->Ini->date_delim . $this->dt_ocorrido_1000 . $this->Ini->date_delim1 . ", ouvd_anonima_1000 = $this->ouvd_anonima_1000, nome_inf_ouvd_1000 = '$this->nome_inf_ouvd_1000', cpf_cnpj_ouvd_1000 = '$this->cpf_cnpj_ouvd_1000', tel_inf_ouvd_1000 = '$this->tel_inf_ouvd_1000', email_inf_ouvd_1000 = '$this->email_inf_ouvd_1000'"; 
              } 
              else 
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "titulo_manifestacao_1000 = '$this->titulo_manifestacao_1000', desc_manifestacao_1000 = '$this->desc_manifestacao_1000', desc_area_setor_1000 = '$this->desc_area_setor_1000', dt_ocorrido_1000 = " . $this->Ini->date_delim . $this->dt_ocorrido_1000 . $this->Ini->date_delim1 . ", ouvd_anonima_1000 = $this->ouvd_anonima_1000, nome_inf_ouvd_1000 = '$this->nome_inf_ouvd_1000', cpf_cnpj_ouvd_1000 = '$this->cpf_cnpj_ouvd_1000', tel_inf_ouvd_1000 = '$this->tel_inf_ouvd_1000', email_inf_ouvd_1000 = '$this->email_inf_ouvd_1000'"; 
              } 
              if (isset($NM_val_form['id_categoria_1100']) && $NM_val_form['id_categoria_1100'] != $this->nmgp_dados_select['id_categoria_1100']) 
              { 
                  $SC_fields_update[] = "id_categoria_1100 = $this->id_categoria_1100"; 
              } 
              if (isset($NM_val_form['dt_ini_inv_ouvd_1000']) && $NM_val_form['dt_ini_inv_ouvd_1000'] != $this->nmgp_dados_select['dt_ini_inv_ouvd_1000']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "dt_ini_inv_ouvd_1000 = #$this->dt_ini_inv_ouvd_1000#"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "dt_ini_inv_ouvd_1000 = " . $this->Ini->date_delim . $this->dt_ini_inv_ouvd_1000 . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['andamento_inv_ouvd_1000']) && $NM_val_form['andamento_inv_ouvd_1000'] != $this->nmgp_dados_select['andamento_inv_ouvd_1000']) 
              { 
                  $SC_fields_update[] = "andamento_inv_ouvd_1000 = '$this->andamento_inv_ouvd_1000'"; 
              } 
              if (isset($NM_val_form['conclusao_inv_ouvd_1000']) && $NM_val_form['conclusao_inv_ouvd_1000'] != $this->nmgp_dados_select['conclusao_inv_ouvd_1000']) 
              { 
                  $SC_fields_update[] = "conclusao_inv_ouvd_1000 = '$this->conclusao_inv_ouvd_1000'"; 
              } 
              if (isset($NM_val_form['nivel_atend_atual_1000']) && $NM_val_form['nivel_atend_atual_1000'] != $this->nmgp_dados_select['nivel_atend_atual_1000']) 
              { 
                  $SC_fields_update[] = "nivel_atend_atual_1000 = $this->nivel_atend_atual_1000"; 
              } 
              if (isset($NM_val_form['id_status_ouvd_1000']) && $NM_val_form['id_status_ouvd_1000'] != $this->nmgp_dados_select['id_status_ouvd_1000']) 
              { 
                  $SC_fields_update[] = "id_status_ouvd_1000 = $this->id_status_ouvd_1000"; 
              } 
              if (isset($NM_val_form['id_controlador_1000']) && $NM_val_form['id_controlador_1000'] != $this->nmgp_dados_select['id_controlador_1000']) 
              { 
                  $SC_fields_update[] = "id_controlador_1000 = $this->id_controlador_1000"; 
              } 
              if (isset($NM_val_form['data_hora_cadastro_1000']) && $NM_val_form['data_hora_cadastro_1000'] != $this->nmgp_dados_select['data_hora_cadastro_1000']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "data_hora_cadastro_1000 = #$this->data_hora_cadastro_1000#"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "data_hora_cadastro_1000 = " . $this->Ini->date_delim . $this->data_hora_cadastro_1000 . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['token_ouvd_1000']) && $NM_val_form['token_ouvd_1000'] != $this->nmgp_dados_select['token_ouvd_1000']) 
              { 
                  $SC_fields_update[] = "token_ouvd_1000 = '$this->token_ouvd_1000'"; 
              } 
              $aEraseFiles  = array();
              $temp_cmd_sql = "";
              if ($this->anexo_ouvd_img1_1000_limpa == "S")
              {
                  $sDirErase     = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/";
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_img1_1000']);
                  if ($this->anexo_ouvd_img1_1000 != "null")
                  {
                      $this->anexo_ouvd_img1_1000 = '';
                  }
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                  {
                      $temp_cmd_sql = "anexo_ouvd_img1_1000 = '" . $this->anexo_ouvd_img1_1000 . "'";
                  }
                  else
                  {
                      $temp_cmd_sql = "anexo_ouvd_img1_1000 = '" . $this->anexo_ouvd_img1_1000 . "'";
                  }
                  $this->anexo_ouvd_img1_1000 = "";
              }
              else
              {
                  if ($this->anexo_ouvd_img1_1000 != "none" && $this->anexo_ouvd_img1_1000 != "")
                  {
                      $NM_conteudo =  $this->anexo_ouvd_img1_1000;
                      if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                      {
                      $temp_cmd_sql .= " anexo_ouvd_img1_1000 = '$NM_conteudo'";
                      }
                      else
                      {
                          $temp_cmd_sql .= " anexo_ouvd_img1_1000 = '$NM_conteudo'";
                      }
                  }
                  else
                  {
                      $aDoNotUpdate[] = "anexo_ouvd_img1_1000";
                  }
              }
              if (!empty($temp_cmd_sql))
              {
                  $SC_fields_update[] = $temp_cmd_sql;
              }
              $temp_cmd_sql = "";
              if ($this->anexo_ouvd_img2_1000_limpa == "S")
              {
                  $sDirErase     = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/";
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_img2_1000']);
                  if ($this->anexo_ouvd_img2_1000 != "null")
                  {
                      $this->anexo_ouvd_img2_1000 = '';
                  }
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                  {
                      $temp_cmd_sql = "anexo_ouvd_img2_1000 = '" . $this->anexo_ouvd_img2_1000 . "'";
                  }
                  else
                  {
                      $temp_cmd_sql = "anexo_ouvd_img2_1000 = '" . $this->anexo_ouvd_img2_1000 . "'";
                  }
                  $this->anexo_ouvd_img2_1000 = "";
              }
              else
              {
                  if ($this->anexo_ouvd_img2_1000 != "none" && $this->anexo_ouvd_img2_1000 != "")
                  {
                      $NM_conteudo =  $this->anexo_ouvd_img2_1000;
                      if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                      {
                      $temp_cmd_sql .= " anexo_ouvd_img2_1000 = '$NM_conteudo'";
                      }
                      else
                      {
                          $temp_cmd_sql .= " anexo_ouvd_img2_1000 = '$NM_conteudo'";
                      }
                  }
                  else
                  {
                      $aDoNotUpdate[] = "anexo_ouvd_img2_1000";
                  }
              }
              if (!empty($temp_cmd_sql))
              {
                  $SC_fields_update[] = $temp_cmd_sql;
              }
              $temp_cmd_sql = "";
              if ($this->anexo_ouvd_doc1_1000_limpa == "S")
              {
                  $sDirErase     = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/";
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_doc1_1000']);
                  if ($this->anexo_ouvd_doc1_1000 != "null")
                  {
                      $this->anexo_ouvd_doc1_1000 = '';
                  }
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                  {
                      $temp_cmd_sql = "anexo_ouvd_doc1_1000 = '" . $this->anexo_ouvd_doc1_1000 . "'";
                  }
                  else
                  {
                      $temp_cmd_sql = "anexo_ouvd_doc1_1000 = '" . $this->anexo_ouvd_doc1_1000 . "'";
                  }
                  $this->anexo_ouvd_doc1_1000 = "";
              }
              else
              {
                  if ($this->anexo_ouvd_doc1_1000 != "none" && $this->anexo_ouvd_doc1_1000 != "")
                  {
                      $NM_conteudo =  $this->anexo_ouvd_doc1_1000;
                      if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                      {
                      $temp_cmd_sql .= " anexo_ouvd_doc1_1000 = '$NM_conteudo'";
                      }
                      else
                      {
                          $temp_cmd_sql .= " anexo_ouvd_doc1_1000 = '$NM_conteudo'";
                      }
                  }
                  else
                  {
                      $aDoNotUpdate[] = "anexo_ouvd_doc1_1000";
                  }
              }
              if (!empty($temp_cmd_sql))
              {
                  $SC_fields_update[] = $temp_cmd_sql;
              }
              $temp_cmd_sql = "";
              if ($this->anexo_ouvd_doc2_1000_limpa == "S")
              {
                  $sDirErase     = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/";
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_doc2_1000']);
                  if ($this->anexo_ouvd_doc2_1000 != "null")
                  {
                      $this->anexo_ouvd_doc2_1000 = '';
                  }
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                  {
                      $temp_cmd_sql = "anexo_ouvd_doc2_1000 = '" . $this->anexo_ouvd_doc2_1000 . "'";
                  }
                  else
                  {
                      $temp_cmd_sql = "anexo_ouvd_doc2_1000 = '" . $this->anexo_ouvd_doc2_1000 . "'";
                  }
                  $this->anexo_ouvd_doc2_1000 = "";
              }
              else
              {
                  if ($this->anexo_ouvd_doc2_1000 != "none" && $this->anexo_ouvd_doc2_1000 != "")
                  {
                      $NM_conteudo =  $this->anexo_ouvd_doc2_1000;
                      if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                      {
                      $temp_cmd_sql .= " anexo_ouvd_doc2_1000 = '$NM_conteudo'";
                      }
                      else
                      {
                          $temp_cmd_sql .= " anexo_ouvd_doc2_1000 = '$NM_conteudo'";
                      }
                  }
                  else
                  {
                      $aDoNotUpdate[] = "anexo_ouvd_doc2_1000";
                  }
              }
              if (!empty($temp_cmd_sql))
              {
                  $SC_fields_update[] = $temp_cmd_sql;
              }
              $comando .= implode(",", $SC_fields_update);  
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $comando .= " WHERE  ";  
              }  
              else  
              {
                  $comando .= " WHERE  ";  
              }  
              $comando = str_replace("N'null'", "null", $comando) ; 
              $comando = str_replace("'null'", "null", $comando) ; 
              $comando = str_replace("#null#", "null", $comando) ; 
              $comando = str_replace($this->Ini->date_delim . "null" . $this->Ini->date_delim1, "null", $comando) ; 
              $useUpdateProcedure = false;
              if (!empty($SC_fields_update) || $useUpdateProcedure)
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = $comando; 
                  $rs = $this->Db->Execute($comando);  
                  if ($rs === false) 
                  { 
                      if (FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "MAIL SENT") && FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "WARNING"))
                      {
                          $dbErrorMessage = $this->Db->ErrorMsg();
                          $dbErrorCode = $this->Db->ErrorNo();
                          $this->handleDbErrorMessage($dbErrorMessage, $dbErrorCode);
                          $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_updt'], $dbErrorMessage, true);
                          if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler']) 
                          { 
                              $this->sc_erro_update = $dbErrorMessage;
                              $this->NM_rollback_db(); 
                              if ($this->NM_ajax_flag)
                              {
                                  cadastro_DEN_1000_registro_mob_pack_ajax_response();
                              }
                              exit;  
                          }   
                      }   
                  }   
              }   
              $this->titulo_manifestacao_1000 = $this->titulo_manifestacao_1000_before_qstr;
              $this->desc_manifestacao_1000 = $this->desc_manifestacao_1000_before_qstr;
              $this->desc_area_setor_1000 = $this->desc_area_setor_1000_before_qstr;
              $this->nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000_before_qstr;
              $this->cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000_before_qstr;
              $this->tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000_before_qstr;
              $this->email_inf_ouvd_1000 = $this->email_inf_ouvd_1000_before_qstr;
              $this->andamento_inv_ouvd_1000 = $this->andamento_inv_ouvd_1000_before_qstr;
              $this->conclusao_inv_ouvd_1000 = $this->conclusao_inv_ouvd_1000_before_qstr;
              $this->token_ouvd_1000 = $this->token_ouvd_1000_before_qstr;
              $this->anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000_before_qstr;
              $this->anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000_before_qstr;
              $this->anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000_before_qstr;
              $this->anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000_before_qstr;
              if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
              { 
              }   
              if ($this->anexo_ouvd_img1_1000_limpa == "S")
              {
                  $this->NM_ajax_info['fldList']['anexo_ouvd_img1_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }
              if ($this->anexo_ouvd_img2_1000_limpa == "S")
              {
                  $this->NM_ajax_info['fldList']['anexo_ouvd_img2_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }
              if ($this->anexo_ouvd_doc1_1000_limpa == "S")
              {
                  $this->NM_ajax_info['fldList']['anexo_ouvd_doc1_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }
              if ($this->anexo_ouvd_doc2_1000_limpa == "S")
              {
                  $this->NM_ajax_info['fldList']['anexo_ouvd_doc2_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }
              if (!empty($aEraseFiles))
              {
                  foreach ($aEraseFiles as $aEraseData)
                  {
                      $sEraseFile = $aEraseData['dir'] . $aEraseData['file'];
                      if (@is_file($sEraseFile))
                      {
                          @unlink($sEraseFile);
                      }
                  }
              }
              $this->sc_evento = "update"; 
              $this->nmgp_opcao = "igual"; 
              $this->nm_flag_iframe = true;
              if ($this->lig_edit_lookup)
              {
                  $this->lig_edit_lookup_call = true;
              }

              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['db_changed'] = true;
              if ($this->NM_ajax_flag) {
                  $this->NM_ajax_info['clearUpload'] = 'S';
                  $this->NM_ajax_info['fldList']['anexo_ouvd_img1_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
                  $this->NM_ajax_info['fldList']['anexo_ouvd_img2_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
                  $this->NM_ajax_info['fldList']['anexo_ouvd_doc1_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
                  $this->NM_ajax_info['fldList']['anexo_ouvd_doc2_1000_salva'] = array(
                      'row'     => '',
                      'type'    => 'text',
                      'valList' => array(''),
                  );
              }


              if     (isset($NM_val_form) && isset($NM_val_form['titulo_manifestacao_1000'])) { $this->titulo_manifestacao_1000 = $NM_val_form['titulo_manifestacao_1000']; }
              elseif (isset($this->titulo_manifestacao_1000)) { $this->nm_limpa_alfa($this->titulo_manifestacao_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['desc_manifestacao_1000'])) { $this->desc_manifestacao_1000 = $NM_val_form['desc_manifestacao_1000']; }
              elseif (isset($this->desc_manifestacao_1000)) { $this->nm_limpa_alfa($this->desc_manifestacao_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['id_categoria_1100'])) { $this->id_categoria_1100 = $NM_val_form['id_categoria_1100']; }
              elseif (isset($this->id_categoria_1100)) { $this->nm_limpa_alfa($this->id_categoria_1100); }
              if     (isset($NM_val_form) && isset($NM_val_form['desc_area_setor_1000'])) { $this->desc_area_setor_1000 = $NM_val_form['desc_area_setor_1000']; }
              elseif (isset($this->desc_area_setor_1000)) { $this->nm_limpa_alfa($this->desc_area_setor_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['ouvd_anonima_1000'])) { $this->ouvd_anonima_1000 = $NM_val_form['ouvd_anonima_1000']; }
              elseif (isset($this->ouvd_anonima_1000)) { $this->nm_limpa_alfa($this->ouvd_anonima_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['nome_inf_ouvd_1000'])) { $this->nome_inf_ouvd_1000 = $NM_val_form['nome_inf_ouvd_1000']; }
              elseif (isset($this->nome_inf_ouvd_1000)) { $this->nm_limpa_alfa($this->nome_inf_ouvd_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['cpf_cnpj_ouvd_1000'])) { $this->cpf_cnpj_ouvd_1000 = $NM_val_form['cpf_cnpj_ouvd_1000']; }
              elseif (isset($this->cpf_cnpj_ouvd_1000)) { $this->nm_limpa_alfa($this->cpf_cnpj_ouvd_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['tel_inf_ouvd_1000'])) { $this->tel_inf_ouvd_1000 = $NM_val_form['tel_inf_ouvd_1000']; }
              elseif (isset($this->tel_inf_ouvd_1000)) { $this->nm_limpa_alfa($this->tel_inf_ouvd_1000); }
              if     (isset($NM_val_form) && isset($NM_val_form['email_inf_ouvd_1000'])) { $this->email_inf_ouvd_1000 = $NM_val_form['email_inf_ouvd_1000']; }
              elseif (isset($this->email_inf_ouvd_1000)) { $this->nm_limpa_alfa($this->email_inf_ouvd_1000); }

              $this->nm_formatar_campos();

              $bChange_anexo_ouvd_doc1_1000 = false;
              if (isset($this->anexo_ouvd_doc1_1000_original_filename) && '' != $this->anexo_ouvd_doc1_1000_original_filename && $this->anexo_ouvd_doc1_1000_original_filename != $this->anexo_ouvd_doc1_1000)
              {
                  $sTmpOrig_anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000;
                  $this->anexo_ouvd_doc1_1000    = $this->anexo_ouvd_doc1_1000_original_filename;
                  $bChange_anexo_ouvd_doc1_1000  = true;
              }

              $bChange_anexo_ouvd_doc2_1000 = false;
              if (isset($this->anexo_ouvd_doc2_1000_original_filename) && '' != $this->anexo_ouvd_doc2_1000_original_filename && $this->anexo_ouvd_doc2_1000_original_filename != $this->anexo_ouvd_doc2_1000)
              {
                  $sTmpOrig_anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000;
                  $this->anexo_ouvd_doc2_1000    = $this->anexo_ouvd_doc2_1000_original_filename;
                  $bChange_anexo_ouvd_doc2_1000  = true;
              }

              $aOldRefresh               = $this->nmgp_refresh_fields;
              $this->nmgp_refresh_fields = array_diff(array('ouvd_anonima_1000', 'nome_inf_ouvd_1000', 'cpf_cnpj_ouvd_1000', 'email_inf_ouvd_1000', 'tel_inf_ouvd_1000', 'id_categoria_1100', 'desc_area_setor_1000', 'titulo_manifestacao_1000', 'desc_manifestacao_1000', 'dt_ocorrido_1000', 'anexo_ouvd_img1_1000', 'anexo_ouvd_img2_1000', 'anexo_ouvd_doc1_1000', 'anexo_ouvd_doc2_1000', 'codigo', 'instr_senha'), $aDoNotUpdate);
              $this->ajax_return_values();
              $this->nmgp_refresh_fields = $aOldRefresh;

              if ($bChange_anexo_ouvd_doc1_1000)
              {
                  $this->anexo_ouvd_doc1_1000                   = $sTmpOrig_anexo_ouvd_doc1_1000;
                  $this->anexo_ouvd_doc1_1000_original_filename = '';
              }

              if ($bChange_anexo_ouvd_doc2_1000)
              {
                  $this->anexo_ouvd_doc2_1000                   = $sTmpOrig_anexo_ouvd_doc2_1000;
                  $this->anexo_ouvd_doc2_1000_original_filename = '';
              }

              $this->nm_tira_formatacao();
              $this->nm_converte_datas();
          }  
      }  
      if ($this->nmgp_opcao == "incluir") 
      { 
          $NM_cmp_auto = "";
          $NM_seq_auto = "";
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
          $bInsertOk = true;
          $aInsertOk = array(); 
          $bInsertOk = $bInsertOk && empty($aInsertOk);
          if (!isset($_POST['nmgp_ins_valid']) || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['insert_validation'] != $_POST['nmgp_ins_valid'])
          {
              $bInsertOk = false;
              $this->Erro->mensagem(__FILE__, __LINE__, 'security', $this->Ini->Nm_lang['lang_errm_inst_vald']);
              if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler'])
              {
                  $this->nmgp_opcao = 'refresh_insert';
                  if ($this->NM_ajax_flag)
                  {
                      cadastro_DEN_1000_registro_mob_pack_ajax_response();
                      exit;
                  }
              }
          }
          if ($bInsertOk)
          { 
              $dir_file = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_img1_1000_scfile_name, $dir_file, "anexo_ouvd_img1_1000");
              if (trim($this->anexo_ouvd_img1_1000_scfile_name) != $_test_file)
              {
                  $this->anexo_ouvd_img1_1000_scfile_name = $_test_file;
                  $this->anexo_ouvd_img1_1000 = $_test_file;
              }
              $dir_file = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_img2_1000_scfile_name, $dir_file, "anexo_ouvd_img2_1000");
              if (trim($this->anexo_ouvd_img2_1000_scfile_name) != $_test_file)
              {
                  $this->anexo_ouvd_img2_1000_scfile_name = $_test_file;
                  $this->anexo_ouvd_img2_1000 = $_test_file;
              }
              $dir_file = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_doc1_1000_scfile_name, $dir_file, "anexo_ouvd_doc1_1000");
              if (trim($this->anexo_ouvd_doc1_1000_scfile_name) != $_test_file)
              {
                  $this->anexo_ouvd_doc1_1000_scfile_name = $_test_file;
                  $this->anexo_ouvd_doc1_1000 = $_test_file;
              }
              $dir_file = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              $_test_file = $this->fetchUniqueUploadName($this->anexo_ouvd_doc2_1000_scfile_name, $dir_file, "anexo_ouvd_doc2_1000");
              if (trim($this->anexo_ouvd_doc2_1000_scfile_name) != $_test_file)
              {
                  $this->anexo_ouvd_doc2_1000_scfile_name = $_test_file;
                  $this->anexo_ouvd_doc2_1000 = $_test_file;
              }
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (titulo_manifestacao_1000, desc_manifestacao_1000, id_categoria_1100, desc_area_setor_1000, dt_ocorrido_1000, ouvd_anonima_1000, nome_inf_ouvd_1000, cpf_cnpj_ouvd_1000, tel_inf_ouvd_1000, email_inf_ouvd_1000, dt_ini_inv_ouvd_1000, andamento_inv_ouvd_1000, conclusao_inv_ouvd_1000, nivel_atend_atual_1000, id_status_ouvd_1000, id_controlador_1000, data_hora_cadastro_1000, token_ouvd_1000, anexo_ouvd_img1_1000, anexo_ouvd_img2_1000, anexo_ouvd_doc1_1000, anexo_ouvd_doc2_1000) VALUES ('$this->titulo_manifestacao_1000', '$this->desc_manifestacao_1000', $this->id_categoria_1100, '$this->desc_area_setor_1000', #$this->dt_ocorrido_1000#, $this->ouvd_anonima_1000, '$this->nome_inf_ouvd_1000', '$this->cpf_cnpj_ouvd_1000', '$this->tel_inf_ouvd_1000', '$this->email_inf_ouvd_1000', #$this->dt_ini_inv_ouvd_1000#, '$this->andamento_inv_ouvd_1000', '$this->conclusao_inv_ouvd_1000', $this->nivel_atend_atual_1000, $this->id_status_ouvd_1000, $this->id_controlador_1000, #$this->data_hora_cadastro_1000#, '$this->token_ouvd_1000', '$this->anexo_ouvd_img1_1000', '$this->anexo_ouvd_img2_1000', '$this->anexo_ouvd_doc1_1000', '$this->anexo_ouvd_doc2_1000')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "titulo_manifestacao_1000, desc_manifestacao_1000, id_categoria_1100, desc_area_setor_1000, dt_ocorrido_1000, ouvd_anonima_1000, nome_inf_ouvd_1000, cpf_cnpj_ouvd_1000, tel_inf_ouvd_1000, email_inf_ouvd_1000, dt_ini_inv_ouvd_1000, andamento_inv_ouvd_1000, conclusao_inv_ouvd_1000, nivel_atend_atual_1000, id_status_ouvd_1000, id_controlador_1000, data_hora_cadastro_1000, token_ouvd_1000, anexo_ouvd_img1_1000, anexo_ouvd_img2_1000, anexo_ouvd_doc1_1000, anexo_ouvd_doc2_1000) VALUES (" . $NM_seq_auto . "'$this->titulo_manifestacao_1000', '$this->desc_manifestacao_1000', $this->id_categoria_1100, '$this->desc_area_setor_1000', " . $this->Ini->date_delim . $this->dt_ocorrido_1000 . $this->Ini->date_delim1 . ", $this->ouvd_anonima_1000, '$this->nome_inf_ouvd_1000', '$this->cpf_cnpj_ouvd_1000', '$this->tel_inf_ouvd_1000', '$this->email_inf_ouvd_1000', " . $this->Ini->date_delim . $this->dt_ini_inv_ouvd_1000 . $this->Ini->date_delim1 . ", '$this->andamento_inv_ouvd_1000', '$this->conclusao_inv_ouvd_1000', $this->nivel_atend_atual_1000, $this->id_status_ouvd_1000, $this->id_controlador_1000, " . $this->Ini->date_delim . $this->data_hora_cadastro_1000 . $this->Ini->date_delim1 . ", '$this->token_ouvd_1000', '$this->anexo_ouvd_img1_1000', '$this->anexo_ouvd_img2_1000', '$this->anexo_ouvd_doc1_1000', '$this->anexo_ouvd_doc2_1000')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sqlite))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "titulo_manifestacao_1000, desc_manifestacao_1000, id_categoria_1100, desc_area_setor_1000, dt_ocorrido_1000, ouvd_anonima_1000, nome_inf_ouvd_1000, cpf_cnpj_ouvd_1000, tel_inf_ouvd_1000, email_inf_ouvd_1000, dt_ini_inv_ouvd_1000, andamento_inv_ouvd_1000, conclusao_inv_ouvd_1000, nivel_atend_atual_1000, id_status_ouvd_1000, id_controlador_1000, data_hora_cadastro_1000, token_ouvd_1000, anexo_ouvd_img1_1000, anexo_ouvd_img2_1000, anexo_ouvd_doc1_1000, anexo_ouvd_doc2_1000) VALUES (" . $NM_seq_auto . "'$this->titulo_manifestacao_1000', '$this->desc_manifestacao_1000', $this->id_categoria_1100, '$this->desc_area_setor_1000', " . $this->Ini->date_delim . $this->dt_ocorrido_1000 . $this->Ini->date_delim1 . ", $this->ouvd_anonima_1000, '$this->nome_inf_ouvd_1000', '$this->cpf_cnpj_ouvd_1000', '$this->tel_inf_ouvd_1000', '$this->email_inf_ouvd_1000', " . $this->Ini->date_delim . $this->dt_ini_inv_ouvd_1000 . $this->Ini->date_delim1 . ", '$this->andamento_inv_ouvd_1000', '$this->conclusao_inv_ouvd_1000', $this->nivel_atend_atual_1000, $this->id_status_ouvd_1000, $this->id_controlador_1000, " . $this->Ini->date_delim . $this->data_hora_cadastro_1000 . $this->Ini->date_delim1 . ", '$this->token_ouvd_1000', '$this->anexo_ouvd_img1_1000', '$this->anexo_ouvd_img2_1000', '$this->anexo_ouvd_doc1_1000', '$this->anexo_ouvd_doc2_1000')"; 
              }
              else
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "titulo_manifestacao_1000, desc_manifestacao_1000, id_categoria_1100, desc_area_setor_1000, dt_ocorrido_1000, ouvd_anonima_1000, nome_inf_ouvd_1000, cpf_cnpj_ouvd_1000, tel_inf_ouvd_1000, email_inf_ouvd_1000, dt_ini_inv_ouvd_1000, andamento_inv_ouvd_1000, conclusao_inv_ouvd_1000, nivel_atend_atual_1000, id_status_ouvd_1000, id_controlador_1000, data_hora_cadastro_1000, token_ouvd_1000, anexo_ouvd_img1_1000, anexo_ouvd_img2_1000, anexo_ouvd_doc1_1000, anexo_ouvd_doc2_1000) VALUES (" . $NM_seq_auto . "'$this->titulo_manifestacao_1000', '$this->desc_manifestacao_1000', $this->id_categoria_1100, '$this->desc_area_setor_1000', " . $this->Ini->date_delim . $this->dt_ocorrido_1000 . $this->Ini->date_delim1 . ", $this->ouvd_anonima_1000, '$this->nome_inf_ouvd_1000', '$this->cpf_cnpj_ouvd_1000', '$this->tel_inf_ouvd_1000', '$this->email_inf_ouvd_1000', " . $this->Ini->date_delim . $this->dt_ini_inv_ouvd_1000 . $this->Ini->date_delim1 . ", '$this->andamento_inv_ouvd_1000', '$this->conclusao_inv_ouvd_1000', $this->nivel_atend_atual_1000, $this->id_status_ouvd_1000, $this->id_controlador_1000, " . $this->Ini->date_delim . $this->data_hora_cadastro_1000 . $this->Ini->date_delim1 . ", '$this->token_ouvd_1000', '$this->anexo_ouvd_img1_1000', '$this->anexo_ouvd_img2_1000', '$this->anexo_ouvd_doc1_1000', '$this->anexo_ouvd_doc2_1000')"; 
              }
              $comando = str_replace("N'null'", "null", $comando) ; 
              $comando = str_replace("'null'", "null", $comando) ; 
              $comando = str_replace("#null#", "null", $comando) ; 
              $comando = str_replace($this->Ini->date_delim . "null" . $this->Ini->date_delim1, "null", $comando) ; 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $comando; 
              $rs = $this->Db->Execute($comando); 
              if ($rs === false)  
              { 
                  if (FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "MAIL SENT") && FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "WARNING"))
                  {
                      $dbErrorMessage = $this->Db->ErrorMsg();
                      $dbErrorCode = $this->Db->ErrorNo();
                      $this->handleDbErrorMessage($dbErrorMessage, $dbErrorCode);
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_inst'], $dbErrorMessage, true);
                      if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler'])
                      { 
                          $this->sc_erro_insert = $dbErrorMessage;
                          $this->nmgp_opcao     = 'refresh_insert';
                          $this->NM_rollback_db(); 
                          if ($this->NM_ajax_flag)
                          {
                              cadastro_DEN_1000_registro_mob_pack_ajax_response();
                              exit; 
                          }
                      }  
                  }  
              }  
              if ('refresh_insert' != $this->nmgp_opcao)
              {
              $this->titulo_manifestacao_1000 = $this->titulo_manifestacao_1000_before_qstr;
              $this->desc_manifestacao_1000 = $this->desc_manifestacao_1000_before_qstr;
              $this->desc_area_setor_1000 = $this->desc_area_setor_1000_before_qstr;
              $this->nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000_before_qstr;
              $this->cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000_before_qstr;
              $this->tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000_before_qstr;
              $this->email_inf_ouvd_1000 = $this->email_inf_ouvd_1000_before_qstr;
              $this->andamento_inv_ouvd_1000 = $this->andamento_inv_ouvd_1000_before_qstr;
              $this->conclusao_inv_ouvd_1000 = $this->conclusao_inv_ouvd_1000_before_qstr;
              $this->token_ouvd_1000 = $this->token_ouvd_1000_before_qstr;
              $this->anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000_before_qstr;
              $this->anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000_before_qstr;
              $this->anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000_before_qstr;
              $this->anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000_before_qstr;
              }

              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['db_changed'] = true;

              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']))
              {
                  unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']);
              }

              $dir_img = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              if (nm_mkdir($dir_img))  
              { 
                  $reg_anexo_ouvd_img1_1000 = ""; 
                  if (is_file($this->SC_IMG_anexo_ouvd_img1_1000)) { 
                      $arq_anexo_ouvd_img1_1000 = fopen($this->SC_IMG_anexo_ouvd_img1_1000, "r") ; 
                      $reg_anexo_ouvd_img1_1000 = fread($arq_anexo_ouvd_img1_1000, filesize($this->SC_IMG_anexo_ouvd_img1_1000)) ; 
                      fclose($arq_anexo_ouvd_img1_1000) ;  
                      $arq_anexo_ouvd_img1_1000 = fopen($dir_img . trim($this->anexo_ouvd_img1_1000_scfile_name), "w") ; 
                      fwrite($arq_anexo_ouvd_img1_1000, $reg_anexo_ouvd_img1_1000) ;  
                      fclose($arq_anexo_ouvd_img1_1000) ;  
                  }
              } 
              $dir_img = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              if (nm_mkdir($dir_img))  
              { 
                  $reg_anexo_ouvd_img2_1000 = ""; 
                  if (is_file($this->SC_IMG_anexo_ouvd_img2_1000)) { 
                      $arq_anexo_ouvd_img2_1000 = fopen($this->SC_IMG_anexo_ouvd_img2_1000, "r") ; 
                      $reg_anexo_ouvd_img2_1000 = fread($arq_anexo_ouvd_img2_1000, filesize($this->SC_IMG_anexo_ouvd_img2_1000)) ; 
                      fclose($arq_anexo_ouvd_img2_1000) ;  
                      $arq_anexo_ouvd_img2_1000 = fopen($dir_img . trim($this->anexo_ouvd_img2_1000_scfile_name), "w") ; 
                      fwrite($arq_anexo_ouvd_img2_1000, $reg_anexo_ouvd_img2_1000) ;  
                      fclose($arq_anexo_ouvd_img2_1000) ;  
                  }
              } 
              $dir_doc = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              if (nm_mkdir($dir_doc))  
              { 
                  $reg_anexo_ouvd_doc1_1000 = ""; 
                  if (is_file($this->SC_DOC_anexo_ouvd_doc1_1000)) { 
                      $arq_anexo_ouvd_doc1_1000 = fopen($this->SC_DOC_anexo_ouvd_doc1_1000, "r") ; 
                      $reg_anexo_ouvd_doc1_1000 = fread($arq_anexo_ouvd_doc1_1000, filesize($this->SC_DOC_anexo_ouvd_doc1_1000)) ; 
                      fclose($arq_anexo_ouvd_doc1_1000) ;  
                      $arq_anexo_ouvd_doc1_1000 = fopen($dir_doc . trim($this->anexo_ouvd_doc1_1000_scfile_name), "w") ; 
                      fwrite($arq_anexo_ouvd_doc1_1000, $reg_anexo_ouvd_doc1_1000) ;  
                      fclose($arq_anexo_ouvd_doc1_1000) ;  
                  }
              } 
              $dir_doc = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
              if (nm_mkdir($dir_doc))  
              { 
                  $reg_anexo_ouvd_doc2_1000 = ""; 
                  if (is_file($this->SC_DOC_anexo_ouvd_doc2_1000)) { 
                      $arq_anexo_ouvd_doc2_1000 = fopen($this->SC_DOC_anexo_ouvd_doc2_1000, "r") ; 
                      $reg_anexo_ouvd_doc2_1000 = fread($arq_anexo_ouvd_doc2_1000, filesize($this->SC_DOC_anexo_ouvd_doc2_1000)) ; 
                      fclose($arq_anexo_ouvd_doc2_1000) ;  
                      $arq_anexo_ouvd_doc2_1000 = fopen($dir_doc . trim($this->anexo_ouvd_doc2_1000_scfile_name), "w") ; 
                      fwrite($arq_anexo_ouvd_doc2_1000, $reg_anexo_ouvd_doc2_1000) ;  
                      fclose($arq_anexo_ouvd_doc2_1000) ;  
                  }
              } 
              $this->sc_evento = "insert"; 
              $this->titulo_manifestacao_1000 = $this->titulo_manifestacao_1000_before_qstr;
              $this->desc_manifestacao_1000 = $this->desc_manifestacao_1000_before_qstr;
              $this->desc_area_setor_1000 = $this->desc_area_setor_1000_before_qstr;
              $this->nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000_before_qstr;
              $this->cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000_before_qstr;
              $this->tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000_before_qstr;
              $this->email_inf_ouvd_1000 = $this->email_inf_ouvd_1000_before_qstr;
              $this->andamento_inv_ouvd_1000 = $this->andamento_inv_ouvd_1000_before_qstr;
              $this->conclusao_inv_ouvd_1000 = $this->conclusao_inv_ouvd_1000_before_qstr;
              $this->token_ouvd_1000 = $this->token_ouvd_1000_before_qstr;
              $this->anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000_before_qstr;
              $this->anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000_before_qstr;
              $this->anexo_ouvd_doc1_1000 = $this->anexo_ouvd_doc1_1000_before_qstr;
              $this->anexo_ouvd_doc2_1000 = $this->anexo_ouvd_doc2_1000_before_qstr;
              $this->sc_insert_on = true; 
              if (empty($this->sc_erro_insert)) {
                  $this->record_insert_ok = true;
              } 
              if ('refresh_insert' != $this->nmgp_opcao && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_redir_insert']) || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_redir_insert'] != "S"))
              {
              $this->nmgp_opcao = "novo"; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "R")
              { 
                   $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['return_edit'] = "new";
              } 
              }
              $this->nm_flag_iframe = true;
          } 
          if ($this->lig_edit_lookup)
          {
              $this->lig_edit_lookup_call = true;
          }
      } 
      if ($this->nmgp_opcao == "excluir") 
      { 
          $this->chave = substr($this->Db->qstr($this->chave), 1, -1); 

          $bDelecaoOk = true;
          $sMsgErro   = '';

          if ($bDelecaoOk)
          {

          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where "; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where  "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where "; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where  "); 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              exit; 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              exit; 
          }  
          $aEraseFiles = array();
          $tmp_result = (int) $rs1->fields[0]; 
          if ($tmp_result != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_dele_nfnd']); 
              $this->nmgp_opcao = "nada"; 
              $this->sc_evento = 'delete';
          } 
          else 
          { 
              $rs1->Close(); 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where  "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where  "); 
              }  
              else  
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where  "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where  "); 
              }  
              if ($rs === false) 
              { 
                  $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dele'], $this->Db->ErrorMsg(), true); 
                  if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler']) 
                  { 
                      $this->sc_erro_delete = $this->Db->ErrorMsg();  
                      $this->NM_rollback_db(); 
                      if ($this->NM_ajax_flag)
                      {
                          cadastro_DEN_1000_registro_mob_pack_ajax_response();
                          exit; 
                      }
                  } 
              } 
                  $sDirErase     = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_img1_1000']);
                  $sDirErase     = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_img2_1000']);
                  $sDirErase     = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_doc1_1000']);
                  $sDirErase     = $this->Ini->path_doc . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/"; 
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['anexo_ouvd_doc2_1000']);
              if (!empty($aEraseFiles))
              {
                  foreach ($aEraseFiles as $aEraseData)
                  {
                      $sEraseFile = $aEraseData['dir'] . $aEraseData['file'];
                      if (@is_file($sEraseFile))
                      {
                          @unlink($sEraseFile);
                      }
                  }
              }
              $this->sc_evento = "delete"; 
              if (empty($this->sc_erro_delete)) {
                  $this->record_delete_ok = true;
              }
              $this->nmgp_opcao = "avanca"; 
              $this->nm_flag_iframe = true;
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start']--; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start'] < 0)
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start'] = 0; 
              }

              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['db_changed'] = true;

              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']))
              {
                  unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']);
              }

              if ($this->lig_edit_lookup)
              {
                  $this->lig_edit_lookup_call = true;
              }
          }

          }
          else
          {
              $this->sc_evento = "delete"; 
              $this->nmgp_opcao = "igual"; 
              $this->Erro->mensagem(__FILE__, __LINE__, "critica", $sMsgErro); 
          }

      }  
      $this->restore_zeros_null();
    if ("insert" == $this->sc_evento && $this->nmgp_opcao != "nada") {
        $_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_codigo = $this->codigo;
    $original_desc_area_setor_1000 = $this->desc_area_setor_1000;
    $original_desc_manifestacao_1000 = $this->desc_manifestacao_1000;
    $original_dt_ocorrido_1000 = $this->dt_ocorrido_1000;
    $original_email_inf_ouvd_1000 = $this->email_inf_ouvd_1000;
    $original_id_categoria_1100 = $this->id_categoria_1100;
    $original_nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000;
    $original_ouvd_anonima_1000 = $this->ouvd_anonima_1000;
    $original_titulo_manifestacao_1000 = $this->titulo_manifestacao_1000;
}
  $params = array(
'type' => 'success',
'showConfirmButton' => true,
'position' => 'center',
'toast' => false
);

$this->nm_mens_alert[] = "Manifestação registrada com sucesso."; $this->nm_params_alert[] = $params; if ($this->NM_ajax_flag) { $this->sc_ajax_alert("Manifestação registrada com sucesso.", $params); }if(!empty($this->email_inf_ouvd_1000 ) && $this->ouvd_anonima_1000  == 0) {
	$this->send_email($this->nome_inf_ouvd_1000 , $this->email_inf_ouvd_1000 , $this->codigo , $this->desc_manifestacao_1000 );
}

$getRespNiv1Data = "SELECT
  T2.nome_1100,
  T2.email_1100
FROM OUVD_1100_categoria T1
INNER JOIN LGPD_1100_equipe T2
  ON T1.id_pessoa_nivel1 = T2.cod_pessoa_1100
WHERE T1.id_categoria_ouvd_1100 = " . $this->id_categoria_1100 ;
 
      $nm_select = $getRespNiv1Data; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->data_resp_nivel = 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->data_resp_nivel[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->data_resp_nivel = false;
          $this->data_resp_nivel_erro = $this->Db->ErrorMsg();
      } 


if(!empty($this->data_resp_nivel )) {
	$this->send_email_nivel($this->data_resp_nivel[0][0], $this->data_resp_nivel[0][1], $this->codigo );
}
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_codigo != $this->codigo || (isset($bFlagRead_codigo) && $bFlagRead_codigo)))
    {
        $this->ajax_return_values_codigo(true);
    }
    if (($original_desc_area_setor_1000 != $this->desc_area_setor_1000 || (isset($bFlagRead_desc_area_setor_1000) && $bFlagRead_desc_area_setor_1000)))
    {
        $this->ajax_return_values_desc_area_setor_1000(true);
    }
    if (($original_desc_manifestacao_1000 != $this->desc_manifestacao_1000 || (isset($bFlagRead_desc_manifestacao_1000) && $bFlagRead_desc_manifestacao_1000)))
    {
        $this->ajax_return_values_desc_manifestacao_1000(true);
    }
    if (($original_dt_ocorrido_1000 != $this->dt_ocorrido_1000 || (isset($bFlagRead_dt_ocorrido_1000) && $bFlagRead_dt_ocorrido_1000)))
    {
        $this->ajax_return_values_dt_ocorrido_1000(true);
    }
    if (($original_email_inf_ouvd_1000 != $this->email_inf_ouvd_1000 || (isset($bFlagRead_email_inf_ouvd_1000) && $bFlagRead_email_inf_ouvd_1000)))
    {
        $this->ajax_return_values_email_inf_ouvd_1000(true);
    }
    if (($original_id_categoria_1100 != $this->id_categoria_1100 || (isset($bFlagRead_id_categoria_1100) && $bFlagRead_id_categoria_1100)))
    {
        $this->ajax_return_values_id_categoria_1100(true);
    }
    if (($original_nome_inf_ouvd_1000 != $this->nome_inf_ouvd_1000 || (isset($bFlagRead_nome_inf_ouvd_1000) && $bFlagRead_nome_inf_ouvd_1000)))
    {
        $this->ajax_return_values_nome_inf_ouvd_1000(true);
    }
    if (($original_ouvd_anonima_1000 != $this->ouvd_anonima_1000 || (isset($bFlagRead_ouvd_anonima_1000) && $bFlagRead_ouvd_anonima_1000)))
    {
        $this->ajax_return_values_ouvd_anonima_1000(true);
    }
    if (($original_titulo_manifestacao_1000 != $this->titulo_manifestacao_1000 || (isset($bFlagRead_titulo_manifestacao_1000) && $bFlagRead_titulo_manifestacao_1000)))
    {
        $this->ajax_return_values_titulo_manifestacao_1000(true);
    }
}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off'; 
    }
      if (!empty($this->Campos_Mens_erro)) 
      {
          $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro); 
          $this->Campos_Mens_erro = ""; 
          $this->nmgp_opc_ant = $salva_opcao ; 
          if ($salva_opcao == "incluir") 
          { 
              $GLOBALS["erro_incl"] = 1; 
          }
          if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "excluir") 
          {
              $this->nmgp_opcao = "nada"; 
          } 
          $this->sc_evento = ""; 
          $this->NM_rollback_db(); 
          return; 
      }
      if ($salva_opcao == "incluir" && $GLOBALS["erro_incl"] != 1) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['parms'] = "chave?#?$this->chave?@?"; 
      }
      $this->nmgp_dados_form['anexo_ouvd_img1_1000'] = ""; 
      $this->anexo_ouvd_img1_1000_limpa = ""; 
      $this->anexo_ouvd_img1_1000_salva = ""; 
      $this->nmgp_dados_form['anexo_ouvd_img2_1000'] = ""; 
      $this->anexo_ouvd_img2_1000_limpa = ""; 
      $this->anexo_ouvd_img2_1000_salva = ""; 
      $this->nmgp_dados_form['anexo_ouvd_doc1_1000'] = ""; 
      $this->anexo_ouvd_doc1_1000_limpa = ""; 
      $this->anexo_ouvd_doc1_1000_salva = ""; 
      $this->nmgp_dados_form['anexo_ouvd_doc2_1000'] = ""; 
      $this->anexo_ouvd_doc2_1000_limpa = ""; 
      $this->anexo_ouvd_doc2_1000_salva = ""; 
      $this->NM_commit_db(); 
      if ($this->sc_evento != "insert" && $this->sc_evento != "update" && $this->sc_evento != "delete")
      { 
          $this->chave = null === $this->chave ? null : substr($this->Db->qstr($this->chave), 1, -1); 
      } 
      if ($this->nmgp_opcao != "nada") 
      {
          $this->nmgp_opcao = "novo"; 
      }
      if (isset($this->NM_where_filter))
      {
          $this->NM_where_filter = str_replace("@percent@", "%", $this->NM_where_filter);
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'] = trim($this->NM_where_filter);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']))
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']);
          }
      }
      $sc_where_filter = '';
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter_form'])
      {
          $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter_form'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'] && $sc_where_filter != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'])
      {
          if (empty($sc_where_filter))
          {
              $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'];
          }
          else
          {
              $sc_where_filter .= " and (" . $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'] . ")";
          }
      }
      if ($this->nmgp_opcao != "novo" && $this->nmgp_opcao != "nada" && $this->nmgp_opcao != "inicio")
      { 
          $this->nmgp_opcao = "igual"; 
      } 
      $GLOBALS["NM_ERRO_IBASE"] = 0;  
//---------- 
      if ($this->nmgp_opcao != "novo" && $this->nmgp_opcao != "nada" && $this->nmgp_opcao != "refresh_insert") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['parms'] = ""; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 1;  
          } 
          $nmgp_select = "SELECT titulo_manifestacao_1000, desc_manifestacao_1000, id_categoria_1100, desc_area_setor_1000, dt_ocorrido_1000, ouvd_anonima_1000, nome_inf_ouvd_1000, cpf_cnpj_ouvd_1000, tel_inf_ouvd_1000, email_inf_ouvd_1000, dt_ini_inv_ouvd_1000, andamento_inv_ouvd_1000, conclusao_inv_ouvd_1000, nivel_atend_atual_1000, id_status_ouvd_1000, id_controlador_1000, data_hora_cadastro_1000, token_ouvd_1000, anexo_ouvd_img1_1000, anexo_ouvd_img2_1000, anexo_ouvd_doc1_1000, anexo_ouvd_doc2_1000 from " . $this->Ini->nm_tabela ; 
          $aWhere = array();
          $aWhere[] = $sc_where_filter;
          if ($this->nmgp_opcao == "igual" || (($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "R") && ($this->sc_evento == "insert" || $this->sc_evento == "update")) )
          { 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $aWhere[] = ""; 
              }  
              else  
              {
                  $aWhere[] = ""; 
              }  
              if (!empty($sc_where_filter))  
              {
                  $teste_select = $nmgp_select . $this->returnWhere($aWhere);
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = $teste_select; 
                  $rs = $this->Db->Execute($teste_select); 
                  if ($rs->EOF)
                  {
                     $aWhere = array($sc_where_filter);
                  }  
                  $rs->Close(); 
              }  
          } 
          $nmgp_select .= $this->returnWhere($aWhere) . ' ';
          $sc_order_by = "";
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "R")
          {
              if ($this->sc_evento == "update")
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['select'] = $nmgp_select;
                  $this->nm_gera_html();
              } 
              elseif (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['select']))
              { 
                  $nmgp_select = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['select'];
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['select'] = ""; 
              } 
          } 
          if ($this->nmgp_opcao == "igual") 
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
              $rs = $this->Db->Execute($nmgp_select) ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start']) ; 
          } 
          else  
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
              $rs = $this->Db->Execute($nmgp_select) ; 
              if (!$rs === false && !$rs->EOF) 
              { 
                  $rs->Move($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start']) ;  
              } 
          } 
          if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
              exit ; 
          }  
          if ($rs === false && $GLOBALS["NM_ERRO_IBASE"] == 1) 
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_nfnd_extr'], $this->Db->ErrorMsg()); 
              exit ; 
          }  
          if ($rs->EOF) 
          { 
              if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter']))
              {
                  $this->nmgp_form_empty        = true;
                  $this->NM_ajax_info['buttonDisplay']['first']   = $this->nmgp_botoes['first']   = "off";
                  $this->NM_ajax_info['buttonDisplay']['back']    = $this->nmgp_botoes['back']    = "off";
                  $this->NM_ajax_info['buttonDisplay']['forward'] = $this->nmgp_botoes['forward'] = "off";
                  $this->NM_ajax_info['buttonDisplay']['last']    = $this->nmgp_botoes['last']    = "off";
                  $this->NM_ajax_info['buttonDisplay']['update']  = $this->nmgp_botoes['update']  = "off";
                  $this->NM_ajax_info['buttonDisplay']['delete']  = $this->nmgp_botoes['delete']  = "off";
                  $this->NM_ajax_info['buttonDisplay']['first']   = $this->nmgp_botoes['insert']  = "off";
                  $this->NM_ajax_info['buttonDisplay']['Voltar'] = $this->nmgp_botoes['Voltar'] = "off";
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter'] = true;
                  return; 
              }
              if ($this->nmgp_botoes['insert'] != "on")
              {
                  $this->nmgp_form_empty        = true;
                  $this->NM_ajax_info['buttonDisplay']['first']   = $this->nmgp_botoes['first']   = "off";
                  $this->NM_ajax_info['buttonDisplay']['back']    = $this->nmgp_botoes['back']    = "off";
                  $this->NM_ajax_info['buttonDisplay']['forward'] = $this->nmgp_botoes['forward'] = "off";
                  $this->NM_ajax_info['buttonDisplay']['last']    = $this->nmgp_botoes['last']    = "off";
              }
              $this->nmgp_opcao = "novo"; 
              $this->nm_flag_saida_novo = "S"; 
              $rs->Close(); 
              $this->NM_ajax_info['buttonDisplay']['Voltar'] = $this->nmgp_botoes['Voltar'] = "on";
              if ($this->aba_iframe)
              {
                  $this->NM_ajax_info['buttonDisplay']['exit'] = $this->nmgp_botoes['exit'] = 'off';
              }
          } 
          if ($rs === false && $GLOBALS["NM_ERRO_IBASE"] == 1) 
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_nfnd_extr']); 
              $this->nmgp_opcao = "novo"; 
          }  
          if ($this->nmgp_opcao != "novo") 
          { 
              $this->titulo_manifestacao_1000 = $rs->fields[0] ; 
              $this->nmgp_dados_select['titulo_manifestacao_1000'] = $this->titulo_manifestacao_1000;
              $this->desc_manifestacao_1000 = $rs->fields[1] ; 
              $this->nmgp_dados_select['desc_manifestacao_1000'] = $this->desc_manifestacao_1000;
              $this->id_categoria_1100 = $rs->fields[2] ; 
              $this->nmgp_dados_select['id_categoria_1100'] = $this->id_categoria_1100;
              $this->desc_area_setor_1000 = $rs->fields[3] ; 
              $this->nmgp_dados_select['desc_area_setor_1000'] = $this->desc_area_setor_1000;
              $this->dt_ocorrido_1000 = $rs->fields[4] ; 
              $this->nmgp_dados_select['dt_ocorrido_1000'] = $this->dt_ocorrido_1000;
              $this->ouvd_anonima_1000 = $rs->fields[5] ; 
              $this->nmgp_dados_select['ouvd_anonima_1000'] = $this->ouvd_anonima_1000;
              $this->nome_inf_ouvd_1000 = $rs->fields[6] ; 
              $this->nmgp_dados_select['nome_inf_ouvd_1000'] = $this->nome_inf_ouvd_1000;
              $this->cpf_cnpj_ouvd_1000 = $rs->fields[7] ; 
              $this->nmgp_dados_select['cpf_cnpj_ouvd_1000'] = $this->cpf_cnpj_ouvd_1000;
              $this->cpf_cnpj_ouvd_1000 = trim($this->cpf_cnpj_ouvd_1000);
              if (strlen($this->cpf_cnpj_ouvd_1000) < 14 && strlen($this->cpf_cnpj_ouvd_1000) != 11  && !empty($this->cpf_cnpj_ouvd_1000)) 
              { 
                  $this->cpf_cnpj_ouvd_1000 = str_repeat(0, 14 - strlen($this->cpf_cnpj_ouvd_1000)) . $this->cpf_cnpj_ouvd_1000; 
              } 
              if (strlen($this->cpf_cnpj_ouvd_1000) > 11 && substr($this->cpf_cnpj_ouvd_1000, 0, 3) == "000" && $teste_validade->CNPJ($this->cpf_cnpj_ouvd_1000) == false) 
              { 
                  $this->cpf_cnpj_ouvd_1000 = substr($this->cpf_cnpj_ouvd_1000, strlen($this->cpf_cnpj_ouvd_1000) - 11); 
              } 
              $this->tel_inf_ouvd_1000 = $rs->fields[8] ; 
              $this->nmgp_dados_select['tel_inf_ouvd_1000'] = $this->tel_inf_ouvd_1000;
              $this->email_inf_ouvd_1000 = $rs->fields[9] ; 
              $this->nmgp_dados_select['email_inf_ouvd_1000'] = $this->email_inf_ouvd_1000;
              $this->dt_ini_inv_ouvd_1000 = $rs->fields[10] ; 
              $this->nmgp_dados_select['dt_ini_inv_ouvd_1000'] = $this->dt_ini_inv_ouvd_1000;
              $this->andamento_inv_ouvd_1000 = $rs->fields[11] ; 
              $this->nmgp_dados_select['andamento_inv_ouvd_1000'] = $this->andamento_inv_ouvd_1000;
              $this->conclusao_inv_ouvd_1000 = $rs->fields[12] ; 
              $this->nmgp_dados_select['conclusao_inv_ouvd_1000'] = $this->conclusao_inv_ouvd_1000;
              $this->nivel_atend_atual_1000 = $rs->fields[13] ; 
              $this->nmgp_dados_select['nivel_atend_atual_1000'] = $this->nivel_atend_atual_1000;
              $this->id_status_ouvd_1000 = $rs->fields[14] ; 
              $this->nmgp_dados_select['id_status_ouvd_1000'] = $this->id_status_ouvd_1000;
              $this->id_controlador_1000 = $rs->fields[15] ; 
              $this->nmgp_dados_select['id_controlador_1000'] = $this->id_controlador_1000;
              $this->data_hora_cadastro_1000 = $rs->fields[16] ; 
              if (substr($this->data_hora_cadastro_1000, 10, 1) == "-") 
              { 
                 $this->data_hora_cadastro_1000 = substr($this->data_hora_cadastro_1000, 0, 10) . " " . substr($this->data_hora_cadastro_1000, 11);
              } 
              if (substr($this->data_hora_cadastro_1000, 13, 1) == ".") 
              { 
                 $this->data_hora_cadastro_1000 = substr($this->data_hora_cadastro_1000, 0, 13) . ":" . substr($this->data_hora_cadastro_1000, 14, 2) . ":" . substr($this->data_hora_cadastro_1000, 17);
              } 
              $this->nmgp_dados_select['data_hora_cadastro_1000'] = $this->data_hora_cadastro_1000;
              $this->token_ouvd_1000 = $rs->fields[17] ; 
              $this->nmgp_dados_select['token_ouvd_1000'] = $this->token_ouvd_1000;
              $this->anexo_ouvd_img1_1000 = $rs->fields[18] ; 
              $this->nmgp_dados_select['anexo_ouvd_img1_1000'] = $this->anexo_ouvd_img1_1000;
              $this->anexo_ouvd_img2_1000 = $rs->fields[19] ; 
              $this->nmgp_dados_select['anexo_ouvd_img2_1000'] = $this->anexo_ouvd_img2_1000;
              $this->anexo_ouvd_doc1_1000 = $rs->fields[20] ; 
              $this->nmgp_dados_select['anexo_ouvd_doc1_1000'] = $this->anexo_ouvd_doc1_1000;
              $this->anexo_ouvd_doc2_1000 = $rs->fields[21] ; 
              $this->nmgp_dados_select['anexo_ouvd_doc2_1000'] = $this->anexo_ouvd_doc2_1000;
          $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->id_categoria_1100 = (string)$this->id_categoria_1100; 
              $this->ouvd_anonima_1000 = (string)$this->ouvd_anonima_1000; 
              $this->nivel_atend_atual_1000 = (string)$this->nivel_atend_atual_1000; 
              $this->id_status_ouvd_1000 = (string)$this->id_status_ouvd_1000; 
              $this->id_controlador_1000 = (string)$this->id_controlador_1000; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['parms'] = "chave?#?$this->chave?@?";
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['sub_dir'][0]  = "/ouvidoria/" . $_SESSION['cnpj_controlador'];
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['sub_dir'][1]  = "/ouvidoria/" . $_SESSION['cnpj_controlador'];
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['sub_dir'][2]  = "/ouvidoria/" . $_SESSION['cnpj_controlador'];
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['sub_dir'][3]  = "/ouvidoria/" . $_SESSION['cnpj_controlador'];
          } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_select'] = $this->nmgp_dados_select;
          if (!$this->NM_ajax_flag || 'backup_line' != $this->NM_ajax_opcao)
          {
              $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start'];
              $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start'] < $qt_geral_reg_cadastro_DEN_1000_registro_mob;
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opcao']   = '';
          }
      } 
      if ($this->nmgp_opcao == "novo" || $this->nmgp_opcao == "refresh_insert") 
      { 
          $this->sc_evento_old = $this->sc_evento;
          $this->sc_evento = "novo";
          if ('refresh_insert' == $this->nmgp_opcao)
          {
              $this->nmgp_opcao = 'novo';
          }
          else
          {
              $this->nm_formatar_campos();
              $this->chave = "";  
              $this->nmgp_dados_form["chave"] = $this->chave;
              $this->titulo_manifestacao_1000 = "";  
              $this->nmgp_dados_form["titulo_manifestacao_1000"] = $this->titulo_manifestacao_1000;
              $this->desc_manifestacao_1000 = "";  
              $this->nmgp_dados_form["desc_manifestacao_1000"] = $this->desc_manifestacao_1000;
              $this->id_categoria_1100 = "";  
              $this->nmgp_dados_form["id_categoria_1100"] = $this->id_categoria_1100;
              $this->desc_area_setor_1000 = "";  
              $this->nmgp_dados_form["desc_area_setor_1000"] = $this->desc_area_setor_1000;
              $this->dt_ocorrido_1000 = "";  
              $this->dt_ocorrido_1000_hora = "" ;  
              $this->nmgp_dados_form["dt_ocorrido_1000"] = $this->dt_ocorrido_1000;
              $this->ouvd_anonima_1000 = "";  
              $this->nmgp_dados_form["ouvd_anonima_1000"] = $this->ouvd_anonima_1000;
              $this->nome_inf_ouvd_1000 = "";  
              $this->nmgp_dados_form["nome_inf_ouvd_1000"] = $this->nome_inf_ouvd_1000;
              $this->cpf_cnpj_ouvd_1000 = "";  
              $this->nmgp_dados_form["cpf_cnpj_ouvd_1000"] = $this->cpf_cnpj_ouvd_1000;
              $this->tel_inf_ouvd_1000 = "";  
              $this->nmgp_dados_form["tel_inf_ouvd_1000"] = $this->tel_inf_ouvd_1000;
              $this->email_inf_ouvd_1000 = "";  
              $this->nmgp_dados_form["email_inf_ouvd_1000"] = $this->email_inf_ouvd_1000;
              $this->dt_ini_inv_ouvd_1000 = "";  
              $this->dt_ini_inv_ouvd_1000_hora = "" ;  
              $this->nmgp_dados_form["dt_ini_inv_ouvd_1000"] = $this->dt_ini_inv_ouvd_1000;
              $this->andamento_inv_ouvd_1000 = "";  
              $this->nmgp_dados_form["andamento_inv_ouvd_1000"] = $this->andamento_inv_ouvd_1000;
              $this->conclusao_inv_ouvd_1000 = "";  
              $this->nmgp_dados_form["conclusao_inv_ouvd_1000"] = $this->conclusao_inv_ouvd_1000;
              $this->nivel_atend_atual_1000 = "";  
              $this->nmgp_dados_form["nivel_atend_atual_1000"] = $this->nivel_atend_atual_1000;
              $this->id_status_ouvd_1000 = "";  
              $this->nmgp_dados_form["id_status_ouvd_1000"] = $this->id_status_ouvd_1000;
              $this->id_controlador_1000 = "";  
              $this->nmgp_dados_form["id_controlador_1000"] = $this->id_controlador_1000;
              $this->data_hora_cadastro_1000 = "";  
              $this->data_hora_cadastro_1000_hora = "" ;  
              $this->nmgp_dados_form["data_hora_cadastro_1000"] = $this->data_hora_cadastro_1000;
              $this->token_ouvd_1000 = "";  
              $this->nmgp_dados_form["token_ouvd_1000"] = $this->token_ouvd_1000;
              $this->anexo_ouvd_img1_1000 = "";  
              $this->anexo_ouvd_img1_1000_ul_name = "" ;  
              $this->anexo_ouvd_img1_1000_ul_type = "" ;  
              $this->nmgp_dados_form["anexo_ouvd_img1_1000"] = $this->anexo_ouvd_img1_1000;
              $this->anexo_ouvd_img2_1000 = "";  
              $this->anexo_ouvd_img2_1000_ul_name = "" ;  
              $this->anexo_ouvd_img2_1000_ul_type = "" ;  
              $this->nmgp_dados_form["anexo_ouvd_img2_1000"] = $this->anexo_ouvd_img2_1000;
              $this->anexo_ouvd_doc1_1000 = "";  
              $this->anexo_ouvd_doc1_1000_ul_name = "" ;  
              $this->anexo_ouvd_doc1_1000_ul_type = "" ;  
              $this->nmgp_dados_form["anexo_ouvd_doc1_1000"] = $this->anexo_ouvd_doc1_1000;
              $this->anexo_ouvd_doc2_1000 = "";  
              $this->anexo_ouvd_doc2_1000_ul_name = "" ;  
              $this->anexo_ouvd_doc2_1000_ul_type = "" ;  
              $this->nmgp_dados_form["anexo_ouvd_doc2_1000"] = $this->anexo_ouvd_doc2_1000;
              $this->nmgp_dados_form["instr_senha"] = $this->instr_senha;
              $this->codigo = "";  
              $this->nmgp_dados_form["codigo"] = $this->codigo;
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dados_form'] = $this->nmgp_dados_form;
              $this->formatado = false;
          }
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
      }  
//
//
//-- 
      if ($this->nmgp_opcao != "novo") 
      {
      }
      if (!isset($this->nmgp_refresh_fields)) 
      { 
          $this->nm_proc_onload();
      }
  }
        function initializeRecordState() {
                $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'] = array();
        }

        function storeRecordState($sc_seq_vert = 0) {
                if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'])) {
                        $this->initializeRecordState();
                }
                if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert])) {
                        $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert] = array();
                }

                $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert]['buttons'] = array(
                        'delete' => $this->nmgp_botoes['delete'],
                        'update' => $this->nmgp_botoes['update']
                );
        }

        function loadRecordState($sc_seq_vert = 0) {
                if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state']) || !isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert])) {
                        return;
                }

                if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert]['buttons']['delete'])) {
                        $this->nmgp_botoes['delete'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert]['buttons']['delete'];
                }
                if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert]['buttons']['update'])) {
                        $this->nmgp_botoes['update'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['record_state'][$sc_seq_vert]['buttons']['update'];
                }
        }

// 
 function gera_icone($doc) 
 {
    $cam_icone = "";
    $path =  $this->Ini->root . $this->Ini->path_icones . "/";
    if (is_dir($path))
    {
        $nm_icones = nm_list_icon($path); 
        $nm_tipo = strtolower(substr($doc, strrpos($doc, ".") + 1));
        $nm_tipo = str_replace(array('docx', 'xlsx'), array('doc', 'xls'), $nm_tipo);
        if (isset($nm_icones[$nm_tipo]) && !empty($nm_icones[$nm_tipo]))
        {
            $cam_icone = $this->Ini->path_icones . "/" . $nm_icones[$nm_tipo];
        }
        else
        {
            $cam_icone = $this->Ini->path_icones . "/" . $nm_icones["default"];
        }
    }
    return $cam_icone;
 } 
//
function geraSenha($tamanho = 8, $maiusculas = true, $numeros = true, $simbolos = false)
	{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
	$lmin = 'abcdefghijklmnopqrstuvwxyz';
	$lmai = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

	$num = '1234567890';
	$simb = '!@#$%*';
	 
	$retorno = '';
	$caracteres = '';
	 
	$caracteres .= $lmin;
	if ($maiusculas) $caracteres .= $lmai;
	if ($numeros) $caracteres .= $num;
	if ($simbolos) $caracteres .= $simb;
	 
	$len = strlen($caracteres);
	 
	for ($n = 1; $n <= $tamanho; $n++) {
	$rand = mt_rand(1, $len);
	$retorno .= $caracteres[$rand-1];
	}
	return $retorno;
	
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function Gerar_Senha()
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  



$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function assign_null_if_empty($fields)
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
foreach($fields as $field) {
	if(empty($this->$field)) {
		$this->$field = "null";
	}
	
}


$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function check_is_empty($field)
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
$field = trim($field);

return !empty($field) ? $field : "Não informado";


$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function clear_white_spaces($fields)
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
foreach($fields as $field) {
	$this->$field = trim($this->$field);
}


$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function getCNPJController()
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (!isset($this->sc_temp_cnpj_controlador)) {$this->sc_temp_cnpj_controlador = (isset($_SESSION['cnpj_controlador'])) ? $_SESSION['cnpj_controlador'] : "";}
if (!isset($this->sc_temp_usr_controlador)) {$this->sc_temp_usr_controlador = (isset($_SESSION['usr_controlador'])) ? $_SESSION['usr_controlador'] : "";}
  
$check_sql = 'SELECT cnpj_1000 from LGPD_1000_controlador
where id_controlador_1000 = '. $this->sc_temp_usr_controlador;
		
 
      $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])) {
	$this->sc_temp_cnpj_controlador = $this->rs[0][0] ;
}
if (isset($this->sc_temp_usr_controlador)) { $_SESSION['usr_controlador'] = $this->sc_temp_usr_controlador;}
if (isset($this->sc_temp_cnpj_controlador)) { $_SESSION['cnpj_controlador'] = $this->sc_temp_cnpj_controlador;}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function get_image_link($img_name)
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
$serverPath = $_SERVER["REQUEST_URI"];
$separateEnvironmentRegex = "/\/[a-zA-Z_]+/";
preg_match_all($separateEnvironmentRegex, $serverPath, $matches);

$environment = $matches[0][0];

$clearBarsRegex = "/\//";
$environment = preg_replace($clearBarsRegex, "", $environment);


$environmentArr = [
	"scriptcase" => "http://150.230.94.87/file/doc/env_mail/$img_name",
	"producao" => "https://www.omnisblueapps.com/file/doc/env_mail/$img_name"
];

$imageLink = array_key_exists($environment, $environmentArr) ? $environmentArr[$environment] : $environmentArr["producao"];


return $imageLink;



$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function ouvd_anonima_1000_onClick()
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
$original_ouvd_anonima_1000 = $this->ouvd_anonima_1000;
$original_nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000;
$original_email_inf_ouvd_1000 = $this->email_inf_ouvd_1000;
$original_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
$original_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;

if(!$this->ouvd_anonima_1000 ) {
	$this->nmgp_cmp_hidden["nome_inf_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['nome_inf_ouvd_1000'] = 'on';
	$this->nmgp_cmp_hidden["email_inf_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['email_inf_ouvd_1000'] = 'on';
	$this->nmgp_cmp_hidden["tel_inf_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['tel_inf_ouvd_1000'] = 'on';
	$this->nmgp_cmp_hidden["cpf_cnpj_ouvd_1000"] = 'on'; $this->NM_ajax_info['fieldDisplay']['cpf_cnpj_ouvd_1000'] = 'on';
} else {
	$this->nmgp_cmp_hidden["nome_inf_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['nome_inf_ouvd_1000'] = 'off';
	$this->nmgp_cmp_hidden["email_inf_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['email_inf_ouvd_1000'] = 'off';
	$this->nmgp_cmp_hidden["tel_inf_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['tel_inf_ouvd_1000'] = 'off';
	$this->nmgp_cmp_hidden["cpf_cnpj_ouvd_1000"] = 'off'; $this->NM_ajax_info['fieldDisplay']['cpf_cnpj_ouvd_1000'] = 'off';
}


$modificado_ouvd_anonima_1000 = $this->ouvd_anonima_1000;
$modificado_nome_inf_ouvd_1000 = $this->nome_inf_ouvd_1000;
$modificado_email_inf_ouvd_1000 = $this->email_inf_ouvd_1000;
$modificado_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
$modificado_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
$this->nm_formatar_campos('ouvd_anonima_1000', 'nome_inf_ouvd_1000', 'email_inf_ouvd_1000', 'tel_inf_ouvd_1000', 'cpf_cnpj_ouvd_1000');
if ($original_ouvd_anonima_1000 !== $modificado_ouvd_anonima_1000 || isset($this->nmgp_cmp_readonly['ouvd_anonima_1000']) || (isset($bFlagRead_ouvd_anonima_1000) && $bFlagRead_ouvd_anonima_1000))
{
    $this->ajax_return_values_ouvd_anonima_1000(true);
}
if ($original_nome_inf_ouvd_1000 !== $modificado_nome_inf_ouvd_1000 || isset($this->nmgp_cmp_readonly['nome_inf_ouvd_1000']) || (isset($bFlagRead_nome_inf_ouvd_1000) && $bFlagRead_nome_inf_ouvd_1000))
{
    $this->ajax_return_values_nome_inf_ouvd_1000(true);
}
if ($original_email_inf_ouvd_1000 !== $modificado_email_inf_ouvd_1000 || isset($this->nmgp_cmp_readonly['email_inf_ouvd_1000']) || (isset($bFlagRead_email_inf_ouvd_1000) && $bFlagRead_email_inf_ouvd_1000))
{
    $this->ajax_return_values_email_inf_ouvd_1000(true);
}
if ($original_tel_inf_ouvd_1000 !== $modificado_tel_inf_ouvd_1000 || isset($this->nmgp_cmp_readonly['tel_inf_ouvd_1000']) || (isset($bFlagRead_tel_inf_ouvd_1000) && $bFlagRead_tel_inf_ouvd_1000))
{
    $this->ajax_return_values_tel_inf_ouvd_1000(true);
}
if ($original_cpf_cnpj_ouvd_1000 !== $modificado_cpf_cnpj_ouvd_1000 || isset($this->nmgp_cmp_readonly['cpf_cnpj_ouvd_1000']) || (isset($bFlagRead_cpf_cnpj_ouvd_1000) && $bFlagRead_cpf_cnpj_ouvd_1000))
{
    $this->ajax_return_values_cpf_cnpj_ouvd_1000(true);
}
$this->NM_ajax_info['event_field'] = 'ouvd';
cadastro_DEN_1000_registro_mob_pack_ajax_response();
exit;
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function send_email($nome, $email, $token, $manifestacao)
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (!isset($this->sc_temp_usr_controlador)) {$this->sc_temp_usr_controlador = (isset($_SESSION['usr_controlador'])) ? $_SESSION['usr_controlador'] : "";}
  
$serverPath = $_SERVER["REQUEST_URI"];
$separateEnvironmentRegex = "/\/[a-zA-Z_]+/";
preg_match_all($separateEnvironmentRegex, $serverPath, $matches);

$environment = $matches[0][0];

$clearBarsRegex = "/\//";
$environment = preg_replace($clearBarsRegex, "", $environment);

$environmentArr = [
  "scriptcase" => "http://150.230.94.87:8092/scriptcase/app/OMN_OVD/load_sec/?cntrl=" . $this->sc_temp_usr_controlador,
  "producao" => "https://www.omnisblueapps.com/$environment/OMN_OVD/load_sec/?cntrl=" . $this->sc_temp_usr_controlador
];

$environmentLink = array_key_exists($environment, $environmentArr) ? $environmentArr[$environment] : $environmentArr["producao"];


$getCategoria = "SELECT titulo_categoria_1100 FROM OUVD_1100_categoria"
	." WHERE id_controlador_1000 = ". $this->sc_temp_usr_controlador ." AND id_categoria_ouvd_1100 = " . $this->id_categoria_1100 ;
 
      $nm_select = $getCategoria; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->tp_categoria = 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->tp_categoria[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->tp_categoria = false;
          $this->tp_categoria_erro = $this->Db->ErrorMsg();
      } 



$manifestacao = $this->check_is_empty($manifestacao);
$areaSectorValue = $this->check_is_empty($this->desc_area_setor_1000 );
$categoria = $this->check_is_empty($this->tp_categoria[0][0]);
$nome = !empty($nome) ? $nome : "Anônimo";
$whenOcurred = !(empty($this->dt_ocorrido_1000 ) || $this->dt_ocorrido_1000  == "null")?
	$this->nm_conv_data_db($this->dt_ocorrido_1000 , "db_format", "dd/mm/aaaa") : "Não informado";

$SMTPData = "SELECT 
	mail_smtp_server_0002,
    mail_smtp_user_0002,
    mail_smtp_pass_0002,
    mail_smtp_from_0002,
    url_portal_acesso_0002,
	porta_smtp
FROM LGPD_0002_conf_smpt";
 
      $nm_select = $SMTPData; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->smtp = 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->smtp[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->smtp = false;
          $this->smtp_erro = $this->Db->ErrorMsg();
      } 


$getInformationsCont = "SELECT 
  nome_1000,
  utlz_img_env_mail_1000, 
  img_env_mail_1000
FROM LGPD_1000_controlador 
WHERE id_controlador_1000 = " . $this->sc_temp_usr_controlador;
 
      $nm_select = $getInformationsCont; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->company_data = 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->company_data[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->company_data = false;
          $this->company_data_erro = $this->Db->ErrorMsg();
      } 


$useImage = $this->company_data[0][1];
$imageName = $this->company_data[0][2];

$linkImg = $this->get_image_link($imageName);

$htmlImage = ($useImage && !empty($imageName)) ? '
<div style="text-align: center; margin-top: 20px;">
  <img 
    src="'.$linkImg.'" 
    alt="Logo"
    style="
      display: block;
      margin: 0 auto 15px auto;
      width: 200px;
      height: auto;
      max-width: 100%;
    "
  >
</div>' : '';



$mail_smtp_server    = trim($this->smtp[0][0]);   
$mail_port           = trim($this->smtp[0][5]);   
$mail_smtp_user      = trim($this->smtp[0][1]);   
$mail_smtp_pass      = trim($this->smtp[0][2]);   
$mail_from           = trim($this->smtp[0][3]);   
$mail_to             = trim($email);  
$mail_subject        = 'Confirmação de registro na ouvidoria'; 

$mail_message        = '<table width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">

      <!-- Container -->
      <table width="100%" cellpadding="0" cellspacing="0" style="max-width:720px;background:#ffffff;">
        <tr>
          <td style="padding:20px;font-family:Verdana, Arial, sans-serif;color:#222;">

            <!-- Header -->
            <h2 style="color:#222;font-size:15px;font-weight:normal;margin:0 0 10px 0;">
              Prezado(a):
              <strong>' . $nome . '</strong>
            </h2>

            <!-- Intro -->
            <p style="font-size:14px;margin:0 0 16px 0;">
              Por meio deste comunicado, confirmamos o registro de sua manifestação no portal de ouvidoria da
              <strong style="color:#444;">' . $this->company_data[0][0] . '</strong>.
            </p>

            <!-- Categoria -->
            <p style="font-size:14px;margin:0;">
              <strong>Categoria:</strong> ' . $categoria . '
            </p>
			
			<!-- Título -->
			<p style="font-size:14px;margin-top:12px;">
              <strong>Assunto:</strong> ' . $this->titulo_manifestacao_1000  . '
            </p>

            <!-- Descrição -->
            <p style="font-size:14px;margin-top:12px;text-align:justify;">
              <strong>Descrição:</strong> <pre style="font-family:Verdana, Arial, sans-serif;font-size:14px;">' . $manifestacao . '</pre>
            </p>
			
			<!-- Area setor -->
            <p style="font-size:14px;margin-top:12px;text-align:justify;">
              <strong>Area / Setor:</strong> <pre style="font-family:Verdana, Arial, sans-serif;font-size:14px;">'. $areaSectorValue .'</pre>
            </p>
			
			<!-- Area setor -->
            <p style="font-size:14px;margin:12px 0 24px 0;text-align:justify;">
              <strong>Quando ocorreu?</strong> ' . $whenOcurred . '
            </p>

            <!-- Instruções -->
            <p style="margin:24px 0 8px 0;font-size:14px;color:#444;">
              Para acompanhar o andamento, siga os passos abaixo:
            </p>

            <ol style="font-size:14px;line-height:1.7;margin:0 0 16px 18px;padding:0;">
              <li>
                Acesse o link:
                <a href="' . $environmentLink . '" target="_blank" style="color:#0c60ff;">
                  Portal de Ouvidoria
                </a>
              </li>
              <li>Selecione a opção <q>Acompanhar Ouvidoria</q></li>
              <li>Insira a chave de acesso: <strong>' . $token . '</strong></li>
              <li>Selecione <q>OK</q></li>
            </ol>

            <p style="font-size:14px;margin:0 0 16px 0;color:#444;">
              Seguindo os passos acima, você poderá acompanhar as atualizações. Enviaremos notificações conforme novas atualizações surgirem.
            </p>

            <!-- Footer -->
			
			'.$htmlImage.'
			
            <p style="font-size:13px;color:#777;margin-top:30px;">
              Este e-mail é enviado automaticamente pelo sistema do portal de ouvidoria. Por favor, não responda.
            </p>

          </td>
        </tr>
      </table>

    </td>
  </tr>
</table>';                                     
$mail_format         = 'H';                                    
$mail_copies         = '';                                     
$mail_tp_copies      = '';                                     
$mail_tp_connection  = 'T';                                    

$mail_Anexo = '';
$mail_ssl = '';
$replay_to = '';



try {

	    include_once($this->Ini->path_third . "/swift/swift_required.php");
    $sc_mail_port     = "$mail_port";
    $sc_mail_tp_port  = "$mail_tp_connection";
    $sc_mail_tp_mens  = "$mail_format";
    $sc_mail_tp_copy  = "$mail_tp_copies";
    $this->sc_mail_count = 0;
    $this->sc_mail_erro  = "";
    $this->sc_mail_ok    = true;
    if ($sc_mail_tp_port == "S" || $sc_mail_tp_port == "Y")
    {
        $sc_mail_port = (!empty($sc_mail_port)) ? $sc_mail_port : 465;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port, 'ssl');
    }
    elseif ($sc_mail_tp_port == "T")
    {
        $sc_mail_port = !empty($sc_mail_port) ? $sc_mail_port : 587;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port, 'tls');
    }
    else
    {
        $sc_mail_port = (!empty($sc_mail_port)) ? $sc_mail_port : 25;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port);
    }
    $Con_Mail->setUsername($mail_smtp_user);
    $Con_Mail->setpassword($mail_smtp_pass);
    $Send_Mail = Swift_Mailer::newInstance($Con_Mail);
    if ($sc_mail_tp_mens == "H")
    {
        $Mens_Mail = Swift_Message::newInstance($mail_subject);
        $Mens_Mail->setBody(SC_Mail_Image($mail_message, $Mens_Mail))->setContentType("text/html");
    }
    else
    {
        $Mens_Mail = Swift_Message::newInstance($mail_subject)->setBody($mail_message);
    }
    if (!empty($_SESSION['scriptcase']['charset']))
    {
        $Mens_Mail->setCharset($_SESSION['scriptcase']['charset']);
    }
    $Temp_mail = $mail_to;
    if (!is_array($Temp_mail))
    {
        $Temp_mail = explode(";", $mail_to);
    }
    foreach ($Temp_mail as $NM_dest)
    {
        if (!empty($NM_dest))
        {
            $Arr_addr = SC_Mail_Address($NM_dest);
            $Mens_Mail->addTo($Arr_addr[0], $Arr_addr[1]);
        }
    }
    $Temp_mail = $mail_copies;
    if (!is_array($Temp_mail))
    {
        $Temp_mail = explode(";", $mail_copies);
    }
    foreach ($Temp_mail as $NM_dest)
    {
        if (!empty($NM_dest))
        {
            $Arr_addr = SC_Mail_Address($NM_dest);
            if (strtoupper(substr($sc_mail_tp_copy, 0, 2)) == "CC")
            {
                $Mens_Mail->addCc($Arr_addr[0], $Arr_addr[1]);
            }
            else
            {
                $Mens_Mail->addBcc($Arr_addr[0], $Arr_addr[1]);
            }
        }
    }
    $Arr_addr = SC_Mail_Address($mail_from);
    $Err_mail = array();
    $this->sc_mail_count = $Send_Mail->send($Mens_Mail->setFrom($Arr_addr[0], $Arr_addr[1]), $Err_mail);
    if (!empty($Err_mail))
    {
        $this->sc_mail_erro = $Err_mail;
        $this->sc_mail_ok   = false;
    }
; 
	
	
	
} catch (Exception $e) {
	
 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 .= "Não foi possivel enviar o e-mail";
 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_cadastro_DEN_1000_registro_mob';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_cadastro_DEN_1000_registro_mob';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = "Não foi possivel enviar o e-mail";
 }
;
}
if (isset($this->sc_temp_usr_controlador)) { $_SESSION['usr_controlador'] = $this->sc_temp_usr_controlador;}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function send_email_nivel($nome, $email, $token)
{
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
if (!isset($this->sc_temp_usr_controlador)) {$this->sc_temp_usr_controlador = (isset($_SESSION['usr_controlador'])) ? $_SESSION['usr_controlador'] : "";}
  
$serverPath = $_SERVER["REQUEST_URI"];
$separateEnvironmentRegex = "/\/[a-zA-Z_]+/";
preg_match_all($separateEnvironmentRegex, $serverPath, $matches);

$environment = $matches[0][0];

$clearBarsRegex = "/\//";
$environment = preg_replace($clearBarsRegex, "", $environment);

$environmentArr = [
	"scriptcase" => "http://150.230.94.87:8092/scriptcase/app/OMN_ACS/control_email",
	"app" => "https://www.omnisblueapps.com/$environment/OMN_ACS/control_email",
	"producao" => "https://www.omnisblueapps.com/$environment/PortalAcesso/login_sec"
];

$environmentLink = array_key_exists($environment, $environmentArr) ? $environmentArr[$environment] : $environmentArr["producao"];


$getCategoria = "SELECT titulo_categoria_1100 FROM OUVD_1100_categoria"
	." WHERE id_controlador_1000 = ". $this->sc_temp_usr_controlador ." AND id_categoria_ouvd_1100 = " . $this->id_categoria_1100 ;
 
      $nm_select = $getCategoria; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->tp_categoria = 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->tp_categoria[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->tp_categoria = false;
          $this->tp_categoria_erro = $this->Db->ErrorMsg();
      } 



$manifestacao = $this->check_is_empty($this->desc_manifestacao_1000 );
$areaSectorValue = $this->check_is_empty($this->desc_area_setor_1000 );
$categoria = $this->check_is_empty($this->tp_categoria[0][0]);
$nome = $this->check_is_empty($nome);
$whenOcurred = !(empty($this->dt_ocorrido_1000 ) || $this->dt_ocorrido_1000  == "null")?
	$this->nm_conv_data_db($this->dt_ocorrido_1000 , "db_format", "dd/mm/aaaa") : "Não informado";

$SMTPData = "SELECT 
	mail_smtp_server_0002,
    mail_smtp_user_0002,
    mail_smtp_pass_0002,
    mail_smtp_from_0002,
    url_portal_acesso_0002,
	porta_smtp
FROM LGPD_0002_conf_smpt";
 
      $nm_select = $SMTPData; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->smtp = 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->smtp[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->smtp = false;
          $this->smtp_erro = $this->Db->ErrorMsg();
      } 


$getInformationsCont = "SELECT 
  nome_1000,
  utlz_img_env_mail_1000, 
  img_env_mail_1000
FROM LGPD_1000_controlador 
WHERE id_controlador_1000 = " . $this->sc_temp_usr_controlador;
 
      $nm_select = $getInformationsCont; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->company_data = 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->company_data[$SCy] [$SCx] = $SCrx->fields[$SCx];
                 }
                 $SCy++; 
                 $SCrx->MoveNext();
          } 
          $SCrx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->company_data = false;
          $this->company_data_erro = $this->Db->ErrorMsg();
      } 


$useImage = $this->company_data[0][1];
$imageName = $this->company_data[0][2];

$linkImg = $this->get_image_link($imageName);

$htmlImage = ($useImage && !empty($imageName)) ? '
<div style="text-align: center; margin-top: 20px;">
  <img 
    src="'.$linkImg.'" 
    alt="Logo"
    style="
      display: block;
      margin: 0 auto 15px auto;
      width: 200px;
      height: auto;
      max-width: 100%;
    "
  >
</div>' : '';



$mail_smtp_server    = trim($this->smtp[0][0]);   
$mail_port           = trim($this->smtp[0][5]);   
$mail_smtp_user      = trim($this->smtp[0][1]);   
$mail_smtp_pass      = trim($this->smtp[0][2]);   
$mail_from           = trim($this->smtp[0][3]);   
$mail_to             = trim($email);  
$mail_subject        = 'Notificação de cadastro na ouvidoria'; 

$mail_message        = '<table width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center">

      <!-- Container -->
      <table width="100%" cellpadding="0" cellspacing="0" style="max-width:720px;background:#ffffff;">
        <tr>
          <td style="padding:20px;font-family:Verdana, Arial, sans-serif;color:#222;">

            <!-- Header -->
            <h2 style="color:#222;font-size:15px;font-weight:normal;margin:0 0 10px 0;">
              Prezado(a):
              <strong>' . $nome . '</strong>
            </h2>

            <!-- Intro -->
            <p style="font-size:14px;margin:0 0 16px 0;">
              Por meio deste comunicado, informamos que você foi selecionado como um dos responsáveis pelo tratamento de uma nova manifestação registrada no portal de ouvidoria da
              <strong style="color:#444;">' . $this->company_data[0][0] . '</strong>.
            </p>

            <!-- Categoria -->
            <p style="font-size:14px;margin:0;">
              <strong>Categoria:</strong> ' . $categoria . '
            </p>
			
			<!-- Título -->
			<p style="font-size:14px;margin-top:12px;">
              <strong>Assunto:</strong> ' . $this->titulo_manifestacao_1000  . '
            </p>

            <!-- Descrição -->
            <p style="font-size:14px;margin-top:12px;text-align:justify;">
              <strong>Descrição:</strong> <pre style="font-family:Verdana, Arial, sans-serif;font-size:14px;">' . $manifestacao . '</pre>
            </p>
			
			<!-- Area setor -->
            <p style="font-size:14px;margin-top:12px;text-align:justify;">
              <strong>Area / Setor:</strong> <pre style="font-family:Verdana, Arial, sans-serif;font-size:14px;">' .$areaSectorValue. '</pre>
            </p>
			
			<!-- Area setor -->
            <p style="font-size:14px;margin:12px 0 24px 0;text-align:justify;">
              <strong>Quando ocorreu?</strong> ' . $whenOcurred . '
            </p>
  
            <!-- Instruções -->
            <p style="margin:24px 0 8px 0;font-size:14px;color:#444;">
              Para realizar o tratamento da manifestação, siga os passos abaixo:
            </p>

            <ol style="font-size:14px;line-height:1.7;margin:0 0 16px 18px;padding:0;">
              <li>
                Acesse o link:
                <a href="' . $environmentLink . '" target="_blank" style="color:#0c60ff;">
                  Portal LGPD
                </a>
              </li>
              <li>Selecione a opção <q>PAC</q></li>
              <li>No menu, navegue até <q>Portal de Ouvidoria > Manifestações</q></li>
              <li>Localize a manisfestação utilizando a chave de acesso: <strong style="color: #444444;">'.$token.'</strong></li>
            </ol>

            <p style="font-size:14px;margin:0 0 16px 0;color:#444;">
              Seguindo as orientações acima, você poderá visualizar todas as informações disponíveis para o devido tratamento.
            </p>

            <!-- Footer -->
			
			'.$htmlImage.'
			
            <p style="font-size:13px;color:#777;margin-top:30px;">
              Este e-mail é enviado automaticamente pelo sistema do portal de ouvidoria. Por favor, não responda.
            </p>

          </td>
        </tr>
      </table>

    </td>
  </tr>
</table>';                                     
$mail_format         = 'H';                                    
$mail_copies         = '';                                     
$mail_tp_copies      = '';                                     
$mail_tp_connection  = 'T';                                    

$mail_Anexo = '';
$mail_ssl = '';
$replay_to = '';



try {

	    include_once($this->Ini->path_third . "/swift/swift_required.php");
    $sc_mail_port     = "$mail_port";
    $sc_mail_tp_port  = "$mail_tp_connection";
    $sc_mail_tp_mens  = "$mail_format";
    $sc_mail_tp_copy  = "$mail_tp_copies";
    $this->sc_mail_count = 0;
    $this->sc_mail_erro  = "";
    $this->sc_mail_ok    = true;
    if ($sc_mail_tp_port == "S" || $sc_mail_tp_port == "Y")
    {
        $sc_mail_port = (!empty($sc_mail_port)) ? $sc_mail_port : 465;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port, 'ssl');
    }
    elseif ($sc_mail_tp_port == "T")
    {
        $sc_mail_port = !empty($sc_mail_port) ? $sc_mail_port : 587;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port, 'tls');
    }
    else
    {
        $sc_mail_port = (!empty($sc_mail_port)) ? $sc_mail_port : 25;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port);
    }
    $Con_Mail->setUsername($mail_smtp_user);
    $Con_Mail->setpassword($mail_smtp_pass);
    $Send_Mail = Swift_Mailer::newInstance($Con_Mail);
    if ($sc_mail_tp_mens == "H")
    {
        $Mens_Mail = Swift_Message::newInstance($mail_subject);
        $Mens_Mail->setBody(SC_Mail_Image($mail_message, $Mens_Mail))->setContentType("text/html");
    }
    else
    {
        $Mens_Mail = Swift_Message::newInstance($mail_subject)->setBody($mail_message);
    }
    if (!empty($_SESSION['scriptcase']['charset']))
    {
        $Mens_Mail->setCharset($_SESSION['scriptcase']['charset']);
    }
    $Temp_mail = $mail_to;
    if (!is_array($Temp_mail))
    {
        $Temp_mail = explode(";", $mail_to);
    }
    foreach ($Temp_mail as $NM_dest)
    {
        if (!empty($NM_dest))
        {
            $Arr_addr = SC_Mail_Address($NM_dest);
            $Mens_Mail->addTo($Arr_addr[0], $Arr_addr[1]);
        }
    }
    $Temp_mail = $mail_copies;
    if (!is_array($Temp_mail))
    {
        $Temp_mail = explode(";", $mail_copies);
    }
    foreach ($Temp_mail as $NM_dest)
    {
        if (!empty($NM_dest))
        {
            $Arr_addr = SC_Mail_Address($NM_dest);
            if (strtoupper(substr($sc_mail_tp_copy, 0, 2)) == "CC")
            {
                $Mens_Mail->addCc($Arr_addr[0], $Arr_addr[1]);
            }
            else
            {
                $Mens_Mail->addBcc($Arr_addr[0], $Arr_addr[1]);
            }
        }
    }
    $Arr_addr = SC_Mail_Address($mail_from);
    $Err_mail = array();
    $this->sc_mail_count = $Send_Mail->send($Mens_Mail->setFrom($Arr_addr[0], $Arr_addr[1]), $Err_mail);
    if (!empty($Err_mail))
    {
        $this->sc_mail_erro = $Err_mail;
        $this->sc_mail_ok   = false;
    }
; 
	
	
	
} catch (Exception $e) {
	
 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 .= "Não foi possivel enviar o e-mail";
 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_cadastro_DEN_1000_registro_mob';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_cadastro_DEN_1000_registro_mob';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = "Não foi possivel enviar o e-mail";
 }
;
}
if (isset($this->sc_temp_usr_controlador)) { $_SESSION['usr_controlador'] = $this->sc_temp_usr_controlador;}
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function adjustLightTheme() {
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
		echo <<<CSS
		<style>
		ol.sc-steps.is-boxed {
			width: 100%;
		}

		#TB_window {
			border-radius: 20px;
		}

		.select2-container--default .select2-results > .select2-results__options {
			font-size: 13px;
		}

		.scFormTable {
			width: 97%;
		}

		.scFormToolbarNav, .scFormToolbarNavOpen {
			margin-left: 5px;
		}

		.scGridToolbarNav:hover, .scFormToolbarNav:hover {
			background-color: #072ac8 !important;
			color: #ffffff;
		}

		table.scGridTabela {
			border-collapse: separate !important;
			border-spacing: 0px !important;
			padding: 0px;
		}

		.scGridLabelFont {
			border-radius: 12px !important;

		}

		.scGridTabelaTd {
			background-color: #fff;
			padding: 0px;
		}

		#sc_grid_body {
			padding: 0px;
			padding-top: 20px;
		}

		.scFormLabelOddMult {
			border-radius: 12px;
		}

		.header-format {
		padding: 0px;
		border-spacing: 0px;
		border-width: 0px;
		font-family: 'Poppins', sans-serif;
		width: 100%;
		border: none;
		}

		.header-format > tr {
		  text-align: center;
		  vertical-align: middle;
		}

		.scTabLine {
		border-radius: 12px;
		}

		.scTabInactive {
		transition: background 200ms ease-in;
		}

		.scTabInactive:hover {
		background-color: #515E70;
		}



		#sc_id_groupby_placeholder_top td.scAppDivContent.css_scAppDivContentText {
		border-radius: 0 0 12px 12px !important;
		border-bottom: 1px solid #ccc;
		}


		#sc_id_groupby_placeholder_top td.scAppDivToolbar {
		border: 0px;
		padding-left: 8px;
		}

		#sc_id_groupby_placeholder_top tr#sc_id_free_groupby > td >  table {
		margin: 0;
		}

		#sc_id_groupby_placeholder_top #sc_id_free_groupby > td {
		padding-top: 0;
		}

		#sc_id_class_id, #sc_id_fldord_selected select {
		height: auto;
		}

		.css_toolbar_obj {
		margin-bottom: 5px;
		}

		.css_toolbar_obj:focus-within {
		border-color: #0b64f4;
		box-shadow: none;
		outline-color:  #0b64f4;
		}
		
		.scFormFieldErrorMessage {
			display: inline-block;
			color: #D72A2A;
			font-size: 14px;
			margin-top: 8px;
		}
		</style>
		CSS;

$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function adjustDarkTheme() {
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  

$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
function applyThemeAdjustments($mode) {
$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'on';
  
	if($mode == "light") {
		$this->adjustLightTheme();
	} else {
		$this->adjustDarkTheme();
	}

$_SESSION['scriptcase']['cadastro_DEN_1000_registro_mob']['contr_erro'] = 'off';
}
//
 function nm_gera_html()
 {
    global
           $nm_url_saida, $nmgp_url_saida, $nm_saida_global, $nm_apl_dependente, $glo_subst, $sc_check_excl, $sc_check_incl, $nmgp_num_form, $NM_run_iframe;
     if ($this->Embutida_proc)
     {
         return;
     }
     if ($this->nmgp_form_show == 'off')
     {
         exit;
     }
      if (isset($NM_run_iframe) && $NM_run_iframe == 1)
      {
          $this->nmgp_botoes['exit'] = "off";
      }
     $HTTP_REFERER = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ""; 
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['botoes'] = $this->nmgp_botoes;
     if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")
     {
         $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opc_ant'] = $this->nmgp_opcao;
     }
     else
     {
         $this->nmgp_opcao = $this->nmgp_opc_ant;
     }
     if (!empty($this->Campos_Mens_erro)) 
     {
         $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro); 
         $this->Campos_Mens_erro = "";
     }
     if (($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "R") && $this->nm_flag_iframe && empty($this->nm_todas_criticas))
     {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe_ajax']))
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit'] = array("edit", "");
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit'] .= "&nmgp_opcao=edit";
          }
          if ($this->sc_evento == "insert" && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F")
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe_ajax']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit'] = array("edit", "fim");
              }
              else
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit'] .= "&rec=fim";
              }
          }
          $this->NM_close_db(); 
          $sJsParent = '';
          if ($this->NM_ajax_flag && isset($this->NM_ajax_info['param']['buffer_output']) && $this->NM_ajax_info['param']['buffer_output'])
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe_ajax']))
              {
                  $this->NM_ajax_info['ajaxJavascript'][] = array("parent.ajax_navigate", $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit']);
              }
              else
              {
                  $sJsParent .= 'parent';
                  $this->NM_ajax_info['redir']['metodo'] = 'location';
                  $this->NM_ajax_info['redir']['action'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit'];
                  $this->NM_ajax_info['redir']['target'] = $sJsParent;
              }
              cadastro_DEN_1000_registro_mob_pack_ajax_response();
              exit;
          }
?>
<!DOCTYPE html>

         <html><body>
         <script type="text/javascript">
<?php
    
    if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe_ajax']))
    {
        $opc = ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] == "F" && $this->sc_evento == "insert") ? "fim" : "";
        echo "parent.ajax_navigate('edit', '" .$opc . "');";
    }
    else
    {
        echo $sJsParent . "parent.location = '" . $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['retorno_edit'] . "';";
    }
?>
         </script>
         </body></html>
<?php
         exit;
     }
//-- 
   if ($this->nmgp_opcao == "novo")
   { 
       $out_anexo_ouvd_img1_1000 = "";  
   } 
   else 
   { 
       $out_anexo_ouvd_img1_1000 = $this->anexo_ouvd_img1_1000;  
   } 
   if ($this->anexo_ouvd_img1_1000 != "" && $this->anexo_ouvd_img1_1000 != "none")   
   { 
       $path_anexo_ouvd_img1_1000 = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/" . $this->anexo_ouvd_img1_1000;
       $md5_anexo_ouvd_img1_1000  = md5("/ouvidoria/" . $_SESSION['cnpj_controlador'] . $this->anexo_ouvd_img1_1000);
       nm_fix_SubDirUpload($this->anexo_ouvd_img1_1000,$this->Ini->root . $this->Ini->path_imagens,"/ouvidoria/" . $_SESSION['cnpj_controlador']);
        if (is_file($path_anexo_ouvd_img1_1000))  
       { 
           $NM_ler_img = true;
           $out_anexo_ouvd_img1_1000 = $this->Ini->path_imag_temp . "/sc_anexo_ouvd_img1_1000_" . $md5_anexo_ouvd_img1_1000 . ".gif" ;  
           if (is_file($this->Ini->root . $out_anexo_ouvd_img1_1000))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_anexo_ouvd_img1_1000) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_ler_img = false;
               } 
           } 
           if ($NM_ler_img) 
           { 
               $tmp_anexo_ouvd_img1_1000 = fopen($path_anexo_ouvd_img1_1000, "r") ; 
               $reg_anexo_ouvd_img1_1000 = fread($tmp_anexo_ouvd_img1_1000, filesize($path_anexo_ouvd_img1_1000)) ; 
               fclose($tmp_anexo_ouvd_img1_1000) ;  
               $arq_anexo_ouvd_img1_1000 = fopen($this->Ini->root . $out_anexo_ouvd_img1_1000, "w") ;  
               fwrite($arq_anexo_ouvd_img1_1000, $reg_anexo_ouvd_img1_1000) ;  
               fclose($arq_anexo_ouvd_img1_1000) ;  
           } 
       if ($this->Ini->Export_img_zip) {
           $this->Ini->Img_export_zip[] = $this->Ini->root . $out_anexo_ouvd_img1_1000;
           $out_anexo_ouvd_img1_1000 = str_replace($this->Ini->path_imag_temp . "/", "", $out_anexo_ouvd_img1_1000);
       } 
       } 
   } 
   if (isset($_POST['nmgp_opcao']) && 'excluir' == $_POST['nmgp_opcao'] && $this->sc_evento != "delete" && (!isset($this->sc_evento_old) || 'delete' != $this->sc_evento_old))
   {
       global $temp_out_anexo_ouvd_img1_1000;
       if (isset($temp_out_anexo_ouvd_img1_1000))
       {
           $out_anexo_ouvd_img1_1000 = $temp_out_anexo_ouvd_img1_1000;
       }
   }
   if ($this->nmgp_opcao == "novo")
   { 
       $out_anexo_ouvd_img2_1000 = "";  
   } 
   else 
   { 
       $out_anexo_ouvd_img2_1000 = $this->anexo_ouvd_img2_1000;  
   } 
   if ($this->anexo_ouvd_img2_1000 != "" && $this->anexo_ouvd_img2_1000 != "none")   
   { 
       $path_anexo_ouvd_img2_1000 = $this->Ini->root . $this->Ini->path_imagens . "/ouvidoria/" . $_SESSION['cnpj_controlador'] . "/" . $this->anexo_ouvd_img2_1000;
       $md5_anexo_ouvd_img2_1000  = md5("/ouvidoria/" . $_SESSION['cnpj_controlador'] . $this->anexo_ouvd_img2_1000);
       nm_fix_SubDirUpload($this->anexo_ouvd_img2_1000,$this->Ini->root . $this->Ini->path_imagens,"/ouvidoria/" . $_SESSION['cnpj_controlador']);
        if (is_file($path_anexo_ouvd_img2_1000))  
       { 
           $NM_ler_img = true;
           $out_anexo_ouvd_img2_1000 = $this->Ini->path_imag_temp . "/sc_anexo_ouvd_img2_1000_" . $md5_anexo_ouvd_img2_1000 . ".gif" ;  
           if (is_file($this->Ini->root . $out_anexo_ouvd_img2_1000))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_anexo_ouvd_img2_1000) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_ler_img = false;
               } 
           } 
           if ($NM_ler_img) 
           { 
               $tmp_anexo_ouvd_img2_1000 = fopen($path_anexo_ouvd_img2_1000, "r") ; 
               $reg_anexo_ouvd_img2_1000 = fread($tmp_anexo_ouvd_img2_1000, filesize($path_anexo_ouvd_img2_1000)) ; 
               fclose($tmp_anexo_ouvd_img2_1000) ;  
               $arq_anexo_ouvd_img2_1000 = fopen($this->Ini->root . $out_anexo_ouvd_img2_1000, "w") ;  
               fwrite($arq_anexo_ouvd_img2_1000, $reg_anexo_ouvd_img2_1000) ;  
               fclose($arq_anexo_ouvd_img2_1000) ;  
           } 
       if ($this->Ini->Export_img_zip) {
           $this->Ini->Img_export_zip[] = $this->Ini->root . $out_anexo_ouvd_img2_1000;
           $out_anexo_ouvd_img2_1000 = str_replace($this->Ini->path_imag_temp . "/", "", $out_anexo_ouvd_img2_1000);
       } 
       } 
   } 
   if (isset($_POST['nmgp_opcao']) && 'excluir' == $_POST['nmgp_opcao'] && $this->sc_evento != "delete" && (!isset($this->sc_evento_old) || 'delete' != $this->sc_evento_old))
   {
       global $temp_out_anexo_ouvd_img2_1000;
       if (isset($temp_out_anexo_ouvd_img2_1000))
       {
           $out_anexo_ouvd_img2_1000 = $temp_out_anexo_ouvd_img2_1000;
       }
   }
   if ($this->anexo_ouvd_doc1_1000 != "" && $this->anexo_ouvd_doc1_1000 != "none")   
   { 
       $sTmpExtension = pathinfo($this->anexo_ouvd_doc1_1000, PATHINFO_EXTENSION);
       $sTmpExtension = null == $sTmpExtension ? '' : '.' . $sTmpExtension;
       $sTmpFile_anexo_ouvd_doc1_1000 = 'sc_anexo_ouvd_doc1_1000_' . md5(mt_rand(1, 1000) . microtime() . session_id()) . $sTmpExtension;
       if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames']))
       {
           $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'] = array();
       }
       $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'][$sTmpFile_anexo_ouvd_doc1_1000] = $this->anexo_ouvd_doc1_1000;
   } 
   if ($this->anexo_ouvd_doc2_1000 != "" && $this->anexo_ouvd_doc2_1000 != "none")   
   { 
       $sTmpExtension = pathinfo($this->anexo_ouvd_doc2_1000, PATHINFO_EXTENSION);
       $sTmpExtension = null == $sTmpExtension ? '' : '.' . $sTmpExtension;
       $sTmpFile_anexo_ouvd_doc2_1000 = 'sc_anexo_ouvd_doc2_1000_' . md5(mt_rand(1, 1000) . microtime() . session_id()) . $sTmpExtension;
       if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames']))
       {
           $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'] = array();
       }
       $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['download_filenames'][$sTmpFile_anexo_ouvd_doc2_1000] = $this->anexo_ouvd_doc2_1000;
   } 
        $this->initFormPages();
    include_once("cadastro_DEN_1000_registro_mob_form0.php");
        $this->hideFormPages();
 }

        function initFormPages() {
        } // initFormPages

        function hideFormPages() {
        } // hideFormPages

    function form_format_readonly($field, $value)
    {
        $result = $value;

        $this->form_highlight_search($result, $field, $value);

        return $result;
    }

    function form_highlight_search(&$result, $field, $value)
    {
        if ($this->proc_fast_search) {
            $this->form_highlight_search_quicksearch($result, $field, $value);
        }
    }

    function form_highlight_search_quicksearch(&$result, $field, $value)
    {
        $searchOk = false;
        if ('SC_all_Cmp' == $this->nmgp_fast_search && in_array($field, array("ouvd_anonima_1000", "nome_inf_ouvd_1000", "cpf_cnpj_ouvd_1000", "email_inf_ouvd_1000", "tel_inf_ouvd_1000", "id_categoria_1100", "desc_area_setor_1000", "titulo_manifestacao_1000", "desc_manifestacao_1000", "dt_ocorrido_1000", "anexo_ouvd_img1_1000", "anexo_ouvd_img2_1000", "anexo_ouvd_doc1_1000", "anexo_ouvd_doc2_1000"))) {
            $searchOk = true;
        }
        elseif ($field == $this->nmgp_fast_search && in_array($field, array("ouvd_anonima_1000", "nome_inf_ouvd_1000", "cpf_cnpj_ouvd_1000", "email_inf_ouvd_1000", "tel_inf_ouvd_1000", "id_categoria_1100", "desc_area_setor_1000", "titulo_manifestacao_1000", "desc_manifestacao_1000", "dt_ocorrido_1000", "anexo_ouvd_img1_1000", "anexo_ouvd_img2_1000", "anexo_ouvd_doc1_1000", "anexo_ouvd_doc2_1000"))) {
            $searchOk = true;
        }

        if (!$searchOk || '' == $this->nmgp_arg_fast_search) {
            return;
        }

        $htmlIni = '<div class="highlight" style="background-color: #fafaca; display: inline-block">';
        $htmlFim = '</div>';

        if ('qp' == $this->nmgp_cond_fast_search) {
            $keywords = preg_quote($this->nmgp_arg_fast_search, '/');
            $result = preg_replace('/'. $keywords .'/i', $htmlIni . '$0' . $htmlFim, $result);
        } elseif ('eq' == $this->nmgp_cond_fast_search) {
            if (strcasecmp($this->nmgp_arg_fast_search, $value) == 0) {
                $result = $htmlIni. $result .$htmlFim;
            }
        }
    }


    function form_encode_input($string)
    {
        if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['table_refresh']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['table_refresh'])
        {
            return NM_encode_input(NM_encode_input($string));
        }
        else
        {
            return NM_encode_input($string);
        }
    } // form_encode_input

   function jqueryCalendarDtFormat($sFormat, $sSep)
   {
       $sFormat = chunk_split(str_replace('yyyy', 'yy', $sFormat), 2, $sSep);

       if ($sSep == substr($sFormat, -1))
       {
           $sFormat = substr($sFormat, 0, -1);
       }

       return $sFormat;
   } // jqueryCalendarDtFormat

   function jqueryCalendarTimeStart($sFormat, $value)
   {
       $aDateParts = explode(';', $sFormat);

       if (2 == sizeof($aDateParts))
       {
           $sTime = $aDateParts[1];
       }
       else
       {
           $sTime = 'hh:mm:ss';
       }

       if ('now' == $value) {
           return str_replace(array('hh', 'mm', 'ii', 'ss'), array(date('H'), date('i'), date('i'), date('s')), $sTime);
       } elseif ('end' == $value) {
           return str_replace(array('hh', 'mm', 'ii', 'ss'), array('23', '59', '59', '59'), $sTime);
       } else {
           return str_replace(array('h', 'm', 'i', 's'), array('0', '0', '0', '0'), $sTime);
       }
   } // jqueryCalendarTimeStart

   function jqueryCalendarWeekInit($sDay)
   {
       switch ($sDay) {
           case 'MO': return 1; break;
           case 'TU': return 2; break;
           case 'WE': return 3; break;
           case 'TH': return 4; break;
           case 'FR': return 5; break;
           case 'SA': return 6; break;
           default  : return 7; break;
       }
   } // jqueryCalendarWeekInit

   function jqueryIconFile($sModule)
   {
       $sImage = '';
       if ('calendar' == $sModule)
       {
           if (isset($this->arr_buttons['bcalendario']) && isset($this->arr_buttons['bcalendario']['type']) && 'image' == $this->arr_buttons['bcalendario']['type'] && 'only_fontawesomeicon' != $this->arr_buttons['bcalendario']['display'])
           {
               $sImage = $this->arr_buttons['bcalendario']['image'];
           }
       }
       elseif ('calculator' == $sModule)
       {
           if (isset($this->arr_buttons['bcalculadora']) && isset($this->arr_buttons['bcalculadora']['type']) && 'image' == $this->arr_buttons['bcalculadora']['type'] && 'only_fontawesomeicon' != $this->arr_buttons['bcalculadora']['display'])
           {
               $sImage = $this->arr_buttons['bcalculadora']['image'];
           }
       }

       return '' == $sImage ? '' : $this->Ini->path_icones . '/' . $sImage;
   } // jqueryIconFile

   function jqueryFAFile($sModule)
   {
       $sFA = '';
       if ('calendar' == $sModule)
       {
           if (isset($this->arr_buttons['bcalendario']) && isset($this->arr_buttons['bcalendario']['type']) && ('image' == $this->arr_buttons['bcalendario']['type'] || 'button' == $this->arr_buttons['bcalendario']['type']) && 'only_fontawesomeicon' == $this->arr_buttons['bcalendario']['display'])
           {
               $sFA = $this->arr_buttons['bcalendario']['fontawesomeicon'];
           }
       }
       elseif ('calculator' == $sModule)
       {
           if (isset($this->arr_buttons['bcalculadora']) && isset($this->arr_buttons['bcalculadora']['type']) && ('image' == $this->arr_buttons['bcalculadora']['type'] || 'button' == $this->arr_buttons['bcalculadora']['type']) && 'only_fontawesomeicon' == $this->arr_buttons['bcalculadora']['display'])
           {
               $sFA = $this->arr_buttons['bcalculadora']['fontawesomeicon'];
           }
       }

       return '' == $sFA ? '' : "<span class='scButton_fontawesome " . $sFA . "'></span>";
   } // jqueryFAFile

   function jqueryButtonText($sModule)
   {
       $sClass = '';
       $sText  = '';
       if ('calendar' == $sModule)
       {
           if (isset($this->arr_buttons['bcalendario']) && isset($this->arr_buttons['bcalendario']['type']) && ('image' == $this->arr_buttons['bcalendario']['type'] || 'button' == $this->arr_buttons['bcalendario']['type']))
           {
               if ('only_text' == $this->arr_buttons['bcalendario']['display'])
               {
                   $sClass = 'scButton_' . $this->arr_buttons['bcalendario']['style'];
                   $sText  = $this->arr_buttons['bcalendario']['value'];
               }
               elseif ('text_fontawesomeicon' == $this->arr_buttons['bcalendario']['display'])
               {
                   $sClass = 'scButton_' . $this->arr_buttons['bcalendario']['style'];
                   if ('text_right' == $this->arr_buttons['bcalendario']['display_position'])
                   {
                       $sText = "<i class='icon_fa " . $this->arr_buttons['bcalendario']['fontawesomeicon'] . "'></i> " . $this->arr_buttons['bcalendario']['value'];
                   }
                   else
                   {
                       $sText = $this->arr_buttons['bcalendario']['value'] . " <i class='icon_fa " . $this->arr_buttons['bcalendario']['fontawesomeicon'] . "'></i>";
                   }
               }
           }
       }
       elseif ('calculator' == $sModule)
       {
           if (isset($this->arr_buttons['bcalculadora']) && isset($this->arr_buttons['bcalculadora']['type']) && ('image' == $this->arr_buttons['bcalculadora']['type'] || 'button' == $this->arr_buttons['bcalculadora']['type']))
           {
               if ('only_text' == $this->arr_buttons['bcalculadora']['display'])
               {
                   $sClass = 'scButton_' . $this->arr_buttons['bcalendario']['style'];
                   $sText  = $this->arr_buttons['bcalculadora']['value'];
               }
               elseif ('text_fontawesomeicon' == $this->arr_buttons['bcalculadora']['display'])
               {
                   $sClass = 'scButton_' . $this->arr_buttons['bcalendario']['style'];
                   if ('text_right' == $this->arr_buttons['bcalendario']['display_position'])
                   {
                       $sText = "<i class='icon_fa " . $this->arr_buttons['bcalculadora']['fontawesomeicon'] . "'></i> " . $this->arr_buttons['bcalculadora']['value'];
                   }
                   else
                   {
                       $sText = $this->arr_buttons['bcalculadora']['value'] . " <i class='icon_fa " . $this->arr_buttons['bcalculadora']['fontawesomeicon'] . "'></i> ";
                   }
               }
           }
       }

       return '' == $sText ? array('', '') : array($sText, $sClass);
   } // jqueryButtonText


    function scCsrfGetToken()
    {
        if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['csrf_token']))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['csrf_token'] = $this->scCsrfGenerateToken();
        }

        return $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['csrf_token'];
    }

    function scCsrfGenerateToken()
    {
        $aSources = array(
            'abcdefghijklmnopqrstuvwxyz',
            'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
            '1234567890',
            '!@$*()-_[]{},.;:'
        );

        $sRandom = '';

        $aSourcesSizes = array();
        $iSourceSize   = sizeof($aSources) - 1;
        for ($i = 0; $i <= $iSourceSize; $i++)
        {
            $aSourcesSizes[$i] = strlen($aSources[$i]) - 1;
        }

        for ($i = 0; $i < 64; $i++)
        {
            $iSource = $this->scCsrfRandom(0, $iSourceSize);
            $sRandom .= substr($aSources[$iSource], $this->scCsrfRandom(0, $aSourcesSizes[$iSource]), 1);
        }

        return $sRandom;
    }

    function scCsrfRandom($iMin, $iMax)
    {
        return mt_rand($iMin, $iMax);
    }

        function addUrlParam($url, $param, $value) {
                $urlParts  = explode('?', $url);
                $urlParams = isset($urlParts[1]) ? explode('&', $urlParts[1]) : array();
                $objParams = array();
                foreach ($urlParams as $paramInfo) {
                        $paramParts = explode('=', $paramInfo);
                        $objParams[ $paramParts[0] ] = isset($paramParts[1]) ? $paramParts[1] : '';
                }
                $objParams[$param] = $value;
                $urlParams = array();
                foreach ($objParams as $paramName => $paramValue) {
                        $urlParams[] = $paramName . '=' . $paramValue;
                }
                return $urlParts[0] . '?' . implode('&', $urlParams);
        }
 function allowedCharsCharset($charlist)
 {
     if ($_SESSION['scriptcase']['charset'] != 'UTF-8')
     {
         $charlist = NM_conv_charset($charlist, $_SESSION['scriptcase']['charset'], 'UTF-8');
     }
     return str_replace("'", "\'", $charlist);
 }

function sc_file_size($file, $format = false)
{
    if ('' == $file) {
        return '';
    }
    if (!@is_file($file)) {
        return '';
    }
    $fileSize = @filesize($file);
    if ($format) {
        $suffix = '';
        if (1024 >= $fileSize) {
            $fileSize /= 1024;
            $suffix    = ' KB';
        }
        if (1024 >= $fileSize) {
            $fileSize /= 1024;
            $suffix    = ' MB';
        }
        if (1024 >= $fileSize) {
            $fileSize /= 1024;
            $suffix    = ' GB';
        }
        $fileSize = $fileSize . $suffix;
    }
    return $fileSize;
}


 function new_date_format($type, $field)
 {
     $new_date_format_out = '';

     if ('DT' == $type)
     {
         $date_format  = $this->field_config[$field]['date_format'];
         $date_sep     = $this->field_config[$field]['date_sep'];
         $date_display = $this->field_config[$field]['date_display'];
         $time_format  = '';
         $time_sep     = '';
         $time_display = '';
     }
     elseif ('DH' == $type)
     {
         $date_format  = false !== strpos($this->field_config[$field]['date_format'] , ';') ? substr($this->field_config[$field]['date_format'] , 0, strpos($this->field_config[$field]['date_format'] , ';')) : $this->field_config[$field]['date_format'];
         $date_sep     = $this->field_config[$field]['date_sep'];
         $date_display = false !== strpos($this->field_config[$field]['date_display'], ';') ? substr($this->field_config[$field]['date_display'], 0, strpos($this->field_config[$field]['date_display'], ';')) : $this->field_config[$field]['date_display'];
         $time_format  = false !== strpos($this->field_config[$field]['date_format'] , ';') ? substr($this->field_config[$field]['date_format'] , strpos($this->field_config[$field]['date_format'] , ';') + 1) : '';
         $time_sep     = $this->field_config[$field]['time_sep'];
         $time_display = false !== strpos($this->field_config[$field]['date_display'], ';') ? substr($this->field_config[$field]['date_display'], strpos($this->field_config[$field]['date_display'], ';') + 1) : '';
     }
     elseif ('HH' == $type)
     {
         $date_format  = '';
         $date_sep     = '';
         $date_display = '';
         $time_format  = $this->field_config[$field]['date_format'];
         $time_sep     = $this->field_config[$field]['time_sep'];
         $time_display = $this->field_config[$field]['date_display'];
     }

     if ('DT' == $type || 'DH' == $type)
     {
         $date_array = array();
         $date_index = 0;
         $date_ult   = '';
         for ($i = 0; $i < strlen($date_format); $i++)
         {
             $char = strtolower(substr($date_format, $i, 1));
             if (in_array($char, array('d', 'm', 'y', 'a')))
             {
                 if ('a' == $char)
                 {
                     $char = 'y';
                 }
                 if ($char == $date_ult)
                 {
                     $date_array[$date_index] .= $char;
                 }
                 else
                 {
                     if ('' != $date_ult)
                     {
                         $date_index++;
                     }
                     $date_array[$date_index] = $char;
                 }
             }
             $date_ult = $char;
         }

         $disp_array = array();
         $date_index = 0;
         $date_ult   = '';
         for ($i = 0; $i < strlen($date_display); $i++)
         {
             $char = strtolower(substr($date_display, $i, 1));
             if (in_array($char, array('d', 'm', 'y', 'a')))
             {
                 if ('a' == $char)
                 {
                     $char = 'y';
                 }
                 if ($char == $date_ult)
                 {
                     $disp_array[$date_index] .= $char;
                 }
                 else
                 {
                     if ('' != $date_ult)
                     {
                         $date_index++;
                     }
                     $disp_array[$date_index] = $char;
                 }
             }
             $date_ult = $char;
         }

         $date_final = array();
         foreach ($date_array as $date_part)
         {
             if (in_array($date_part, $disp_array))
             {
                 $date_final[] = $date_part;
             }
         }

         $date_format = implode($date_sep, $date_final);
     }
     if ('HH' == $type || 'DH' == $type)
     {
         $time_array = array();
         $time_index = 0;
         $time_ult   = '';
         for ($i = 0; $i < strlen($time_format); $i++)
         {
             $char = strtolower(substr($time_format, $i, 1));
             if (in_array($char, array('h', 'i', 's')))
             {
                 if ($char == $time_ult)
                 {
                     $time_array[$time_index] .= $char;
                 }
                 else
                 {
                     if ('' != $time_ult)
                     {
                         $time_index++;
                     }
                     $time_array[$time_index] = $char;
                 }
             }
             $time_ult = $char;
         }

         $disp_array = array();
         $time_index = 0;
         $time_ult   = '';
         for ($i = 0; $i < strlen($time_display); $i++)
         {
             $char = strtolower(substr($time_display, $i, 1));
             if (in_array($char, array('h', 'i', 's')))
             {
                 if ($char == $time_ult)
                 {
                     $disp_array[$time_index] .= $char;
                 }
                 else
                 {
                     if ('' != $time_ult)
                     {
                         $time_index++;
                     }
                     $disp_array[$time_index] = $char;
                 }
             }
             $time_ult = $char;
         }

         $time_final = array();
         foreach ($time_array as $time_part)
         {
             if (in_array($time_part, $disp_array))
             {
                 $time_final[] = $time_part;
             }
         }

         $time_format = implode($time_sep, $time_final);
     }

     if ('DT' == $type)
     {
         $old_date_format = $date_format;
     }
     elseif ('DH' == $type)
     {
         $old_date_format = $date_format . ';' . $time_format;
     }
     elseif ('HH' == $type)
     {
         $old_date_format = $time_format;
     }

     for ($i = 0; $i < strlen($old_date_format); $i++)
     {
         $char = substr($old_date_format, $i, 1);
         if ('/' == $char)
         {
             $new_date_format_out .= $date_sep;
         }
         elseif (':' == $char)
         {
             $new_date_format_out .= $time_sep;
         }
         else
         {
             $new_date_format_out .= $char;
         }
     }

     $this->field_config[$field]['date_format'] = $new_date_format_out;
     if ('DH' == $type)
     {
         $new_date_format_out                                  = explode(';', $new_date_format_out);
         $this->field_config[$field]['date_format_js']        = $new_date_format_out[0];
         $this->field_config[$field . '_hora']['date_format'] = $new_date_format_out[1];
         $this->field_config[$field . '_hora']['time_sep']    = $this->field_config[$field]['time_sep'];
     }
 } // new_date_format

   function Form_lookup_ouvd_anonima_1000()
   {
       $nmgp_def_dados  = "";
       $nmgp_def_dados .= "Sim?#?1?#?N?@?";
       $nmgp_def_dados .= "Não?#?0?#?S?@?";
       $todo = explode("?@?", $nmgp_def_dados);
       return $todo;

   }
   function Form_lookup_id_categoria_1100()
   {
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'] = array(); 
}
   if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
   { 
       $GLOBALS["NM_ERRO_IBASE"] = 1;  
   } 
   $nm_nao_carga = false;
   $nmgp_def_dados = "" ; 
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100']); 
   }
   else
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'] = array(); 
    }

   $old_value_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
   $old_value_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
   $old_value_dt_ocorrido_1000 = $this->dt_ocorrido_1000;
   $this->nm_tira_formatacao();
   if ($this->nmgp_opcao != "nada") {
       $this->nm_converte_datas(false);
   }


   $unformatted_value_cpf_cnpj_ouvd_1000 = $this->cpf_cnpj_ouvd_1000;
   $unformatted_value_tel_inf_ouvd_1000 = $this->tel_inf_ouvd_1000;
   $unformatted_value_dt_ocorrido_1000 = $this->dt_ocorrido_1000;

   $nm_comando = "SELECT id_categoria_ouvd_1100, titulo_categoria_1100 FROM OUVD_1100_categoria WHERE ind_cat_atv_1100 = 1 AND id_controlador_1000 = " . $_SESSION['usr_controlador'] . "";

   $this->cpf_cnpj_ouvd_1000 = $old_value_cpf_cnpj_ouvd_1000;
   $this->tel_inf_ouvd_1000 = $old_value_tel_inf_ouvd_1000;
   $this->dt_ocorrido_1000 = $old_value_dt_ocorrido_1000;

   $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando;
   $_SESSION['scriptcase']['sc_sql_ult_conexao'] = '';
   if ($nm_comando != "" && $rs = $this->Db->Execute($nm_comando))
   {
       while (!$rs->EOF) 
       { 
              $rs->fields[0] = str_replace(',', '.', $rs->fields[0]);
              $rs->fields[0] = (strpos(strtolower($rs->fields[0]), "e")) ? (float)$rs->fields[0] : $rs->fields[0];
              $rs->fields[0] = (string)$rs->fields[0];
              $nmgp_def_dados .= $rs->fields[1] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['Lookup_id_categoria_1100'][] = $rs->fields[0];
              $rs->MoveNext() ; 
       } 
       $rs->Close() ; 
   } 
   elseif ($GLOBALS["NM_ERRO_IBASE"] != 1 && $nm_comando != "")  
   {  
       $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
       exit; 
   } 
   $GLOBALS["NM_ERRO_IBASE"] = 0; 
   $todox = str_replace("?#?@?#?", "?#?@ ?#?", trim($nmgp_def_dados)) ; 
   $todo  = explode("?@?", $todox) ; 
   return $todo;

   }
   function SC_fast_search($in_fields, $arg_search, $data_search)
   {
      $fields = (strpos($in_fields, "SC_all_Cmp") !== false) ? array("SC_all_Cmp") : explode(";", $in_fields);
      $this->NM_case_insensitive = false;
      if (empty($data_search)) 
      {
         unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dyn_search_and_or']);
         unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dyn_search_cache']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['fast_search']);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_detal'])) 
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'] = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_detal'];
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter'])
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter']);
              $this->NM_ajax_info['empty_filter'] = 'ok';
              cadastro_DEN_1000_registro_mob_pack_ajax_response();
              exit;
          }
          return;
      }
      $comando = "";
      if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($data_search))
      {
          $data_search = NM_conv_charset($data_search, $_SESSION['scriptcase']['charset'], "UTF-8");
      }
      $sv_data = $data_search;
      foreach ($fields as $field) {
          if ($field == "SC_all_Cmp" || $field == "ouvd_anonima_1000") 
          {
              $data_lookup = $this->SC_lookup_ouvd_anonima_1000($arg_search, $data_search);
              if (is_array($data_lookup) && !empty($data_lookup)) 
              {
                  $this->SC_monta_condicao($comando, "ouvd_anonima_1000", $arg_search, $data_lookup, "TINYINT", false);
              }
          }
          if ($field == "SC_all_Cmp" || $field == "nome_inf_ouvd_1000") 
          {
              $this->SC_monta_condicao($comando, "nome_inf_ouvd_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "cpf_cnpj_ouvd_1000") 
          {
              $this->SC_monta_condicao($comando, "cpf_cnpj_ouvd_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "email_inf_ouvd_1000") 
          {
              $this->SC_monta_condicao($comando, "email_inf_ouvd_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "tel_inf_ouvd_1000") 
          {
              $this->SC_monta_condicao($comando, "tel_inf_ouvd_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "id_categoria_1100") 
          {
              $data_lookup = $this->SC_lookup_id_categoria_1100($arg_search, $data_search);
              if (is_array($data_lookup) && !empty($data_lookup)) 
              {
                  $this->SC_monta_condicao($comando, "id_categoria_1100", $arg_search, $data_lookup, "INT", false);
              }
          }
          if ($field == "SC_all_Cmp" || $field == "desc_area_setor_1000") 
          {
              $this->SC_monta_condicao($comando, "desc_area_setor_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "titulo_manifestacao_1000") 
          {
              $this->SC_monta_condicao($comando, "titulo_manifestacao_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "desc_manifestacao_1000") 
          {
              $this->SC_monta_condicao($comando, "desc_manifestacao_1000", $arg_search, $data_search, "TEXT", false);
          }
          if ($field == "SC_all_Cmp" || $field == "dt_ocorrido_1000") 
          {
              $this->SC_monta_condicao($comando, "dt_ocorrido_1000", $arg_search, $data_search, "DATE", false);
          }
          if ($field == "SC_all_Cmp" || $field == "anexo_ouvd_img1_1000") 
          {
              $this->SC_monta_condicao($comando, "anexo_ouvd_img1_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "anexo_ouvd_img2_1000") 
          {
              $this->SC_monta_condicao($comando, "anexo_ouvd_img2_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "anexo_ouvd_doc1_1000") 
          {
              $this->SC_monta_condicao($comando, "anexo_ouvd_doc1_1000", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "anexo_ouvd_doc2_1000") 
          {
              $this->SC_monta_condicao($comando, "anexo_ouvd_doc2_1000", $arg_search, $data_search, "VARCHAR", false);
          }
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_detal']) && !empty($comando)) 
      {
          $comando = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_detal'] . " and (" .  $comando . ")";
      }
      if (empty($comando)) 
      {
          $comando = " 1 <> 1 "; 
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter_form'])
      {
          $sc_where = " where " . $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter_form'] . " and (" . $comando . ")";
      }
      else
      {
         $sc_where = " where " . $comando;
      }
      $nmgp_select = "SELECT count(*) AS countTest from " . $this->Ini->nm_tabela . $sc_where; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
      $rt = $this->Db->Execute($nmgp_select) ; 
      if ($rt === false && !$rt->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
      { 
          $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit ; 
      }  
      $qt_geral_reg_cadastro_DEN_1000_registro_mob = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total'] = $qt_geral_reg_cadastro_DEN_1000_registro_mob;
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['where_filter'] = $comando;
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['fast_search'][0] = $field;
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['fast_search'][1] = $arg_search;
      $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['fast_search'][2] = $sv_data;
      $rt->Close(); 
      if (isset($rt->fields[0]) && $rt->fields[0] > 0 &&  isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter'])
      {
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter']);
          $this->NM_ajax_info['empty_filter'] = 'ok';
          cadastro_DEN_1000_registro_mob_pack_ajax_response();
          exit;
      }
      elseif (!isset($rt->fields[0]) || $rt->fields[0] == 0)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['empty_filter'] = true;
          $this->NM_ajax_info['empty_filter'] = 'ok';
          cadastro_DEN_1000_registro_mob_pack_ajax_response();
          exit;
      }
   }
   function SC_monta_condicao(&$comando, $nome, $condicao, $campo, $tp_campo="", $tp_unaccent=false)
   {
      $nm_aspas   = "'";
      $nm_aspas1  = "'";
      $nm_numeric = array();
      $Nm_datas   = array();
      $nm_esp_postgres = array();
      $campo_join = strtolower(str_replace(".", "_", $nome));
      $nm_ini_lower = "";
      $nm_fim_lower = "";
      $Nm_accent = $this->Ini->Nm_accent_no;
      if ($tp_unaccent) {
          $Nm_accent = $this->Ini->Nm_accent_yes;
      }
      $nm_numeric[] = "id_categoria_1100";$nm_numeric[] = "ouvd_anonima_1000";$nm_numeric[] = "nivel_atend_atual_1000";$nm_numeric[] = "id_status_ouvd_1000";$nm_numeric[] = "id_controlador_1000";
      if (in_array($campo_join, $nm_numeric))
      {
         if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['decimal_db'] == ".")
         {
             $nm_aspas  = "";
             $nm_aspas1 = "";
         }
         if (is_array($campo))
         {
             foreach ($campo as $Ind => $Cmp)
             {
                if (!is_numeric($Cmp))
                {
                    return;
                }
                if ($Cmp == "")
                {
                    $campo[$Ind] = 0;
                }
             }
         }
         else
         {
             if (!is_numeric($campo))
             {
                 return;
             }
             if ($campo == "")
             {
                $campo = 0;
             }
         }
      }
      if (is_array($campo)) {
          foreach ($campo as $Ind => $Cmp) {
             if ($Cmp != null) {
                 $campo[$Ind] = substr($this->Ini->Db->qstr($Cmp), 1, -1);
             }
          }
      }
      else {
          $campo = substr($this->Ini->Db->qstr($campo), 1, -1);
      }
         if (in_array($campo_join, $nm_numeric) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) && (strtoupper($condicao) == "II" || strtoupper($condicao) == "QP" || strtoupper($condicao) == "NP"))
         {
             $nome      = "CAST ($nome AS TEXT)";
             $nm_aspas  = "'";
             $nm_aspas1 = "'";
         }
         if (in_array($campo_join, $nm_esp_postgres) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
         {
             $nome      = "CAST ($nome AS TEXT)";
             $nm_aspas  = "'";
             $nm_aspas1 = "'";
         }
      $Nm_datas["dt_ocorrido_1000"] = "date";$Nm_datas["dt_ini_inv_ouvd_1000"] = "date";$Nm_datas["data_hora_cadastro_1000"] = "datetime";
         if (isset($Nm_datas[$campo_join]))
         {
             for ($x = 0; $x < strlen($campo); $x++)
             {
                 $tst = substr($campo, $x, 1);
                 if (!is_numeric($tst) && ($tst != "-" && $tst != ":" && $tst != " "))
                 {
                     return;
                 }
             }
         }
          if (isset($Nm_datas[$campo_join]))
          {
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
             $nm_aspas  = "#";
             $nm_aspas1 = "#";
          }
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['SC_sep_date']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['SC_sep_date']))
              {
                  $nm_aspas  = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['SC_sep_date'];
                  $nm_aspas1 = $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['SC_sep_date1'];
              }
          }
      if (isset($Nm_datas[$campo_join]) && (strtoupper($condicao) == "II" || strtoupper($condicao) == "QP" || strtoupper($condicao) == "NP" || strtoupper($condicao) == "DF"))
      {
          if (strtoupper($condicao) == "DF")
          {
              $condicao = "NP";
          }
          if (($Nm_datas[$campo_join] == "datetime" || $Nm_datas[$campo_join] == "timestamp") && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $nome = "to_char (" . $nome . ", 'YYYY-MM-DD hh24:mi:ss')";
          }
          elseif ($Nm_datas[$campo_join] == "date" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $nome = "to_char (" . $nome . ", 'YYYY-MM-DD')";
          }
          elseif ($Nm_datas[$campo_join] == "time" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $nome = "to_char (" . $nome . ", 'hh24:mi:ss')";
          }
      }
         $comando .= (!empty($comando) ? " or " : "");
         if (is_array($campo))
         {
             $prep = "";
             foreach ($campo as $Ind => $Cmp)
             {
                 $prep .= (!empty($prep)) ? "," : "";
                 $Cmp   = substr($this->Db->qstr($Cmp), 1, -1);
                 $prep .= $nm_ini_lower . $nm_aspas . $Cmp . $nm_aspas1 . $nm_fim_lower;
             }
             $prep .= (empty($prep)) ? $nm_aspas . $nm_aspas1 : "";
             $comando .= $nm_ini_lower . $nome . $nm_fim_lower . " in (" . $prep . ")";
             return;
         }
         $campo  = substr($this->Db->qstr($campo), 1, -1);
         $cond_tst = strtoupper($condicao);
         if ($cond_tst == "II" || $cond_tst == "QP" || $cond_tst == "NP")
         {
             if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) && $this->NM_case_insensitive)
             {
                 $op_like      = " ilike ";
                 $nm_ini_lower = "";
                 $nm_fim_lower = "";
             }
             else
             {
                 $op_like = " like ";
             }
         }
         switch ($cond_tst)
         {
            case "EQ":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " = " . $nm_ini_lower . $nm_aspas . $campo . $nm_aspas1 . $nm_fim_lower;
            break;
            case "II":     // 
               $comando        .= $nm_ini_lower . $Nm_accent['cmp_i'] . $nome . $Nm_accent['cmp_f'] . $nm_fim_lower . $Nm_accent['cmp_apos'] . $op_like . $nm_ini_lower . "'" . $Nm_accent['arg_i'] . sc_sql_escape($this->Ini->nm_tpbanco, $campo) . $Nm_accent['arg_f'] . "%'" . $nm_fim_lower . $Nm_accent['arg_apos'] . $_SESSION['sc_session']['sc_sql_escape'];
            break;
            case "QP":     // 
               $comando        .= $nm_ini_lower . $Nm_accent['cmp_i'] . $nome . $Nm_accent['cmp_f'] . $nm_fim_lower . $Nm_accent['cmp_apos'] . $op_like . $nm_ini_lower . "'%" . $Nm_accent['arg_i'] . sc_sql_escape($this->Ini->nm_tpbanco, $campo) . $Nm_accent['arg_f'] . "%'" . $nm_fim_lower . $Nm_accent['arg_apos'] . $_SESSION['sc_session']['sc_sql_escape'];
            break;
            case "NP":     // 
               $comando        .= $nm_ini_lower . $Nm_accent['cmp_i'] . $nome . $Nm_accent['cmp_f'] . $nm_fim_lower . $Nm_accent['cmp_apos'] . " not" . $op_like . $nm_ini_lower . "'%" . $Nm_accent['arg_i'] . sc_sql_escape($this->Ini->nm_tpbanco, $campo) . $Nm_accent['arg_f'] . "%'" . $nm_fim_lower . $Nm_accent['arg_apos'] . $_SESSION['sc_session']['sc_sql_escape'];
            break;
            case "DF":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " <> " . $nm_ini_lower . $nm_aspas . $campo . $nm_aspas1 . $nm_fim_lower;
            break;
            case "GT":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " > " . $nm_ini_lower . $nm_aspas . $campo . $nm_aspas1 . $nm_fim_lower;
            break;
            case "GE":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " >= " . $nm_ini_lower . $nm_aspas . $campo . $nm_aspas1 . $nm_fim_lower;
            break;
            case "LT":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " < " . $nm_ini_lower . $nm_aspas . $campo . $nm_aspas1 . $nm_fim_lower;
            break;
            case "LE":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " <= " . $nm_ini_lower . $nm_aspas . $campo . $nm_aspas1 . $nm_fim_lower;
            break;
         }
   }
   function SC_lookup_ouvd_anonima_1000($condicao, $campo)
   {
       $data_look = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $data_look['1'] = "Sim";
       $data_look['0'] = "Não";
       $result = array();
       foreach ($data_look as $chave => $label) 
       {
           if ($condicao == "eq" && $campo == $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
           {
               $result[] = $chave;
           }
           if ($condicao == "qp" && strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "np" && !strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "df" && $campo != $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "gt" && $label > $campo )
           {
               $result[] = $chave;
           }
           if ($condicao == "ge" && $label >= $campo)
            {
               $result[] = $chave;
           }
           if ($condicao == "lt" && $label < $campo)
           {
               $result[] = $chave;
           }
           if ($condicao == "le" && $label <= $campo)
           {
               $result[] = $chave;
           }
          
       }
       return $result;
   }
   function SC_lookup_id_categoria_1100($condicao, $campo)
   {
       $result = array();
       $campo_orig = $campo;
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       if (isset($this->Ini->nm_bases_postgres) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) && ($condicao == "eq" || $condicao == "qp" || $condicao == "np" || $condicao == "ii" || $condicao == "df"))
       {
           $nm_comando = "SELECT titulo_categoria_1100, id_categoria_ouvd_1100 FROM OUVD_1100_categoria WHERE (CAST (id_categoria_ouvd_1100 AS TEXT) LIKE '%$campo%') AND (ind_cat_atv_1100 = 1) AND (id_controlador_1000 = " . $_SESSION['usr_controlador'] . ")" ; 
       }
       else
       {
           $nm_comando = "SELECT titulo_categoria_1100, id_categoria_ouvd_1100 FROM OUVD_1100_categoria WHERE (#cmp_ititulo_categoria_1100#cmp_f#cmp_apos LIKE '%#arg_i" . $campo . "#arg_f%'#arg_apos) AND (ind_cat_atv_1100 = 1) AND (id_controlador_1000 = " . $_SESSION['usr_controlador'] . ")" ; 
       }
       if ($condicao == "ii")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", "LIKE '#arg_i" . $campo . "#arg_f%'", $nm_comando);
       }
       if ($condicao == "np")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", "NOT LIKE '%#arg_i" . $campo . "#arg_f%'", $nm_comando);
       }
       if ($condicao == "df")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", "<> '#arg_i" . $campo . "#arg_f'", $nm_comando);
       }
       if ($condicao == "gt")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", "> '#arg_i" . $campo . "#arg_f'", $nm_comando);
       }
       if ($condicao == "ge")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", ">= '#arg_i" . $campo . "#arg_f'", $nm_comando);
       }
       if ($condicao == "lt")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", "< '#arg_i" . $campo . "#arg_f'", $nm_comando);
       }
       if ($condicao == "le")
       {
           $nm_comando = str_replace("LIKE '%#arg_i" . $campo . "#arg_f%'", "<= '#arg_i" . $campo . "#arg_f'", $nm_comando);
       }
       $nm_comando = str_replace(array('#cmp_i','#cmp_f','#cmp_apos','#arg_i','#arg_f','#arg_apos'), array('','','','','',''), $nm_comando); 
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
       if ($rx = $this->Db->Execute($nm_comando)) 
       { 
           $campo = $campo_orig;
           while (!$rx->EOF) 
           { 
               $chave = $rx->fields[1];
               $label = $rx->fields[0];
               if ($condicao == "eq" && $campo == $label)
               {
                   $result[] = $chave;
               }
               if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
               {
                   $result[] = $chave;
               }
               if ($condicao == "qp" && strstr($label, $campo))
               {
                   $result[] = $chave;
               }
               if ($condicao == "np" && !strstr($label, $campo))
               {
                   $result[] = $chave;
               }
               if ($condicao == "df" && $campo != $label)
               {
                   $result[] = $chave;
               }
               if ($condicao == "gt" && $label > $campo )
               {
                   $result[] = $chave;
               }
               if ($condicao == "ge" && $label >= $campo)
               {
                   $result[] = $chave;
               }
               if ($condicao == "lt" && $label < $campo)
               {
                   $result[] = $chave;
               }
               if ($condicao == "le" && $label <= $campo)
               {
                   $result[] = $chave;
               }
               $rx->MoveNext() ;
           }  
           return $result;
       }  
       elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
       { 
           $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
           exit; 
       } 
   }
function nmgp_redireciona($tipo=0)
{
   global $nm_apl_dependente;
   if (isset($_SESSION['scriptcase']['nm_sc_retorno']) && !empty($_SESSION['scriptcase']['nm_sc_retorno']) && $_SESSION['scriptcase']['sc_tp_saida'] != "D" && $nm_apl_dependente != 1) 
   {
       $nmgp_saida_form = $_SESSION['scriptcase']['nm_sc_retorno'];
   }
   else
   {
       $nmgp_saida_form = $_SESSION['scriptcase']['sc_url_saida'][$this->Ini->sc_page];
   }
   if ($tipo == 2)
   {
       $nmgp_saida_form = "cadastro_DEN_1000_registro_mob_fim.php";
   }
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['redir']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['redir'] == 'redir')
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']);
   }
   unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['opc_ant']);
   if ($tipo == 2 && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['nm_run_menu']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['nm_run_menu'] == 1)
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['nm_run_menu'] = 2;
       $nmgp_saida_form = "cadastro_DEN_1000_registro_mob_fim.php";
   }
   $diretorio = explode("/", $nmgp_saida_form);
   $cont = count($diretorio);
   $apl = $diretorio[$cont - 1];
   $apl = str_replace(".php", "", $apl);
   $pos = strpos($apl, "?");
   if ($pos !== false)
   {
       $apl = substr($apl, 0, $pos);
   }
   if ($tipo != 1 && $tipo != 2)
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page][$apl]['where_orig']);
   }
   if ($this->NM_ajax_flag)
   {
       $sTarget = '_self';
       $this->NM_ajax_info['redir']['metodo']              = 'post';
       $this->NM_ajax_info['redir']['action']              = $nmgp_saida_form;
       $this->NM_ajax_info['redir']['target']              = $sTarget;
       $this->NM_ajax_info['redir']['script_case_init']    = $this->Ini->sc_page;
       if (0 == $tipo)
       {
           $this->NM_ajax_info['redir']['nmgp_url_saida'] = $this->nm_location;
       }
       cadastro_DEN_1000_registro_mob_pack_ajax_response();
       exit;
   }
?>
<!DOCTYPE html>

   <HTML>
   <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['scriptcase']['charset_html'] ?>" />
<?php

   if (isset($_SESSION['scriptcase']['device_mobile']) && $_SESSION['scriptcase']['device_mobile'] && $_SESSION['scriptcase']['display_mobile'])
   {
?>
     <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<?php
   }

?>
    <META http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT"/>
    <META http-equiv="Last-Modified" content="<?php echo gmdate("D, d M Y H:i:s"); ?> GMT"/>
    <META http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate"/>
    <META http-equiv="Cache-Control" content="post-check=0, pre-check=0"/>
    <META http-equiv="Pragma" content="no-cache"/>
    <link rel="shortcut icon" href="../_lib/img/usr__NM__bg__NM__Grupo 1003.png">
   </HEAD>
   <BODY>
   <FORM name="form_ok" method="POST" action="<?php echo $this->form_encode_input($nmgp_saida_form); ?>" target="_self">
<?php
   if ($tipo == 0)
   {
?>
     <INPUT type="hidden" name="nmgp_url_saida" value="<?php echo $this->form_encode_input($this->nm_location); ?>"> 
<?php
   }
?>
     <INPUT type="hidden" name="script_case_init" value="<?php echo $this->form_encode_input($this->Ini->sc_page); ?>"> 
   </FORM>
   <SCRIPT type="text/javascript">
      bLigEditLookupCall = <?php if ($this->lig_edit_lookup_call) { ?>true<?php } else { ?>false<?php } ?>;
      function scLigEditLookupCall()
      {
<?php
   if ($this->lig_edit_lookup && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_modal']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['sc_modal'])
   {
?>
        parent.<?php echo $this->lig_edit_lookup_cb; ?>(<?php echo $this->lig_edit_lookup_row; ?>);
<?php
   }
   elseif ($this->lig_edit_lookup)
   {
?>
        opener.<?php echo $this->lig_edit_lookup_cb; ?>(<?php echo $this->lig_edit_lookup_row; ?>);
<?php
   }
?>
      }
      if (bLigEditLookupCall)
      {
        scLigEditLookupCall();
      }
<?php
if ($tipo == 2 && isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['masterValue']))
{
    if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['under_dashboard']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['under_dashboard']) {
?>
var dbParentFrame = $(parent.document).find("[name='<?php echo $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['parent_widget']; ?>']");
if (dbParentFrame && dbParentFrame[0] && dbParentFrame[0].contentWindow.scAjaxDetailValue)
{
<?php
        foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['masterValue'] as $cmp_master => $val_master)
        {
?>
    dbParentFrame[0].contentWindow.scAjaxDetailValue('<?php echo $cmp_master ?>', '<?php echo $val_master ?>');
<?php
        }
        unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['masterValue']);
?>
}
<?php
    }
    else {
?>
if (parent && parent.scAjaxDetailValue)
{
<?php
        foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['masterValue'] as $cmp_master => $val_master)
        {
?>
    parent.scAjaxDetailValue('<?php echo $cmp_master ?>', '<?php echo $val_master ?>');
<?php
        }
        unset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['masterValue']);
?>
}
<?php
    }
}
?>
      document.form_ok.submit();
   </SCRIPT>
   </BODY>
   </HTML>
<?php
  exit;
}
    function sc_ajax_alert($sMessage, $params = array())
    {
        if ($this->NM_ajax_flag)
        {
            $this->NM_ajax_info['ajaxAlert']['message'] = NM_charset_to_utf8($sMessage);
            $this->NM_ajax_info['ajaxAlert']['params']  = $this->sc_ajax_alert_params($params);
        }
    } // sc_ajax_alert

    function sc_ajax_alert_params($params)
    {
        $paramList = array();
        foreach ($params as $paramName => $paramValue)
        {
            if (in_array($paramName, array('title', 'timer', 'confirmButtonText', 'confirmButtonFA', 'confirmButtonFAPos', 'cancelButtonText', 'cancelButtonFA', 'cancelButtonFAPos', 'footer', 'width', 'padding', 'position')))
            {
                $paramList[$paramName] = NM_charset_to_utf8($paramValue);
            }
            elseif (in_array($paramName, array('showConfirmButton', 'showCancelButton', 'toast')) && in_array($paramValue, array(true, false)))
            {
                $paramList[$paramName] = NM_charset_to_utf8($paramValue);
            }
            elseif ('position' == $paramName && in_array($paramValue, array('top', 'top-start', 'top-end', 'center', 'center-start', 'center-end', 'bottom', 'bottom-start', 'bottom-end')))
            {
                $paramList[$paramName] = NM_charset_to_utf8($paramValue);
            }
            elseif ('type' == $paramName && in_array($paramValue, array('warning', 'error', 'success', 'info', 'question')))
            {
                $paramList[$paramName] = NM_charset_to_utf8($paramValue);
            }
            elseif ('background' == $paramName)
            {
                $paramList[$paramName] = $this->sc_ajax_alert_image(NM_charset_to_utf8($paramValue));
            }
        }
        return $paramList;
    } // sc_ajax_alert_params

    function sc_ajax_alert_image($background)
    {
        $image_param = $background;
        preg_match_all('/url\(([\s])?(["|\'])?(.*?)(["|\'])?([\s])?\)/i', $background, $matches, PREG_PATTERN_ORDER);
        if (isset($matches[3])) {
            foreach ($matches[3] as $match) {
                if ('http:' != substr($match, 0, 5) && 'https:' != substr($match, 0, 6) && '/' != substr($match, 0, 1)) {
                    $image_param = str_replace($match, "{$this->Ini->path_img_global}/{$match}", $image_param);
                }
            }
        }
        return $image_param;
    } // sc_ajax_alert_image
    function getButtonIds($buttonName) {
        switch ($buttonName) {
            case "voltar":
                return array("sc_Voltar_top", "sc_Voltar_top");
                break;
            case "new":
                return array("sc_b_new_b.sc-unique-btn-1", "sc_b_new_t.sc-unique-btn-4");
                break;
            case "insert":
                return array("sc_b_ins_b.sc-unique-btn-2", "sc_b_ins_t.sc-unique-btn-5");
                break;
            case "exit":
                return array("sc_b_sai_b.sc-unique-btn-3", "sc_b_sai_b.sc-unique-btn-10");
                break;
            case "first":
                return array("sc_b_ini_b.sc-unique-btn-6");
                break;
            case "back":
                return array("sc_b_ret_b.sc-unique-btn-7");
                break;
            case "forward":
                return array("sc_b_avc_b.sc-unique-btn-8");
                break;
            case "last":
                return array("sc_b_fim_b.sc-unique-btn-9");
                break;
        }

        return array($buttonName);
    } // getButtonIds

    function displayAppHeader()
    {
        if ($this->Embutida_call) {
            return;
        }
        if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['mostra_cab']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro']['mostra_cab'] == "N") {
            return;
        }
        if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['under_dashboard'] && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['compact_mode'] && !$_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['dashboard_info']['maximized']) {
            return;
        }
        if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['link_info']['compact_mode']) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['link_info']['compact_mode']) {
            return;
        }
?>
    <tr><td class="sc-app-header">
<!-- Estilo adicionado na lib interna -->
<table width="100%" class="scFormHeader">
  <tr align="center">
    <td style="padding: 0px">
      <table class="header-format">
        <tr>
          <td class="scFormHeaderFont"><?php if ($this->nmgp_opcao == "novo") { echo "Cadastrar Manifestação"; } else { echo "Cadastrar Manifestação"; } ?></td>
        </tr>
      </table>
    </td>
  </tr>
</table>

    </td></tr>
<?php
    }

    function displayAppFooter()
    {
    }

    function displayAppToolbars()
    {
        if (($this->Embutida_form || !$this->Embutida_call || $this->Grid_editavel || $this->Embutida_multi || ($this->Embutida_call && 'on' == $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['embutida_liga_form_btn_nav'])) && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] != "F" && $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['run_iframe'] != "R") {
        } else {
            return false;
        }
        return true;
    } // displayAppToolbars

    function displayTopToolbar()
    {
        if (!$this->displayAppToolbars()) {
            return;
        }
    } // displayTopToolbar

    function displayBottomToolbar()
    {
        if (!$this->displayAppToolbars()) {
            return;
        }
    } // displayBottomToolbar

    function getSummaryLine()
    {
        $summaryLine = "[" . $this->Ini->Nm_lang['lang_othr_smry_info_simp'] . "]";
        $summaryLine = str_replace(
            [
                '?final?',
                '?total?',
            ],
            [
                $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['reg_start'] + 1,
                $_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['total'] + 1,
            ],
            $summaryLine
        );

        return $summaryLine;
    } // getSummaryLine

    function scGetColumnOrderRule($fieldName, &$orderColName, &$orderColOrient, &$orderColRule)
    {
        $sortRule = 'nosort';
        if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['ordem_cmp'] == $fieldName) {
            $orderColName = $fieldName;
            if ($_SESSION['sc_session'][$this->Ini->sc_page]['cadastro_DEN_1000_registro_mob']['ordem_ord'] == " desc") {
                $orderColOrient = $nome_img = $this->Ini->Label_sort_desc;
                $orderColRule = $sortRule = 'desc';
            } else {
                $orderColOrient = $nome_img = $this->Ini->Label_sort_asc;
                $orderColRule = $sortRule = 'asc';
            }
        }
        return $sortRule;
    }

    function scGetColumnOrderIcon($fieldName, $sortRule)
    {        if ($this->scIsFieldNumeric($fieldName)) {
            $defaultOffIcon = 'asc' == $this->scGetDefaultFieldOrder($fieldName) ? "fas fa-sort-numeric-down" : "fas fa-sort-numeric-down-alt";
            if ('desc' == $sortRule) {
                return "<span class=\"fas fa-sort-numeric-down-alt sc-form-order-icon\"></span>";
            } elseif ('asc' == $sortRule) {
                return "<span class=\"fas fa-sort-numeric-down sc-form-order-icon\"></span>";
            } else {
                return "<span class=\"" . $defaultOffIcon . " sc-form-order-icon sc-form-order-icon-unused\"></span>";
            }
        } else {
            $defaultOffIcon = 'asc' == $this->scGetDefaultFieldOrder($fieldName) ? "fas fa-sort-alpha-down" : "fas fa-sort-alpha-down-alt";
            if ('desc' == $sortRule) {
                return "<span class=\"fas fa-sort-alpha-down-alt sc-form-order-icon\"></span>";
            } elseif ('asc' == $sortRule) {
                return "<span class=\"fas fa-sort-alpha-down sc-form-order-icon\"></span>";
            } else {
                return "<span class=\"" . $defaultOffIcon . " sc-form-order-icon sc-form-order-icon-unused\"></span>";
            }
        }
    }

    function scIsFieldNumeric($fieldName)
    {
        switch ($fieldName) {
            case "nivel_atend_atual_1000":
                return true;
            case "id_status_ouvd_1000":
                return true;
            case "id_controlador_1000":
                return true;
            default:
                return false;
        }
        return false;
    }

    function scGetDefaultFieldOrder($fieldName)
    {
        switch ($fieldName) {
            case "ouvd_anonima_1000":
                return 'desc';
            case "id_categoria_1100":
                return 'desc';
            case "dt_ocorrido_1000":
                return 'desc';
            case "id_registro_1000":
                return 'desc';
            case "dt_ini_inv_ouvd_1000":
                return 'desc';
            case "nivel_atend_atual_1000":
                return 'desc';
            case "id_status_ouvd_1000":
                return 'desc';
            case "id_controlador_1000":
                return 'desc';
            case "data_hora_cadastro_1000":
                return 'desc';
            default:
                return 'asc';
        }
        return 'asc';
    }

}
?>
