<?php
//
class form_fiche_pro_sante_labo_edit_apl
{
   var $has_where_params = false;
   var $NM_is_redirected = false;
   var $NM_non_ajax_info = false;
   var $formatado = false;
   var $use_100perc_fields = true;
   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(),
                                '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 $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 $id_fiche_ps;
   var $code_fiche;
   var $date_declaration;
   var $date_declaration_hora;
   var $wilaya;
   var $wilaya_1;
   var $commune;
   var $commune_1;
   var $structure;
   var $nom_rapporteur;
   var $tel_rapporteur;
   var $email_rapporteur;
   var $maladie_suspectee_nm_fk;
   var $maladie_suspectee_nm_fk_1;
   var $nom_malade;
   var $prenom_malade;
   var $date_naissance_malade;
   var $age_malade;
   var $sexe_nm_fk;
   var $profession_malade;
   var $adresse_malade;
   var $wilaya_malade;
   var $commune_malade;
   var $lieu_travail;
   var $tel_malade;
   var $email_malade;
   var $lieux_frequentes;
   var $date_apparition_symptomes;
   var $autres_symptomes;
   var $hospitalisation;
   var $date_hospitalisation;
   var $evacuation;
   var $date_evacuation;
   var $structure_evacuation;
   var $structure_evacuation_1;
   var $antecedent_medicaux;
   var $commentaires;
   var $longitude;
   var $latitude;
   var $envoie;
   var $envoie_ack;
   var $valide;
   var $descr_invalidite;
   var $user_fk;
   var $validator_fk;
   var $mobile;
   var $evolution_nm_fk;
   var $symptomes;
   var $symptomes_1;
   var $device_id;
   var $maladie_suspectee_by_ia;
   var $maladie_suspectee_by_ia_1;
   var $deleted;
   var $date_validation;
   var $date_validation_hora;
   var $user_labo_fk;
   var $date_confirmation_labo;
   var $date_confirmation_labo_hora;
   var $maladie_confirmee_labo;
   var $maladie_confirmee_labo_1;
   var $statut_maladie;
   var $date_sortie;
   var $date_deces;
   var $date_prelevements;
   var $date_reception_prelevement;
   var $date_resultats_labo;
   var $type_prelevement_nm_fk;
   var $type_prelevement_nm_fk_1;
   var $resultats_labo;
   var $labo_destination;
   var $labo_destination_1;
   var $nin;
   var $commentaires_labo;
   var $commentaires_semep;
   var $statut_fiche;
   var $autre_evolution;
   var $attached_file;
   var $attached_file_scfile_name;
   var $attached_file_ul_name;
   var $attached_file_scfile_type;
   var $attached_file_ul_type;
   var $attached_file_limpa;
   var $attached_file_salva;
   var $out_attached_file;
   var $out1_attached_file;
   var $cas_similaires;
   var $unite_age_nm_fk;
   var $pays_origine;
   var $nationalite_nm_fk;
   var $spacer1;
   var $spacer2;
   var $nm_data;
   var $nmgp_opcao;
   var $nmgp_opc_ant;
   var $sc_evento;
   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']['attached_file']))
          {
              $this->attached_file = $this->NM_ajax_info['param']['attached_file'];
          }
          if (isset($this->NM_ajax_info['param']['attached_file_limpa']))
          {
              $this->attached_file_limpa = $this->NM_ajax_info['param']['attached_file_limpa'];
          }
          if (isset($this->NM_ajax_info['param']['attached_file_salva']))
          {
              $this->attached_file_salva = $this->NM_ajax_info['param']['attached_file_salva'];
          }
          if (isset($this->NM_ajax_info['param']['attached_file_ul_name']))
          {
              $this->attached_file_ul_name = $this->NM_ajax_info['param']['attached_file_ul_name'];
          }
          if (isset($this->NM_ajax_info['param']['attached_file_ul_type']))
          {
              $this->attached_file_ul_type = $this->NM_ajax_info['param']['attached_file_ul_type'];
          }
          if (isset($this->NM_ajax_info['param']['code_fiche']))
          {
              $this->code_fiche = $this->NM_ajax_info['param']['code_fiche'];
          }
          if (isset($this->NM_ajax_info['param']['commentaires']))
          {
              $this->commentaires = $this->NM_ajax_info['param']['commentaires'];
          }
          if (isset($this->NM_ajax_info['param']['commentaires_labo']))
          {
              $this->commentaires_labo = $this->NM_ajax_info['param']['commentaires_labo'];
          }
          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']['date_declaration']))
          {
              $this->date_declaration = $this->NM_ajax_info['param']['date_declaration'];
          }
          if (isset($this->NM_ajax_info['param']['date_evacuation']))
          {
              $this->date_evacuation = $this->NM_ajax_info['param']['date_evacuation'];
          }
          if (isset($this->NM_ajax_info['param']['date_reception_prelevement']))
          {
              $this->date_reception_prelevement = $this->NM_ajax_info['param']['date_reception_prelevement'];
          }
          if (isset($this->NM_ajax_info['param']['date_resultats_labo']))
          {
              $this->date_resultats_labo = $this->NM_ajax_info['param']['date_resultats_labo'];
          }
          if (isset($this->NM_ajax_info['param']['id_fiche_ps']))
          {
              $this->id_fiche_ps = $this->NM_ajax_info['param']['id_fiche_ps'];
          }
          if (isset($this->NM_ajax_info['param']['maladie_suspectee_nm_fk']))
          {
              $this->maladie_suspectee_nm_fk = $this->NM_ajax_info['param']['maladie_suspectee_nm_fk'];
          }
          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']['resultats_labo']))
          {
              $this->resultats_labo = $this->NM_ajax_info['param']['resultats_labo'];
          }
          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']['structure']))
          {
              $this->structure = $this->NM_ajax_info['param']['structure'];
          }
          if (isset($this->NM_ajax_info['param']['structure_evacuation']))
          {
              $this->structure_evacuation = $this->NM_ajax_info['param']['structure_evacuation'];
          }
          if (isset($this->NM_ajax_info['param']['type_prelevement_nm_fk']))
          {
              $this->type_prelevement_nm_fk = $this->NM_ajax_info['param']['type_prelevement_nm_fk'];
          }
          if (isset($this->NM_ajax_info['param']['user_fk']))
          {
              $this->user_fk = $this->NM_ajax_info['param']['user_fk'];
          }
          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->var_code_fiche) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['var_code_fiche'] = $this->var_code_fiche;
      }
      if (isset($this->var_code_fp_label) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['var_code_fp_label'] = $this->var_code_fp_label;
      }
      if (isset($this->usr_nfac) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['usr_nfac'] = $this->usr_nfac;
      }
      if (isset($_POST["var_code_fiche"]) && isset($this->var_code_fiche)) 
      {
          $_SESSION['var_code_fiche'] = $this->var_code_fiche;
      }
      if (isset($_POST["var_code_fp_label"]) && isset($this->var_code_fp_label)) 
      {
          $_SESSION['var_code_fp_label'] = $this->var_code_fp_label;
      }
      if (isset($_POST["usr_nfac"]) && isset($this->usr_nfac)) 
      {
          $_SESSION['usr_nfac'] = $this->usr_nfac;
      }
      if (isset($_GET["var_code_fiche"]) && isset($this->var_code_fiche)) 
      {
          $_SESSION['var_code_fiche'] = $this->var_code_fiche;
      }
      if (isset($_GET["var_code_fp_label"]) && isset($this->var_code_fp_label)) 
      {
          $_SESSION['var_code_fp_label'] = $this->var_code_fp_label;
      }
      if (isset($_GET["usr_nfac"]) && isset($this->usr_nfac)) 
      {
          $_SESSION['usr_nfac'] = $this->usr_nfac;
      }
      if (isset($this->nmgp_opcao) && $this->nmgp_opcao == "reload_novo") {
          $_POST['nmgp_opcao'] = "novo";
          $this->nmgp_opcao    = "novo";
          $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['opcao']   = "novo";
          $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['opc_ant'] = "inicio";
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['embutida_parms']))
      { 
          $this->nmgp_parms = $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['embutida_parms'];
          unset($_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['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_form_fiche_pro_sante_labo_edit($cadapar[1]);
                 if ($cadapar[1] == "@ ") {$cadapar[1] = trim($cadapar[1]); }
                 $Tmp_par = $cadapar[0];
                 $this->$Tmp_par = $cadapar[1];
             }
             $ix++;
          }
          if (isset($this->var_code_fiche)) 
          {
              $_SESSION['var_code_fiche'] = $this->var_code_fiche;
          }
          if (isset($this->var_code_fp_label)) 
          {
              $_SESSION['var_code_fp_label'] = $this->var_code_fp_label;
          }
          if (isset($this->usr_nfac)) 
          {
              $_SESSION['usr_nfac'] = $this->usr_nfac;
          }
          if (isset($this->NM_where_filter_form))
          {
              $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['where_filter_form'] = $this->NM_where_filter_form;
              unset($_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['total']);
          }
          if (isset($this->sc_redir_atualiz))
          {
              $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['sc_redir_atualiz'] = $this->sc_redir_atualiz;
          }
          if (isset($this->sc_redir_insert))
          {
              $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['sc_redir_insert'] = $this->sc_redir_insert;
          }
          if (isset($this->var_code_fiche)) 
          {
              $_SESSION['var_code_fiche'] = $this->var_code_fiche;
          }
          if (isset($this->var_code_fp_label)) 
          {
              $_SESSION['var_code_fp_label'] = $this->var_code_fp_label;
          }
          if (isset($this->usr_nfac)) 
          {
              $_SESSION['usr_nfac'] = $this->usr_nfac;
          }
      } 
      elseif (isset($script_case_init) && !empty($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['nm_run_menu'] = 1;
      } 
      if (($this->NM_ajax_flag && 'navigate_form' == $this->NM_ajax_opcao) || (isset($this->nmgp_opcao) && $this->nmgp_opcao == "igual"))
      { }
      else
      {
          $aDtParts = explode(' ', $this->date_declaration);
          $this->date_declaration      = (isset($aDtParts[0])) ? $aDtParts[0] : "";
          $this->date_declaration_hora = (isset($aDtParts[1])) ? $aDtParts[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]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup']     = true;
          $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup_cb']  = $this->nm_evt_ret_edit;
          $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup_row'] = isset($this->nm_evt_ret_row) ? $this->nm_evt_ret_row : '';
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup']) && $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup'])
      {
          $this->lig_edit_lookup     = true;
          $this->lig_edit_lookup_cb  = $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup_cb'];
          $this->lig_edit_lookup_row = $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['lig_edit_lookup_row'];
      }
      if (!$this->Ini)
      { 
          $this->Ini = new form_fiche_pro_sante_labo_edit_ini(); 
          $this->Ini->init();
          $this->nm_data = new nm_data("fr");
          $this->app_is_initializing = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['initialize'];
      } 
      else 
      { 
         $this->nm_data = new nm_data("fr");
      } 
      $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['upload_field_info'] = array();

      $_SESSION['sc_session'][$script_case_init]['form_fiche_pro_sante_labo_edit']['upload_field_info']['attached_file'] = array(
          'app_dir'            => $this->Ini->path_aplicacao,
          'app_name'           => 'form_fiche_pro_sante_labo_edit',
          'upload_dir'         => $this->Ini->root . $this->Ini->path_imag_temp . '/',
          'upload_url'         => $this->Ini->path_imag_temp . '/',
          'upload_type'        => 'single',
          'upload_allowed_type'  => '/\.(png|jpg|jpeg)$/i',
          'upload_max_size'  => null,
          'upload_file_height' => '100',
          'upload_file_width'  => '100',
          'upload_file_aspect' => 'S',
          'upload_file_type'   => 'I',
      );

      unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['masterValue']);
      $this->Change_Menu = false;
      $run_iframe = (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe']) && ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "R")) ? true : false;
      if (!$run_iframe && isset($_SESSION['scriptcase']['menu_atual']) && !$_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_call'] && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['sc_outra_jan']) || !$_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['sc_outra_jan']))
      {
          $this->sc_init_menu = "x";
          if (isset($_SESSION['scriptcase'][$_SESSION['scriptcase']['menu_atual']]['sc_init']['form_fiche_pro_sante_labo_edit']))
          {
              $this->sc_init_menu = $_SESSION['scriptcase'][$_SESSION['scriptcase']['menu_atual']]['sc_init']['form_fiche_pro_sante_labo_edit'];
          }
          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]['form_fiche_pro_sante_labo_edit']))
          {
               $_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['form_fiche_pro_sante_labo_edit']['link'] = $this->Ini->sc_protocolo . $this->Ini->server . $this->Ini->path_link . "" . SC_dir_app_name('form_fiche_pro_sante_labo_edit') . "/form_fiche_pro_sante_labo_edit.php";
               $_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['form_fiche_pro_sante_labo_edit']['label'] = "Fiche de déclaration de maladie";
               $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 == "form_fiche_pro_sante_labo_edit")
                  {
                      $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['code_fiche'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_code_fiche'] . '';
      $this->nm_new_label['date_declaration'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_declaration'] . '';
      $this->nm_new_label['structure'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_structure'] . '';
      $this->nm_new_label['maladie_suspectee_nm_fk'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_maladie_suspectee_nm_fk'] . '';
      $this->nm_new_label['commentaires'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commentaires'] . '';
      $this->nm_new_label['user_fk'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_user_fk'] . '';
      $this->nm_new_label['date_reception_prelevement'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_reception_prelevement'] . '';
      $this->nm_new_label['date_resultats_labo'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_resultats_labo'] . '';
      $this->nm_new_label['type_prelevement_nm_fk'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_type_prelevement_nm_fk'] . '';
      $this->nm_new_label['resultats_labo'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_resultats_labo'] . '';
      $this->nm_new_label['commentaires_labo'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commentaires_labo'] . '';
      $this->nm_new_label['attached_file'] = '' . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_attached_file'] . '';

      $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->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;
        if ($this->use_100perc_fields) {
            $this->classes_100perc_fields['table'] = ' sc-ui-100perc-table';
            $this->classes_100perc_fields['input'] = ' sc-ui-100perc-input';
            $this->classes_100perc_fields['span_input'] = ' sc-ui-100perc-span-input';
            $this->classes_100perc_fields['span_select'] = ' sc-ui-100perc-span-select';
            $this->classes_100perc_fields['style_category'] = ' style="width: 100%"';
            $this->classes_100perc_fields['keep_field_size'] = false;
        }


      $this->arr_buttons['retour']['hint']             = "";
      $this->arr_buttons['retour']['type']             = "button";
      $this->arr_buttons['retour']['value']            = "Retour";
      $this->arr_buttons['retour']['display']          = "text_fontawesomeicon";
      $this->arr_buttons['retour']['display_position'] = "text_right";
      $this->arr_buttons['retour']['style']            = "default";
      $this->arr_buttons['retour']['image']            = "";
      $this->arr_buttons['retour']['has_fa']            = "true";
      $this->arr_buttons['retour']['fontawesomeicon']            = "fas fa-undo-alt";


      $_SESSION['scriptcase']['error_icon']['form_fiche_pro_sante_labo_edit']  = "<img src=\"" . $this->Ini->path_icones . "/scriptcase__NM__btn__NM__scriptcase9_Lemon__NM__nm_scriptcase9_Lemon_error.png\" style=\"border-width: 0px\" align=\"top\">&nbsp;";
      $_SESSION['scriptcase']['error_close']['form_fiche_pro_sante_labo_edit'] = "<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]['form_fiche_pro_sante_labo_edit']['embutida_proc']) ? $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_proc'] : $this->Embutida_proc;
      $this->Embutida_form = isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_form']) ? $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_form'] : $this->Embutida_form;
      $this->Embutida_call = isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_call']) ? $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_call'] : $this->Embutida_call;

      $this->form_3versions_single = false;

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

      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit'])
      {
          $this->Grid_editavel = ('on' == $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['embutida_multi']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['embutida_liga_tp_pag']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_tp_pag'])
      {
          $this->form_paginacao = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_tp_pag'];
      }

      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_form']) || '' == $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_form'])
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_form'] = $this->Embutida_form;
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit']) || '' == $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit'])
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit'] = $this->Grid_editavel ? 'on' : 'off';
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit']) || '' == $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['embutida_liga_grid_edit'])
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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 . "form_fiche_pro_sante_labo_edit.php"; 
      $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']['attached_file_ul_name']) && '' != $this->NM_ajax_info['param']['attached_file_ul_name'])
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_field_ul_name'][$this->attached_file_ul_name]))
          {
              $this->NM_ajax_info['param']['attached_file_ul_name'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_field_ul_name'][$this->attached_file_ul_name];
          }
          $this->attached_file = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->NM_ajax_info['param']['attached_file_ul_name'];
          $this->attached_file_scfile_name = substr($this->NM_ajax_info['param']['attached_file_ul_name'], 12);
          $this->attached_file_scfile_type = $this->NM_ajax_info['param']['attached_file_ul_type'];
          $this->attached_file_ul_name = $this->NM_ajax_info['param']['attached_file_ul_name'];
          $this->attached_file_ul_type = $this->NM_ajax_info['param']['attached_file_ul_type'];
      }
      elseif (isset($this->attached_file_ul_name) && '' != $this->attached_file_ul_name)
      {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_field_ul_name'][$this->attached_file_ul_name]))
          {
              $this->attached_file_ul_name = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_field_ul_name'][$this->attached_file_ul_name];
          }
          $this->attached_file = $this->Ini->root . $this->Ini->path_imag_temp . '/' . $this->attached_file_ul_name;
          $this->attached_file_scfile_name = substr($this->attached_file_ul_name, 12);
          $this->attached_file_scfile_type = $this->attached_file_ul_type;
      }

      $this->loadFieldConfig();

      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['first_time'])
      {
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['insert']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['new']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['update']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['delete']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['first']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['back']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['forward']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['last']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['qsearch']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['dynsearch']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['summary']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['navpage']);
          unset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['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']['form_fiche_pro_sante_labo_edit']['insert']) || '' == $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['insert']))
      {
          if ('N' == $this->NM_btn_insert)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['insert'] = 'off';
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['insert'] = 'on';
          }
      }
      if (isset($this->NM_btn_new) && 'N' == $this->NM_btn_new)
      {
          $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['new'] = 'off';
      }
      if (isset($this->NM_btn_update) && '' != $this->NM_btn_update && (!isset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['update']) || '' == $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['update']))
      {
          if ('N' == $this->NM_btn_update)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['update'] = 'off';
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['update'] = 'on';
          }
      }
      if (isset($this->NM_btn_delete) && '' != $this->NM_btn_delete && (!isset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['delete']) || '' == $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['delete']))
      {
          if ('N' == $this->NM_btn_delete)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['delete'] = 'off';
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['delete'] = 'on';
          }
      }
      if (isset($this->NM_btn_navega) && '' != $this->NM_btn_navega)
      {
          if ('N' == $this->NM_btn_navega)
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['first']     = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['back']      = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['forward']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['last']      = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['qsearch']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['dynsearch'] = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['summary']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['navpage']   = 'off';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['goto']      = 'off';
              $this->Nav_permite_ava = false;
              $this->Nav_permite_ret = false;
          }
          else
          {
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['first']     = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['back']      = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['forward']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['last']      = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['qsearch']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['dynsearch'] = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['summary']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['navpage']   = 'on';
              $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['goto']      = 'on';
          }
      }

      $this->nmgp_botoes['cancel'] = "on";
      $this->nmgp_botoes['exit'] = "off";
      $this->nmgp_botoes['new']  = "off";
      $this->nmgp_botoes['copy'] = "off";
      $this->nmgp_botoes['insert'] = "off";
      $this->nmgp_botoes['update'] = "on";
      $this->nmgp_botoes['delete'] = "off";
      $this->nmgp_botoes['first'] = "off";
      $this->nmgp_botoes['back'] = "off";
      $this->nmgp_botoes['forward'] = "off";
      $this->nmgp_botoes['last'] = "off";
      $this->nmgp_botoes['summary'] = "off";
      $this->nmgp_botoes['navpage'] = "off";
      $this->nmgp_botoes['goto'] = "off";
      $this->nmgp_botoes['qtline'] = "off";
      $this->nmgp_botoes['reload'] = "off";
      $this->nmgp_botoes['retour'] = "on";
      if (isset($this->NM_btn_cancel) && 'N' == $this->NM_btn_cancel)
      {
          $this->nmgp_botoes['cancel'] = "off";
      }
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_orig'] = " where (code_fiche = '" . $_SESSION['var_code_fiche'] . "')";
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_pesq']))
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_pesq'] = " where (code_fiche = '" . $_SESSION['var_code_fiche'] . "')";
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_pesq_filtro'] = "";
      }
      $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_orig'];
      $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_pesq'];
      $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['buttonStatus'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['iframe_filtro']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['iframe_filtro'] == "S")
      {
          $this->nmgp_botoes['exit'] = "off";
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['btn_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['btn_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['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']['form_fiche_pro_sante_labo_edit']['insert']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['insert'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['insert'];
          $this->nmgp_botoes['insert'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['insert'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['new']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['new'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['new'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['update']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['update'] != '')
      {
          $this->nmgp_botoes['update'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['update'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['delete']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['delete'] != '')
      {
          $this->nmgp_botoes['delete'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['delete'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['first']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['first'] != '')
      {
          $this->nmgp_botoes['first'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['first'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['back']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['back'] != '')
      {
          $this->nmgp_botoes['back'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['back'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['forward']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['forward'] != '')
      {
          $this->nmgp_botoes['forward'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['forward'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['last']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['last'] != '')
      {
          $this->nmgp_botoes['last'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['last'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['qsearch']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['qsearch'] != '')
      {
          $this->nmgp_botoes['qsearch'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['qsearch'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['dynsearch']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['dynsearch'] != '')
      {
          $this->nmgp_botoes['dynsearch'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['dynsearch'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['summary']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['summary'] != '')
      {
          $this->nmgp_botoes['summary'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['summary'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['navpage']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['navpage'] != '')
      {
          $this->nmgp_botoes['navpage'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['navpage'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['goto']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['goto'] != '')
      {
          $this->nmgp_botoes['goto'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['form_fiche_pro_sante_labo_edit']['goto'];
      }

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

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

              $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']['form_fiche_pro_sante_labo_edit']['insert']) && $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['insert'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['insert'];
          $this->nmgp_botoes['insert'] = $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['insert'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['update']) && $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['update'] != '')
      {
          $this->nmgp_botoes['update'] = $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['update'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['delete']) && $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['delete'] != '')
      {
          $this->nmgp_botoes['delete'] = $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['delete'];
      }

      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['field_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['field_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['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']['form_fiche_pro_sante_labo_edit']['field_readonly']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['field_readonly']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['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']['form_fiche_pro_sante_labo_edit']['exit']) && $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['exit'] != '')
      {
          $_SESSION['scriptcase']['sc_url_saida'][$this->Ini->sc_page]       = $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['exit'];
          $_SESSION['scriptcase']['sc_force_url_saida'][$this->Ini->sc_page] = true;
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_form']))
      {
          $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_form'];
          if (!isset($this->id_fiche_ps)){$this->id_fiche_ps = $this->nmgp_dados_form['id_fiche_ps'];} 
          if ($this->nmgp_opcao == "incluir" && $this->nmgp_dados_form['code_fiche'] != "null"){$this->code_fiche = $this->nmgp_dados_form['code_fiche'];} 
          if ($this->nmgp_opcao == "incluir" && $this->nmgp_dados_form['date_declaration'] != "null"){
              $aDtParts = explode(' ', $this->nmgp_dados_form['date_declaration']);
              $this->date_declaration = $this->nm_conv_data_db($aDtParts[0], 'yyyy-mm-dd', $this->field_config['date_declaration']['date_format']);
              $this->date_declaration_hora = $aDtParts[1];
              $aDtParts = explode(';', $this->date_declaration);
              $this->date_declaration = $aDtParts[0];
          }
          if (!isset($this->wilaya)){$this->wilaya = $this->nmgp_dados_form['wilaya'];} 
          if (!isset($this->commune)){$this->commune = $this->nmgp_dados_form['commune'];} 
          if ($this->nmgp_opcao == "incluir" && $this->nmgp_dados_form['structure'] != "null"){$this->structure = $this->nmgp_dados_form['structure'];} 
          if (!isset($this->nom_rapporteur)){$this->nom_rapporteur = $this->nmgp_dados_form['nom_rapporteur'];} 
          if (!isset($this->tel_rapporteur)){$this->tel_rapporteur = $this->nmgp_dados_form['tel_rapporteur'];} 
          if (!isset($this->email_rapporteur)){$this->email_rapporteur = $this->nmgp_dados_form['email_rapporteur'];} 
          if (!isset($this->nom_malade)){$this->nom_malade = $this->nmgp_dados_form['nom_malade'];} 
          if (!isset($this->prenom_malade)){$this->prenom_malade = $this->nmgp_dados_form['prenom_malade'];} 
          if (!isset($this->date_naissance_malade)){$this->date_naissance_malade = $this->nmgp_dados_form['date_naissance_malade'];} 
          if (!isset($this->age_malade)){$this->age_malade = $this->nmgp_dados_form['age_malade'];} 
          if (!isset($this->sexe_nm_fk)){$this->sexe_nm_fk = $this->nmgp_dados_form['sexe_nm_fk'];} 
          if (!isset($this->profession_malade)){$this->profession_malade = $this->nmgp_dados_form['profession_malade'];} 
          if (!isset($this->adresse_malade)){$this->adresse_malade = $this->nmgp_dados_form['adresse_malade'];} 
          if (!isset($this->wilaya_malade)){$this->wilaya_malade = $this->nmgp_dados_form['wilaya_malade'];} 
          if (!isset($this->commune_malade)){$this->commune_malade = $this->nmgp_dados_form['commune_malade'];} 
          if (!isset($this->lieu_travail)){$this->lieu_travail = $this->nmgp_dados_form['lieu_travail'];} 
          if (!isset($this->tel_malade)){$this->tel_malade = $this->nmgp_dados_form['tel_malade'];} 
          if (!isset($this->email_malade)){$this->email_malade = $this->nmgp_dados_form['email_malade'];} 
          if (!isset($this->lieux_frequentes)){$this->lieux_frequentes = $this->nmgp_dados_form['lieux_frequentes'];} 
          if (!isset($this->date_apparition_symptomes)){$this->date_apparition_symptomes = $this->nmgp_dados_form['date_apparition_symptomes'];} 
          if (!isset($this->autres_symptomes)){$this->autres_symptomes = $this->nmgp_dados_form['autres_symptomes'];} 
          if (!isset($this->hospitalisation)){$this->hospitalisation = $this->nmgp_dados_form['hospitalisation'];} 
          if (!isset($this->date_hospitalisation)){$this->date_hospitalisation = $this->nmgp_dados_form['date_hospitalisation'];} 
          if (!isset($this->evacuation)){$this->evacuation = $this->nmgp_dados_form['evacuation'];} 
          if (!isset($this->date_evacuation)){$this->date_evacuation = $this->nmgp_dados_form['date_evacuation'];} 
          if (!isset($this->structure_evacuation)){$this->structure_evacuation = $this->nmgp_dados_form['structure_evacuation'];} 
          if (!isset($this->antecedent_medicaux)){$this->antecedent_medicaux = $this->nmgp_dados_form['antecedent_medicaux'];} 
          if (!isset($this->longitude)){$this->longitude = $this->nmgp_dados_form['longitude'];} 
          if (!isset($this->latitude)){$this->latitude = $this->nmgp_dados_form['latitude'];} 
          if (!isset($this->envoie)){$this->envoie = $this->nmgp_dados_form['envoie'];} 
          if (!isset($this->envoie_ack)){$this->envoie_ack = $this->nmgp_dados_form['envoie_ack'];} 
          if (!isset($this->valide)){$this->valide = $this->nmgp_dados_form['valide'];} 
          if (!isset($this->descr_invalidite)){$this->descr_invalidite = $this->nmgp_dados_form['descr_invalidite'];} 
          if ($this->nmgp_opcao == "incluir" && $this->nmgp_dados_form['user_fk'] != "null"){$this->user_fk = $this->nmgp_dados_form['user_fk'];} 
          if (!isset($this->validator_fk)){$this->validator_fk = $this->nmgp_dados_form['validator_fk'];} 
          if (!isset($this->mobile)){$this->mobile = $this->nmgp_dados_form['mobile'];} 
          if (!isset($this->evolution_nm_fk)){$this->evolution_nm_fk = $this->nmgp_dados_form['evolution_nm_fk'];} 
          if (!isset($this->symptomes)){$this->symptomes = $this->nmgp_dados_form['symptomes'];} 
          if (!isset($this->device_id)){$this->device_id = $this->nmgp_dados_form['device_id'];} 
          if (!isset($this->maladie_suspectee_by_ia)){$this->maladie_suspectee_by_ia = $this->nmgp_dados_form['maladie_suspectee_by_ia'];} 
          if (!isset($this->deleted)){$this->deleted = $this->nmgp_dados_form['deleted'];} 
          if (!isset($this->date_validation)){$this->date_validation = $this->nmgp_dados_form['date_validation'];} 
          if (!isset($this->user_labo_fk)){$this->user_labo_fk = $this->nmgp_dados_form['user_labo_fk'];} 
          if (!isset($this->date_confirmation_labo)){$this->date_confirmation_labo = $this->nmgp_dados_form['date_confirmation_labo'];} 
          if (!isset($this->maladie_confirmee_labo)){$this->maladie_confirmee_labo = $this->nmgp_dados_form['maladie_confirmee_labo'];} 
          if (!isset($this->statut_maladie)){$this->statut_maladie = $this->nmgp_dados_form['statut_maladie'];} 
          if (!isset($this->date_sortie)){$this->date_sortie = $this->nmgp_dados_form['date_sortie'];} 
          if (!isset($this->date_deces)){$this->date_deces = $this->nmgp_dados_form['date_deces'];} 
          if (!isset($this->date_prelevements)){$this->date_prelevements = $this->nmgp_dados_form['date_prelevements'];} 
          if (!isset($this->labo_destination)){$this->labo_destination = $this->nmgp_dados_form['labo_destination'];} 
          if (!isset($this->nin)){$this->nin = $this->nmgp_dados_form['nin'];} 
          if (!isset($this->commentaires_semep)){$this->commentaires_semep = $this->nmgp_dados_form['commentaires_semep'];} 
          if (!isset($this->statut_fiche)){$this->statut_fiche = $this->nmgp_dados_form['statut_fiche'];} 
          if (!isset($this->autre_evolution)){$this->autre_evolution = $this->nmgp_dados_form['autre_evolution'];} 
          if (!isset($this->cas_similaires)){$this->cas_similaires = $this->nmgp_dados_form['cas_similaires'];} 
          if (!isset($this->unite_age_nm_fk)){$this->unite_age_nm_fk = $this->nmgp_dados_form['unite_age_nm_fk'];} 
          if (!isset($this->pays_origine)){$this->pays_origine = $this->nmgp_dados_form['pays_origine'];} 
          if (!isset($this->nationalite_nm_fk)){$this->nationalite_nm_fk = $this->nmgp_dados_form['nationalite_nm_fk'];} 
          if (!isset($this->spacer1)){$this->spacer1 = $this->nmgp_dados_form['spacer1'];} 
          if (!isset($this->spacer2)){$this->spacer2 = $this->nmgp_dados_form['spacer2'];} 
      }
      $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("form_fiche_pro_sante_labo_edit", $apls_aba))
              {
                  $this->aba_iframe = true;
                  break;
              }
          }
      }
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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 . 'form_fiche_pro_sante_labo_edit/form_fiche_pro_sante_labo_edit_calendar.php');
          }
          else
          { 
              include_once($this->Ini->path_aplicacao . 'form_fiche_pro_sante_labo_edit_calendar.php');
          }
          exit;
      }

      if (is_file($this->Ini->path_aplicacao . 'form_fiche_pro_sante_labo_edit_help.txt'))
      {
          $arr_link_webhelp = file($this->Ini->path_aplicacao . 'form_fiche_pro_sante_labo_edit_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 . 'form_fiche_pro_sante_labo_edit/form_fiche_pro_sante_labo_edit_erro.class.php');
      }
      else
      { 
          require_once($this->Ini->path_aplicacao . "form_fiche_pro_sante_labo_edit_erro.class.php"); 
      }
      $this->Erro      = new form_fiche_pro_sante_labo_edit_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]['form_fiche_pro_sante_labo_edit']['opcao']))
         { 
             if ($this->id_fiche_ps != "")   
             { 
                 $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opcao'] = "igual" ;  
             }   
         }   
      } 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opcao']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opcao']) && empty($this->nmgp_refresh_fields))
      {
          $this->nmgp_opcao = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opcao'];  
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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']['form_fiche_pro_sante_labo_edit']['start']) && $_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['start'] == 'new')
      {
          $this->nmgp_opcao = "novo";
          $this->nm_Start_new = true;
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opcao'] = "novo";
          unset($_SESSION['scriptcase']['sc_apl_conf']['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['opc_ant'])) ? $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opc_ant'] : "";
      } 
      if ($this->nmgp_opcao == "novo")  
      {
          $this->nmgp_botoes['retour'] = "off";
      }
      elseif ($this->nmgp_opcao == "incluir")  
      {
          $this->nmgp_botoes['retour'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['botoes']['retour'];
      }
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "muda_form")  
      {
          $this->nmgp_botoes = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['botoes'];
          $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['inicio'];
          $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['total'] != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['final'];
      }
      else
      {
      }
      $this->nm_flag_iframe = false;
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_form'])) 
      {
         $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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;
      if (!isset($this->NM_ajax_flag) || ('validate_' != substr($this->NM_ajax_opcao, 0, 9) && 'add_new_line' != $this->NM_ajax_opcao && 'autocomp_' != substr($this->NM_ajax_opcao, 0, 9)))
      {
      $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  $this->init_fields_script_init();
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off'; 
      }
            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']['form_fiche_pro_sante_labo_edit']['glo_nm_path_imag_temp'] . $file_name;
            $orig_img = $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['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->createImg($_SERVER['DOCUMENT_ROOT'].$out1_img_cache);
            echo $out1_img_cache;
               exit;
            }
      if (isset($this->code_fiche)) { $this->nm_limpa_alfa($this->code_fiche); }
      if (isset($this->structure)) { $this->nm_limpa_alfa($this->structure); }
      if (isset($this->maladie_suspectee_nm_fk)) { $this->nm_limpa_alfa($this->maladie_suspectee_nm_fk); }
      if (isset($this->commentaires)) { $this->nm_limpa_alfa($this->commentaires); }
      if (isset($this->user_fk)) { $this->nm_limpa_alfa($this->user_fk); }
      if (isset($this->type_prelevement_nm_fk)) { $this->nm_limpa_alfa($this->type_prelevement_nm_fk); }
      if (isset($this->resultats_labo)) { $this->nm_limpa_alfa($this->resultats_labo); }
      if (isset($this->commentaires_labo)) { $this->nm_limpa_alfa($this->commentaires_labo); }
      if (isset($nm_opc_lookup) && $nm_opc_lookup == "lookup")
      { 
          if ($GLOBALS['F'] == "structure")
          { 
              $nm_parms   = substr($GLOBALS['P0'], 1, strlen($GLOBALS['P0']) - 2);
              $array_vars = explode(",", $nm_parms);
              $this->structure = $array_vars[0];
              $structure       = $this->structure;
              $this->structure       = $structure;
              $this->lookup_structure($conteudo);
              $conteudo = str_replace("&", "&amp;", $conteudo); 
              $conteudo = str_replace("\/" , "\/", $conteudo); 
              echo "<html><head></head>";
              echo " <body onload=\"p=document.layers?parentLayer:window.parent;p.jsrsLoaded('" . $GLOBALS['C'] . "');\">";
              echo "  jsrsPayload:";
              echo "  <br>";
              echo "  <form name=\"jsrs_Form\"><textarea name=\"jsrs_Payload\">";
              echo "$conteudo";
              echo " </textarea></form></body></html>";
          } 
          if ($GLOBALS['F'] == "user_fk")
          { 
              $nm_parms   = substr($GLOBALS['P0'], 1, strlen($GLOBALS['P0']) - 2);
              $array_vars = explode(",", $nm_parms);
              $this->user_fk = $array_vars[0];
              $user_fk       = $this->user_fk;
              $this->user_fk       = $user_fk;
              $this->lookup_user_fk($conteudo);
              $conteudo = str_replace("&", "&amp;", $conteudo); 
              $conteudo = str_replace("\/" , "\/", $conteudo); 
              echo "<html><head></head>";
              echo " <body onload=\"p=document.layers?parentLayer:window.parent;p.jsrsLoaded('" . $GLOBALS['C'] . "');\">";
              echo "  jsrsPayload:";
              echo "  <br>";
              echo "  <form name=\"jsrs_Form\"><textarea name=\"jsrs_Payload\">";
              echo "$conteudo";
              echo " </textarea></form></body></html>";
          } 
          $this->NM_close_db(); 
          exit;
      } 
      $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]['form_fiche_pro_sante_labo_edit']['Field_no_validate'])) ? $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Field_no_validate'] : array();
      $this->nm_location = $this->Ini->sc_protocolo . $this->Ini->server . $dir_raiz . "form_fiche_pro_sante_labo_edit.php"; 
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opc_edit'] = true;  
     if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select'])) 
     {
        $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select'];
     }
   }

   function loadFieldConfig()
   {
      $this->field_config = array();
      //-- date_declaration
      $this->field_config['date_declaration']                 = array();
      $this->field_config['date_declaration']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'] . ';' . $_SESSION['scriptcase']['reg_conf']['time_format'];
      $this->field_config['date_declaration']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_declaration']['time_sep']     = $_SESSION['scriptcase']['reg_conf']['time_sep'];
      $this->field_config['date_declaration']['date_display'] = "ddmmaaaa;hhii";
      $this->new_date_format('DH', 'date_declaration');
      //-- date_reception_prelevement
      $this->field_config['date_reception_prelevement']                 = array();
      $this->field_config['date_reception_prelevement']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_reception_prelevement']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_reception_prelevement']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_reception_prelevement');
      //-- date_resultats_labo
      $this->field_config['date_resultats_labo']                 = array();
      $this->field_config['date_resultats_labo']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_resultats_labo']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_resultats_labo']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_resultats_labo');
      //-- id_fiche_ps
      $this->field_config['id_fiche_ps']               = array();
      $this->field_config['id_fiche_ps']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['id_fiche_ps']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['id_fiche_ps']['symbol_dec'] = '';
      $this->field_config['id_fiche_ps']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['id_fiche_ps']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- date_naissance_malade
      $this->field_config['date_naissance_malade']                 = array();
      $this->field_config['date_naissance_malade']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_naissance_malade']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_naissance_malade']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_naissance_malade');
      //-- age_malade
      $this->field_config['age_malade']               = array();
      $this->field_config['age_malade']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['age_malade']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['age_malade']['symbol_dec'] = '';
      $this->field_config['age_malade']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['age_malade']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- date_apparition_symptomes
      $this->field_config['date_apparition_symptomes']                 = array();
      $this->field_config['date_apparition_symptomes']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_apparition_symptomes']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_apparition_symptomes']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_apparition_symptomes');
      //-- date_hospitalisation
      $this->field_config['date_hospitalisation']                 = array();
      $this->field_config['date_hospitalisation']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_hospitalisation']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_hospitalisation']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_hospitalisation');
      //-- date_evacuation
      $this->field_config['date_evacuation']                 = array();
      $this->field_config['date_evacuation']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_evacuation']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_evacuation']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_evacuation');
      //-- longitude
      $this->field_config['longitude']               = array();
      $this->field_config['longitude']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['longitude']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['longitude']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['longitude']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['longitude']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- latitude
      $this->field_config['latitude']               = array();
      $this->field_config['latitude']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['latitude']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['latitude']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['latitude']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['latitude']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- date_validation
      $this->field_config['date_validation']                 = array();
      $this->field_config['date_validation']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'] . ';' . $_SESSION['scriptcase']['reg_conf']['time_format'];
      $this->field_config['date_validation']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_validation']['time_sep']     = $_SESSION['scriptcase']['reg_conf']['time_sep'];
      $this->field_config['date_validation']['date_display'] = "ddmmaaaa;hhiiss";
      $this->new_date_format('DH', 'date_validation');
      //-- date_confirmation_labo
      $this->field_config['date_confirmation_labo']                 = array();
      $this->field_config['date_confirmation_labo']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'] . ';' . $_SESSION['scriptcase']['reg_conf']['time_format'];
      $this->field_config['date_confirmation_labo']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_confirmation_labo']['time_sep']     = $_SESSION['scriptcase']['reg_conf']['time_sep'];
      $this->field_config['date_confirmation_labo']['date_display'] = "ddmmaaaa;hhiiss";
      $this->new_date_format('DH', 'date_confirmation_labo');
      //-- date_sortie
      $this->field_config['date_sortie']                 = array();
      $this->field_config['date_sortie']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_sortie']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_sortie']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_sortie');
      //-- date_deces
      $this->field_config['date_deces']                 = array();
      $this->field_config['date_deces']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_deces']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_deces']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_deces');
      //-- date_prelevements
      $this->field_config['date_prelevements']                 = array();
      $this->field_config['date_prelevements']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date_prelevements']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date_prelevements']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date_prelevements');
   }

   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['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Gera_log_access'])
      {
          $this->NM_gera_log_insert("Scriptcase", "access");
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Gera_log_access'] = false;
      }

      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)
      {
      }
//
//-----> 
//
      if ($this->NM_ajax_flag && 'validate_' == substr($this->NM_ajax_opcao, 0, 9))
      {
          if ('validate_code_fiche' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'code_fiche');
          }
          if ('validate_date_declaration' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'date_declaration');
          }
          if ('validate_structure' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'structure');
          }
          if ('validate_user_fk' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'user_fk');
          }
          if ('validate_maladie_suspectee_nm_fk' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'maladie_suspectee_nm_fk');
          }
          if ('validate_type_prelevement_nm_fk' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'type_prelevement_nm_fk');
          }
          if ('validate_date_reception_prelevement' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'date_reception_prelevement');
          }
          if ('validate_date_resultats_labo' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'date_resultats_labo');
          }
          if ('validate_resultats_labo' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'resultats_labo');
          }
          if ('validate_attached_file' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'attached_file');
          }
          if ('validate_commentaires' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'commentaires');
          }
          if ('validate_commentaires_labo' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'commentaires_labo');
          }
          form_fiche_pro_sante_labo_edit_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_evacuation_onclick' == $this->NM_ajax_opcao)
          {
              $this->evacuation_onClick();
          }
          if ('event_evolution_nm_fk_onclick' == $this->NM_ajax_opcao)
          {
              $this->evolution_nm_fk_onClick();
          }
          if ('event_hospitalisation_onclick' == $this->NM_ajax_opcao)
          {
              $this->hospitalisation_onClick();
          }
          form_fiche_pro_sante_labo_edit_pack_ajax_response();
          exit;
      }
      if (isset($this->sc_inline_call) && 'Y' == $this->sc_inline_call)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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") 
      {
          if (is_array($this->symptomes))
          {
              $x = 0; 
              $this->symptomes_1 = $this->symptomes;
              $this->symptomes = ""; 
              if ($this->symptomes_1 != "") 
              { 
                  foreach ($this->symptomes_1 as $dados_symptomes_1 ) 
                  { 
                      if ($x != 0)
                      { 
                          $this->symptomes .= ";";
                      } 
                      $this->symptomes .= $dados_symptomes_1;
                      $x++ ; 
                  } 
              } 
          } 
          if (is_array($this->type_prelevement_nm_fk))
          {
              $x = 0; 
              $this->type_prelevement_nm_fk_1 = $this->type_prelevement_nm_fk;
              $this->type_prelevement_nm_fk = ""; 
              if ($this->type_prelevement_nm_fk_1 != "") 
              { 
                  foreach ($this->type_prelevement_nm_fk_1 as $dados_type_prelevement_nm_fk_1 ) 
                  { 
                      if ($x != 0)
                      { 
                          $this->type_prelevement_nm_fk .= ";";
                      } 
                      $this->type_prelevement_nm_fk .= $dados_type_prelevement_nm_fk_1;
                      $x++ ; 
                  } 
              } 
          } 
          $this->upload_img_doc($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['code_fiche']) && !isset($this->nmgp_refresh_fields))
          { 
              $this->code_fiche = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['code_fiche'];
          } 
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['date_declaration']) && !isset($this->nmgp_refresh_fields))
          { 
              $this->date_declaration = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['date_declaration'];
          } 
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['structure']) && !isset($this->nmgp_refresh_fields))
          { 
              $this->structure = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['structure'];
          } 
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['user_fk']) && !isset($this->nmgp_refresh_fields))
          { 
              $this->user_fk = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']['user_fk'];
          } 
          $nm_sc_sv_opcao = $this->nmgp_opcao; 
          $this->nmgp_opcao = "nada"; 
          $this->nm_acessa_banco();
          if ($this->NM_ajax_flag)
          {
              $this->ajax_return_values();
              form_fiche_pro_sante_labo_edit_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->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['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)
              {
                  form_fiche_pro_sante_labo_edit_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]['form_fiche_pro_sante_labo_edit']['recarga'] = $this->nmgp_opcao;
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['sc_redir_insert']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['sc_redir_atualiz']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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();
          form_fiche_pro_sante_labo_edit_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']);
          }
          form_fiche_pro_sante_labo_edit_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 ?>);
     parent.writeFastMenu(link_atual);
  </script>
<?php
          }
          else
          {
?>
  <script type="text/javascript">
     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) . "form_fiche_pro_sante_labo_edit.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]['form_fiche_pro_sante_labo_edit'][$path_doc_md5][0] = $Arq_htm;
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit'][$path_doc_md5][1] = $Zip_name;
?>
<HTML<?php echo $_SESSION['scriptcase']['reg_conf']['html_dir'] ?>>
<HEAD>
 <TITLE><?php echo strip_tags("Fiche de déclaration de maladie") ?></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/css/all.min.css" /> 
  <link rel="shortcut icon" href="../_lib/img/sys__NM__img__NM__emergency_2785811.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="form_fiche_pro_sante_labo_edit_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="form_fiche_pro_sante_labo_edit"> 
<input type="hidden" name="nm_name_doc" value="<?php echo $path_doc_md5 ?>"> 
</form>
<form name="F0" method=post action="form_fiche_pro_sante_labo_edit.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;
       } 
       if ($this->SC_log_atv)
       {
           $this->NM_gera_log_output();
       }
   }
//
//--------------------------------------------------------------------------------------
   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_gera_log_insert($orig="Scriptcase", $evento="", $texto="")
   {
       $delim  = "'";
       $delim1 = "'";
       if (in_array(strtolower($_SESSION['scriptcase']['glo_tpbanco']), $this->Ini->nm_bases_access))
       { 
           $delim  = "#";
           $delim1 = "#";
       } 
       if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['SC_sep_date']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['SC_sep_date']))
       {
           $delim  = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['SC_sep_date'];
           $delim1 = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['SC_sep_date1'];
       }
       $dt  = $delim . date('Y-m-d H:i:s') . $delim1;
       $usr = isset($_SESSION['usr_login']) ? $_SESSION['usr_login'] : "";
       if (strtolower($_SESSION['scriptcase']['glo_tpbanco']) == 'pdo_sqlsrv' || strtolower($_SESSION['scriptcase']['glo_tpbanco']) == 'pdo_dblib')
       { 
           $dt  = $delim . date('Ymd H:i:s') . $delim1;
       } 
       if (in_array(strtolower($_SESSION['scriptcase']['glo_tpbanco']), $this->Ini->nm_bases_access))
       { 
           $dt  = $delim . date('Y-m-d H:i:s') . $delim1;
       } 
       if (in_array(strtolower($_SESSION['scriptcase']['glo_tpbanco']), $this->Ini->nm_bases_informix))
       { 
           $dt  = "EXTEND(" . $dt . ", YEAR TO FRACTION)";
       } 
       if (in_array(strtolower($_SESSION['scriptcase']['glo_tpbanco']), $this->Ini->nm_bases_access))
       { 
           $comando = "INSERT INTO sc_log (inserted_date, username, application, creator, ip_user, `action`, description) VALUES ($dt, " . $this->Db->qstr($usr) . ", 'form_fiche_pro_sante_labo_edit', '$orig', '" . $_SERVER['REMOTE_ADDR'] . "', '$evento', " . $this->Db->qstr($texto) . ")"; 
       } 
       elseif (in_array(strtolower($_SESSION['scriptcase']['glo_tpbanco']), $this->Ini->nm_bases_sqlite))
       { 
           $comando = "INSERT INTO sc_log (id, inserted_date, username, application, creator, ip_user, action, description) VALUES (NULL, $dt, " . $this->Db->qstr($usr) . ", 'form_fiche_pro_sante_labo_edit', '$orig', '" . $_SERVER['REMOTE_ADDR'] . "', '$evento', " . $this->Db->qstr($texto) . ")"; 
       } 
       else
       { 
           $comando = "INSERT INTO sc_log (inserted_date, username, application, creator, ip_user, action, description) VALUES ($dt, " . $this->Db->qstr($usr) . ", 'form_fiche_pro_sante_labo_edit', '$orig', '" . $_SERVER['REMOTE_ADDR'] . "', '$evento', " . $this->Db->qstr($texto) . ")"; 
       } 
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $comando; 
       $rlog = $this->Db->Execute($comando); 
       if ($rlog === false)  
       { 
           $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_inst'], $this->Db->ErrorMsg()); 
           if ($this->NM_ajax_flag)
           {
               form_fiche_pro_sante_labo_edit_pack_ajax_response();
               exit; 
           }
       }
   }
//
//--------------------------------------------------------------------------------------
   function NM_close_db()
   {
       if ($this->Db && !$this->Embutida_proc)
       { 
           $this->Db->Close(); 
       } 
   }
//
//--------------------------------------------------------------------------------------
   function lookup_structure(&$conteudo)
   {
      global  $structure;
      $guarda_formatado = $this->formatado;
      $this->nm_tira_formatacao();
      $Salva_opc = $this->nmgp_opcao;
      $this->nmgp_opcao = "lookup_rpc";
      $this->nm_converte_datas();
      $this->nmgp_opcao = $Salva_opc;
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
      { 
          $GLOBALS["NM_ERRO_IBASE"] = 1;  
      } 
      $nm_comando = "SELECT nom_structure 
FROM \"public\".structures_sante 
WHERE code_structure = '$this->structure' 
ORDER BY nom_structure"; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rs = $this->Db->Execute($nm_comando)) 
      {
          $conteudo = (isset($rs->fields[0])) ? $rs->fields[0] : ""; 
          $rs->Close() ; 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      {  
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      $GLOBALS["NM_ERRO_IBASE"] = 0; 
      foreach ($this->Before_unformat as $Cmp => $Val)
      {
          $this->$Cmp = $Val;
          $this->formatado = $guarda_formatado;
      }
   }
//
//--------------------------------------------------------------------------------------
   function lookup_user_fk(&$conteudo)
   {
      global  $user_fk;
      $guarda_formatado = $this->formatado;
      $this->nm_tira_formatacao();
      $Salva_opc = $this->nmgp_opcao;
      $this->nmgp_opcao = "lookup_rpc";
      $this->nm_converte_datas();
      $this->nmgp_opcao = $Salva_opc;
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
      { 
          $GLOBALS["NM_ERRO_IBASE"] = 1;  
      } 
      $nm_comando = "SELECT concat (\"name\" , ' - ' , tel)
FROM \"public\".sec_users 
WHERE login = '$this->user_fk' 
ORDER BY \"name\""; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      if ($rs = $this->Db->Execute($nm_comando)) 
      {
          $conteudo = (isset($rs->fields[0])) ? $rs->fields[0] : ""; 
          $rs->Close() ; 
      } 
      elseif ($GLOBALS["NM_ERRO_IBASE"] != 1)  
      {  
          $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
          exit; 
      } 
      $GLOBALS["NM_ERRO_IBASE"] = 0; 
      foreach ($this->Before_unformat as $Cmp => $Val)
      {
          $this->$Cmp = $Val;
          $this->formatado = $guarda_formatado;
      }
   }
//
//--------------------------------------------------------------------------------------
   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 'code_fiche':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_code_fiche'] . "";
               break;
           case 'date_declaration':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_declaration'] . "";
               break;
           case 'structure':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_structure'] . "";
               break;
           case 'user_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_user_fk'] . "";
               break;
           case 'maladie_suspectee_nm_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_maladie_suspectee_nm_fk'] . "";
               break;
           case 'type_prelevement_nm_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_type_prelevement_nm_fk'] . "";
               break;
           case 'date_reception_prelevement':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_reception_prelevement'] . "";
               break;
           case 'date_resultats_labo':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_resultats_labo'] . "";
               break;
           case 'resultats_labo':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_resultats_labo'] . "";
               break;
           case 'attached_file':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_attached_file'] . "";
               break;
           case 'commentaires':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commentaires'] . "";
               break;
           case 'commentaires_labo':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commentaires_labo'] . "";
               break;
           case 'id_fiche_ps':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_id_fiche_ps'] . "";
               break;
           case 'wilaya':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_wilaya'] . "";
               break;
           case 'commune':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commune'] . "";
               break;
           case 'nom_rapporteur':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_nom_rapporteur'] . "";
               break;
           case 'tel_rapporteur':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_tel_rapporteur'] . "";
               break;
           case 'email_rapporteur':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_email_rapporteur'] . "";
               break;
           case 'nom_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_nom_malade'] . "";
               break;
           case 'prenom_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_prenom_malade'] . "";
               break;
           case 'date_naissance_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_naissance_malade'] . "";
               break;
           case 'age_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_age_malade'] . "";
               break;
           case 'sexe_nm_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_sexe_nm_fk'] . "";
               break;
           case 'profession_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_profession_malade'] . "";
               break;
           case 'adresse_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_adresse_malade'] . "";
               break;
           case 'wilaya_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_wilaya_malade'] . "";
               break;
           case 'commune_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commune_malade'] . "";
               break;
           case 'lieu_travail':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_lieu_travail'] . "";
               break;
           case 'tel_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_tel_malade'] . "";
               break;
           case 'email_malade':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_email_malade'] . "";
               break;
           case 'lieux_frequentes':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_lieux_frequentes'] . "";
               break;
           case 'date_apparition_symptomes':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_apparition_symptomes'] . "";
               break;
           case 'autres_symptomes':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_autres_symptomes'] . "";
               break;
           case 'hospitalisation':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_hospitalisation'] . "";
               break;
           case 'date_hospitalisation':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_hospitalisation'] . "";
               break;
           case 'evacuation':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_evacuation'] . "";
               break;
           case 'date_evacuation':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_evacuation'] . "";
               break;
           case 'structure_evacuation':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_structure_evacuation'] . "";
               break;
           case 'antecedent_medicaux':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_antecedent_medicaux'] . "";
               break;
           case 'longitude':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_longitude'] . "";
               break;
           case 'latitude':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_latitude'] . "";
               break;
           case 'envoie':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_envoie'] . "";
               break;
           case 'envoie_ack':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_envoie_ack'] . "";
               break;
           case 'valide':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_valide'] . "";
               break;
           case 'descr_invalidite':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_descr_invalidite'] . "";
               break;
           case 'validator_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_validator_fk'] . "";
               break;
           case 'mobile':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_mobile'] . "";
               break;
           case 'evolution_nm_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_evolution_nm_fk'] . "";
               break;
           case 'symptomes':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_symptomes'] . "";
               break;
           case 'device_id':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_device_id'] . "";
               break;
           case 'maladie_suspectee_by_ia':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_maladie_suspectee_by_ia'] . "";
               break;
           case 'deleted':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_deleted'] . "";
               break;
           case 'date_validation':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_validation'] . "";
               break;
           case 'user_labo_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_user_labo_fk'] . "";
               break;
           case 'date_confirmation_labo':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_confirmation_labo'] . "";
               break;
           case 'maladie_confirmee_labo':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_maladie_confirmee_labo'] . "";
               break;
           case 'statut_maladie':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_statut_maladie'] . "";
               break;
           case 'date_sortie':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_sortie'] . "";
               break;
           case 'date_deces':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_deces'] . "";
               break;
           case 'date_prelevements':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_prelevements'] . "";
               break;
           case 'labo_destination':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_labo_destination'] . "";
               break;
           case 'nin':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_nin'] . "";
               break;
           case 'commentaires_semep':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commentaires_semep'] . "";
               break;
           case 'statut_fiche':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_statut_fiche'] . "";
               break;
           case 'autre_evolution':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_autre_evolution'] . "";
               break;
           case 'cas_similaires':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_cas_similaires'] . "";
               break;
           case 'unite_age_nm_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_unite_age_nm_fk'] . "";
               break;
           case 'pays_origine':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_pays_origine'] . "";
               break;
           case 'nationalite_nm_fk':
               return "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_nationalite_nm_fk'] . "";
               break;
           case 'spacer1':
               return "";
               break;
           case 'spacer2':
               return "";
               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_form_fiche_pro_sante_labo_edit']) || !is_array($this->NM_ajax_info['errList']['geral_form_fiche_pro_sante_labo_edit']))
              {
                  $this->NM_ajax_info['errList']['geral_form_fiche_pro_sante_labo_edit'] = array();
              }
              $this->NM_ajax_info['errList']['geral_form_fiche_pro_sante_labo_edit'][] = "CSRF: " . $this->Ini->Nm_lang['lang_errm_ajax_csrf'];
          }
     }
      if ((!is_array($filtro) && ('' == $filtro || 'code_fiche' == $filtro)) || (is_array($filtro) && in_array('code_fiche', $filtro)))
        $this->ValidateField_code_fiche($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'date_declaration' == $filtro)) || (is_array($filtro) && in_array('date_declaration', $filtro)))
        $this->ValidateField_date_declaration($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'structure' == $filtro)) || (is_array($filtro) && in_array('structure', $filtro)))
        $this->ValidateField_structure($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'user_fk' == $filtro)) || (is_array($filtro) && in_array('user_fk', $filtro)))
        $this->ValidateField_user_fk($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'maladie_suspectee_nm_fk' == $filtro)) || (is_array($filtro) && in_array('maladie_suspectee_nm_fk', $filtro)))
        $this->ValidateField_maladie_suspectee_nm_fk($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'type_prelevement_nm_fk' == $filtro)) || (is_array($filtro) && in_array('type_prelevement_nm_fk', $filtro)))
        $this->ValidateField_type_prelevement_nm_fk($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'date_reception_prelevement' == $filtro)) || (is_array($filtro) && in_array('date_reception_prelevement', $filtro)))
        $this->ValidateField_date_reception_prelevement($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'date_resultats_labo' == $filtro)) || (is_array($filtro) && in_array('date_resultats_labo', $filtro)))
        $this->ValidateField_date_resultats_labo($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'resultats_labo' == $filtro)) || (is_array($filtro) && in_array('resultats_labo', $filtro)))
        $this->ValidateField_resultats_labo($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'attached_file' == $filtro)) || (is_array($filtro) && in_array('attached_file', $filtro)))
        $this->ValidateField_attached_file($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'commentaires' == $filtro)) || (is_array($filtro) && in_array('commentaires', $filtro)))
        $this->ValidateField_commentaires($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ((!is_array($filtro) && ('' == $filtro || 'commentaires_labo' == $filtro)) || (is_array($filtro) && in_array('commentaires_labo', $filtro)))
        $this->ValidateField_commentaires_labo($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']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_attached_file = $this->attached_file;
    $original_date_reception_prelevement = $this->date_reception_prelevement;
    $original_date_resultats_labo = $this->date_resultats_labo;
    $original_resultats_labo = $this->resultats_labo;
}
  if (!(empty($this->date_prelevements ) || $this->date_prelevements  == "null")){
	
	$a = $this->nm_data->Dif_Datas($this->date_prelevements , "yyyy-mm-dd", $this->date_reception_prelevement , "yyyy-mm-dd");	
	
	if ($a>0){

			$error_message = 'Date de réception des prélèvements doit être supérieure ou égale à la date des prélèvements'; 
			
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= $error_message;
 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_form_fiche_pro_sante_labo_edit';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_form_fiche_pro_sante_labo_edit';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = $error_message;
 }
;
			if (isset($this->Campos_Mens_erro) && !empty($this->Campos_Mens_erro))
{
    if ($this->NM_ajax_flag)
    {
        $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
        form_fiche_pro_sante_labo_edit_pack_ajax_response();
        exit;
    }
    $Sc_Lixo = ob_get_clean();
    $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro);
    $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
    $this->Campos_Mens_erro = "";
    if ($this->nmgp_opcao == "incluir") {$this->nmgp_opcao = "novo";};
    $this->nm_proc_onload();
    $this->nm_formatar_campos();
    $this->nm_gera_html();
    $this->NM_close_db();
    exit;
}
}
	
}

$a = $this->nm_data->Dif_Datas($this->date_reception_prelevement , "yyyy-mm-dd", $this->date_resultats_labo , "yyyy-mm-dd");	

if ($a>0){

		$error_message = 'Date du résultat doit être supérieure ou égale à la date de réception des prélèvements';
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= $error_message;
 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_form_fiche_pro_sante_labo_edit';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_form_fiche_pro_sante_labo_edit';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = $error_message;
 }
;
		if (isset($this->Campos_Mens_erro) && !empty($this->Campos_Mens_erro))
{
    if ($this->NM_ajax_flag)
    {
        $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
        form_fiche_pro_sante_labo_edit_pack_ajax_response();
        exit;
    }
    $Sc_Lixo = ob_get_clean();
    $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro);
    $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
    $this->Campos_Mens_erro = "";
    if ($this->nmgp_opcao == "incluir") {$this->nmgp_opcao = "novo";};
    $this->nm_proc_onload();
    $this->nm_formatar_campos();
    $this->nm_gera_html();
    $this->NM_close_db();
    exit;
}
}

if (empty($this->resultats_labo ) && empty($this->attached_file )){
	
		$error_message = 'Au moins l’un des deux champs doit être renseigné: -Résultat- ou -Fichier joint- ';
		
 if (!isset($this->Campos_Mens_erro)){$this->Campos_Mens_erro = "";}
 if (!empty($this->Campos_Mens_erro)){$this->Campos_Mens_erro .= "<br>";}$this->Campos_Mens_erro .= $error_message;
 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_form_fiche_pro_sante_labo_edit';
  } elseif ('submit_form' == $this->NM_ajax_opcao) {
   $sErrorIndex = 'geral_form_fiche_pro_sante_labo_edit';
  } else {
   $sErrorIndex = substr(substr($this->NM_ajax_opcao, 0, strrpos($this->NM_ajax_opcao, '_')), 6);
  }
  $this->NM_ajax_info['errList'][$sErrorIndex][] = $error_message;
 }
;
		if (isset($this->Campos_Mens_erro) && !empty($this->Campos_Mens_erro))
{
    if ($this->NM_ajax_flag)
    {
        $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
        form_fiche_pro_sante_labo_edit_pack_ajax_response();
        exit;
    }
    $Sc_Lixo = ob_get_clean();
    $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro);
    $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
    $this->Campos_Mens_erro = "";
    if ($this->nmgp_opcao == "incluir") {$this->nmgp_opcao = "novo";};
    $this->nm_proc_onload();
    $this->nm_formatar_campos();
    $this->nm_gera_html();
    $this->NM_close_db();
    exit;
}
}
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_attached_file != $this->attached_file || (isset($bFlagRead_attached_file) && $bFlagRead_attached_file)))
    {
        $this->ajax_return_values_attached_file(true);
    }
    if (($original_date_reception_prelevement != $this->date_reception_prelevement || (isset($bFlagRead_date_reception_prelevement) && $bFlagRead_date_reception_prelevement)))
    {
        $this->ajax_return_values_date_reception_prelevement(true);
    }
    if (($original_date_resultats_labo != $this->date_resultats_labo || (isset($bFlagRead_date_resultats_labo) && $bFlagRead_date_resultats_labo)))
    {
        $this->ajax_return_values_date_resultats_labo(true);
    }
    if (($original_resultats_labo != $this->resultats_labo || (isset($bFlagRead_resultats_labo) && $bFlagRead_resultats_labo)))
    {
        $this->ajax_return_values_resultats_labo(true);
    }
}
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['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]);
              }
          }
      }

      if (empty($Campos_Crit) && empty($Campos_Falta) && empty($this->Campos_Mens_erro))
      {
          if (!isset($this->NM_ajax_flag) || 'validate_' != substr($this->NM_ajax_opcao, 0, 9))
          {
              $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_code_fiche = $this->code_fiche;
    $original_maladie_suspectee_nm_fk = $this->maladie_suspectee_nm_fk;
    $original_resultats_labo = $this->resultats_labo;
    $original_structure = $this->structure;
    $original_user_fk = $this->user_fk;
}
if (!isset($this->sc_temp_usr_nfac)) {$this->sc_temp_usr_nfac = (isset($_SESSION['usr_nfac'])) ? $_SESSION['usr_nfac'] : "";}
  if ($this->nmgp_dados_form['resultats_labo'] != $this->resultats_labo && !empty($this->structure )) {
	
	
	$fa = $this->structure ;
	$_users_array = $this->get_semep_users_of_facility($fa);
	
	$this->push_api_log('debug-users-epsp', implode(',',$_users_array));
	
	
	$nfac = $this->sc_temp_usr_nfac;
	
	
	
	
	$us = $this->user_fk ;
	$co = $this->code_fiche ;
	
	$st = $this->statut_maladie ;
	$rl = $this->resultats_labo ;
	
	$ma = $this->maladie_suspectee_nm_fk ;
	
	
	$maladie = $this->get_nmc($ma);
	
	$statut = '';
	
	switch ($st){
		
		case 'S': 
				
			$statut = "Cas suspect";
			
			break;
		
		case 'C': 
			
			$statut = "Cas confirmé";
			break;
		
		case 'I': 
			$statut = "Cas infirmé";
			break;
			
			
	}
	
	
	
	$_subject = 'Renseignement des résultats d’analyse';
	
	
	foreach($_users_array as $u){
	
		$us_name = $this->get_name_of_user($us);
		$_excerpt = "Le laboratoire $nfac a rendu les résultats d’analyse pour la fiche $co. ".PHP_EOL."Maladie suspectée: $maladie, déclarée par $us_name.";
		$_details = "Le laboratoire $nfac a rendu les résultats d’analyse pour la fiche $co. Maladie suspectée: $maladie, déclarée par $us_name.<br><h3>Les résultats des analyses:</h3><p> $rl </p>";
		
		$this->add_private_notification($u, $_subject, $_excerpt, $_details, 'N', $co);
		
		
	}
	
		
	
}
if (isset($this->sc_temp_usr_nfac)) { $_SESSION['usr_nfac'] = $this->sc_temp_usr_nfac;}
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_code_fiche != $this->code_fiche || (isset($bFlagRead_code_fiche) && $bFlagRead_code_fiche)))
    {
        $this->ajax_return_values_code_fiche(true);
    }
    if (($original_maladie_suspectee_nm_fk != $this->maladie_suspectee_nm_fk || (isset($bFlagRead_maladie_suspectee_nm_fk) && $bFlagRead_maladie_suspectee_nm_fk)))
    {
        $this->ajax_return_values_maladie_suspectee_nm_fk(true);
    }
    if (($original_resultats_labo != $this->resultats_labo || (isset($bFlagRead_resultats_labo) && $bFlagRead_resultats_labo)))
    {
        $this->ajax_return_values_resultats_labo(true);
    }
    if (($original_structure != $this->structure || (isset($bFlagRead_structure) && $bFlagRead_structure)))
    {
        $this->ajax_return_values_structure(true);
    }
    if (($original_user_fk != $this->user_fk || (isset($bFlagRead_user_fk) && $bFlagRead_user_fk)))
    {
        $this->ajax_return_values_user_fk(true);
    }
}
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off'; 
          }
      }
   }

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

    function ValidateField_date_declaration(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      nm_limpa_data($this->date_declaration, $this->field_config['date_declaration']['date_sep']) ; 
      if (isset($this->Field_no_validate['date_declaration'])) {
          return;
      }
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          $guarda_datahora = $this->field_config['date_declaration']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['date_declaration']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['date_declaration']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['date_declaration']['date_sep']) ; 
          if (trim($this->date_declaration) != "")  
          { 
              if ($teste_validade->Data($this->date_declaration, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $hasError = true;
                  $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_declaration'] . "; " ; 
                  if (!isset($Campos_Erros['date_declaration']))
                  {
                      $Campos_Erros['date_declaration'] = array();
                  }
                  $Campos_Erros['date_declaration'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['date_declaration']) || !is_array($this->NM_ajax_info['errList']['date_declaration']))
                  {
                      $this->NM_ajax_info['errList']['date_declaration'] = array();
                  }
                  $this->NM_ajax_info['errList']['date_declaration'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['date_declaration']['date_format'] = $guarda_datahora; 
       } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'date_declaration';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
      nm_limpa_hora($this->date_declaration_hora, $this->field_config['date_declaration_hora']['time_sep']) ; 
      if (isset($this->Field_no_validate['date_declaration_hora'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      {
          $Format_Hora = $this->field_config['date_declaration_hora']['date_format']; 
          nm_limpa_hora($Format_Hora, $this->field_config['date_declaration_hora']['time_sep']) ; 
          if (trim($this->date_declaration_hora) != "")  
          { 
              if ($teste_validade->Hora($this->date_declaration_hora, $Format_Hora) == false)  
              { 
                  $hasError = true;
                  $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_declaration'] . "; " ; 
                  if (!isset($Campos_Erros['date_declaration_hora']))
                  {
                      $Campos_Erros['date_declaration_hora'] = array();
                  }
                  $Campos_Erros['date_declaration_hora'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['date_declaration']) || !is_array($this->NM_ajax_info['errList']['date_declaration']))
                  {
                      $this->NM_ajax_info['errList']['date_declaration'] = array();
                  }
                  $this->NM_ajax_info['errList']['date_declaration'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
      if (isset($Campos_Erros['date_declaration']) && isset($Campos_Erros['date_declaration_hora']))
      {
          $this->removeDuplicateDttmError($Campos_Erros['date_declaration'], $Campos_Erros['date_declaration_hora']);
          if (empty($Campos_Erros['date_declaration_hora']))
          {
              unset($Campos_Erros['date_declaration_hora']);
          }
          if (isset($this->NM_ajax_info['errList']['date_declaration']))
          {
              $this->NM_ajax_info['errList']['date_declaration'] = array_unique($this->NM_ajax_info['errList']['date_declaration']);
          }
      }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'date_declaration_hora';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_date_declaration_hora

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

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

    function ValidateField_maladie_suspectee_nm_fk(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
   if (isset($this->Field_no_validate['maladie_suspectee_nm_fk'])) {
       return;
   }
   if ($this->nmgp_opcao == "incluir")
   {
               if (!empty($this->maladie_suspectee_nm_fk) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']) && !in_array($this->maladie_suspectee_nm_fk, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']))
               {
                   $hasError = true;
                   $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($Campos_Erros['maladie_suspectee_nm_fk']))
                   {
                       $Campos_Erros['maladie_suspectee_nm_fk'] = array();
                   }
                   $Campos_Erros['maladie_suspectee_nm_fk'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($this->NM_ajax_info['errList']['maladie_suspectee_nm_fk']) || !is_array($this->NM_ajax_info['errList']['maladie_suspectee_nm_fk']))
                   {
                       $this->NM_ajax_info['errList']['maladie_suspectee_nm_fk'] = array();
                   }
                   $this->NM_ajax_info['errList']['maladie_suspectee_nm_fk'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
               }
   }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'maladie_suspectee_nm_fk';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_maladie_suspectee_nm_fk

    function ValidateField_type_prelevement_nm_fk(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
   if (isset($this->Field_no_validate['type_prelevement_nm_fk'])) {
       return;
   }
      if (!empty($this->type_prelevement_nm_fk) && !is_array($this->type_prelevement_nm_fk))
      {
          $this->type_prelevement_nm_fk = explode(";", $this->type_prelevement_nm_fk);
      }
      if (is_array($this->type_prelevement_nm_fk))
      {
          $x = 0; 
          $this->type_prelevement_nm_fk_1 = array(); 
          foreach ($this->type_prelevement_nm_fk as $ind => $dados_type_prelevement_nm_fk_1 ) 
          {
              if ($dados_type_prelevement_nm_fk_1 != "") 
              {
                  $this->type_prelevement_nm_fk_1[] = $dados_type_prelevement_nm_fk_1;
              } 
          } 
          $this->type_prelevement_nm_fk = ""; 
          if ($this->type_prelevement_nm_fk_1 != "") 
          { 
              foreach ($this->type_prelevement_nm_fk_1 as $dados_type_prelevement_nm_fk_1 ) 
              { 
                       if ($x != 0)
                       { 
                           $this->type_prelevement_nm_fk .= ";";
                       } 
                       $this->type_prelevement_nm_fk .= $dados_type_prelevement_nm_fk_1;
                       if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']) && !in_array($dados_type_prelevement_nm_fk_1, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']))
                       {
                           $hasError = true;
                           $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
                           if (!isset($Campos_Erros['type_prelevement_nm_fk']))
                           {
                               $Campos_Erros['type_prelevement_nm_fk'] = array();
                           }
                           $Campos_Erros['type_prelevement_nm_fk'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                           if (!isset($this->NM_ajax_info['errList']['type_prelevement_nm_fk']) || !is_array($this->NM_ajax_info['errList']['type_prelevement_nm_fk']))
                           {
                               $this->NM_ajax_info['errList']['type_prelevement_nm_fk'] = array();
                           }
                           $this->NM_ajax_info['errList']['type_prelevement_nm_fk'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                           breack;
                       }
                       $x++ ; 
              } 
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'type_prelevement_nm_fk';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_type_prelevement_nm_fk

    function ValidateField_date_reception_prelevement(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      nm_limpa_data($this->date_reception_prelevement, $this->field_config['date_reception_prelevement']['date_sep']) ; 
      if (isset($this->Field_no_validate['date_reception_prelevement'])) {
          return;
      }
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      $trab_dt_max = date('Ymd'); 
      $trab_dt_dia = date('d'); 
      $trab_dt_mes = date('m'); 
      $trab_dt_ano = date('Y'); 
      $this->nm_data->nm_calc_data($trab_dt_dia, $trab_dt_mes, $trab_dt_ano, 21, 0, 0, "-"); 
      $trab_dt_min = $trab_dt_ano . $trab_dt_mes . $trab_dt_dia; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          $guarda_datahora = $this->field_config['date_reception_prelevement']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['date_reception_prelevement']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['date_reception_prelevement']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['date_reception_prelevement']['date_sep']) ; 
          if (trim($this->date_reception_prelevement) != "")  
          { 
              if ($teste_validade->Data($this->date_reception_prelevement, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $hasError = true;
                  $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_reception_prelevement'] . "; " ; 
                  if (!isset($Campos_Erros['date_reception_prelevement']))
                  {
                      $Campos_Erros['date_reception_prelevement'] = array();
                  }
                  $Campos_Erros['date_reception_prelevement'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['date_reception_prelevement']) || !is_array($this->NM_ajax_info['errList']['date_reception_prelevement']))
                  {
                      $this->NM_ajax_info['errList']['date_reception_prelevement'] = array();
                  }
                  $this->NM_ajax_info['errList']['date_reception_prelevement'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['date_reception_prelevement']['date_format'] = $guarda_datahora; 
       } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'date_reception_prelevement';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_date_reception_prelevement

    function ValidateField_date_resultats_labo(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      nm_limpa_data($this->date_resultats_labo, $this->field_config['date_resultats_labo']['date_sep']) ; 
      if (isset($this->Field_no_validate['date_resultats_labo'])) {
          return;
      }
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      $trab_dt_max = date('Ymd'); 
      $trab_dt_dia = date('d'); 
      $trab_dt_mes = date('m'); 
      $trab_dt_ano = date('Y'); 
      $this->nm_data->nm_calc_data($trab_dt_dia, $trab_dt_mes, $trab_dt_ano, 0, 6, 0, "-"); 
      $trab_dt_min = $trab_dt_ano . $trab_dt_mes . $trab_dt_dia; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          $guarda_datahora = $this->field_config['date_resultats_labo']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['date_resultats_labo']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['date_resultats_labo']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['date_resultats_labo']['date_sep']) ; 
          if (trim($this->date_resultats_labo) != "")  
          { 
              if ($teste_validade->Data($this->date_resultats_labo, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $hasError = true;
                  $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_date_resultats_labo'] . "; " ; 
                  if (!isset($Campos_Erros['date_resultats_labo']))
                  {
                      $Campos_Erros['date_resultats_labo'] = array();
                  }
                  $Campos_Erros['date_resultats_labo'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['date_resultats_labo']) || !is_array($this->NM_ajax_info['errList']['date_resultats_labo']))
                  {
                      $this->NM_ajax_info['errList']['date_resultats_labo'] = array();
                  }
                  $this->NM_ajax_info['errList']['date_resultats_labo'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['date_resultats_labo']['date_format'] = $guarda_datahora; 
       } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'date_resultats_labo';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_date_resultats_labo

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

    function ValidateField_attached_file(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['attached_file'])) {
          return;
      }
        if ($this->nmgp_opcao != "excluir")
        {
            $sTestFile = $this->attached_file;
            if ("" != $this->attached_file && "S" != $this->attached_file_limpa && !$teste_validade->ArqExtensao($this->attached_file, array('png', 'jpg', 'jpeg')))
            {
                $hasError = true;
                $Campos_Crit .= "{lang_public_fiche_prof_sante_fld_attached_file}: " . $this->Ini->Nm_lang['lang_errm_file_invl']; 
                if (!isset($Campos_Erros['attached_file']))
                {
                    $Campos_Erros['attached_file'] = array();
                }
                $Campos_Erros['attached_file'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
                if (!isset($this->NM_ajax_info['errList']['attached_file']) || !is_array($this->NM_ajax_info['errList']['attached_file']))
                {
                    $this->NM_ajax_info['errList']['attached_file'] = array();
                }
                $this->NM_ajax_info['errList']['attached_file'][] = $this->Ini->Nm_lang['lang_errm_file_invl'];
            }
            if (!$hasError && "" != $this->attached_file && "S" != $this->attached_file_limpa) {
                if (!function_exists('sc_upload_unprotect_chars')) {
                    include_once 'form_fiche_pro_sante_labo_edit_doc_name.php';
                }
                $pathParts = pathinfo(sc_upload_unprotect_chars($sTestFile));
                $fileSize = filesize(sc_upload_unprotect_chars($sTestFile));
                $sizeErrorSuffix = '';
                if ('png' == strtolower($pathParts['extension']) && 1048576 < $fileSize) {
                    $sizeErrorSuffix = ' (PNG < 1 MB)';
                    $hasError = true;
                }
                if ('jpg' == strtolower($pathParts['extension']) && 1048576 < $fileSize) {
                    $sizeErrorSuffix = ' (JPG < 1 MB)';
                    $hasError = true;
                }
                if ('jpeg' == strtolower($pathParts['extension']) && 1048576 < $fileSize) {
                    $sizeErrorSuffix = ' (JPEG < 1 MB)';
                    $hasError = true;
                }
                if ($hasError) {
                    $Campos_Crit .= "{lang_public_fiche_prof_sante_fld_attached_file}: " . $this->Ini->Nm_lang['lang_errm_file_size'] . $sizeErrorSuffix;
                    if (!isset($Campos_Erros['attached_file']))
                    {
                        $Campos_Erros['attached_file'] = array();
                    }
                    $Campos_Erros['attached_file'][] = $this->Ini->Nm_lang['lang_errm_file_size'] . $sizeErrorSuffix;
                    if (!isset($this->NM_ajax_info['errList']['attached_file']) || !is_array($this->NM_ajax_info['errList']['attached_file']))
                    {
                        $this->NM_ajax_info['errList']['attached_file'] = array();
                    }
                    $this->NM_ajax_info['errList']['attached_file'][] = $this->Ini->Nm_lang['lang_errm_file_size'] . $sizeErrorSuffix;
                }
            }
        }
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'attached_file';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_attached_file

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

    function ValidateField_commentaires_labo(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
        $hasError = false;
      if (isset($this->Field_no_validate['commentaires_labo'])) {
          return;
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->commentaires_labo) > 32767) 
          { 
              $hasError = true;
              $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_commentaires_labo'] . " " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['commentaires_labo']))
              {
                  $Campos_Erros['commentaires_labo'] = array();
              }
              $Campos_Erros['commentaires_labo'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['commentaires_labo']) || !is_array($this->NM_ajax_info['errList']['commentaires_labo']))
              {
                  $this->NM_ajax_info['errList']['commentaires_labo'] = array();
              }
              $this->NM_ajax_info['errList']['commentaires_labo'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
        if ($hasError) {
            global $sc_seq_vert;
            $fieldName = 'commentaires_labo';
            if (isset($sc_seq_vert) && '' != $sc_seq_vert) {
                $fieldName .= $sc_seq_vert;
            }
            $this->NM_ajax_info['fieldsWithErrors'][] = $fieldName;
        }
    } // ValidateField_commentaires_labo
//
//--------------------------------------------------------------------------------------
   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->attached_file == "none") 
          { 
              $this->attached_file = ""; 
          } 
          if ($this->attached_file != "") 
          { 
              if (!function_exists('sc_upload_unprotect_chars'))
              {
                  include_once 'form_fiche_pro_sante_labo_edit_doc_name.php';
              }
              $this->attached_file = sc_upload_unprotect_chars($this->attached_file, true);
              $this->attached_file_scfile_name = sc_upload_unprotect_chars($this->attached_file_scfile_name, true);
              if ($nm_browser == "Opera")  
              { 
                  $this->attached_file_scfile_type = substr($this->attached_file_scfile_type, 0, strpos($this->attached_file_scfile_type, ";")) ; 
              } 
              if ($this->attached_file_scfile_type == "image/pjpeg" || $this->attached_file_scfile_type == "image/jpeg" || $this->attached_file_scfile_type == "image/gif" ||  
                  $this->attached_file_scfile_type == "image/png" || $this->attached_file_scfile_type == "image/x-png" || $this->attached_file_scfile_type == "image/bmp")  
              { 
                  if (!is_file($this->attached_file) && isset($_SESSION['scriptcase']['charset']) && $_SESSION['scriptcase']['charset'] != 'UTF-8') {
                      $mbConvertFileName = mb_convert_encoding($this->attached_file, $_SESSION['scriptcase']['charset'], 'UTF-8');
                      $mbConvertScFileName = mb_convert_encoding($this->attached_file_scfile_name, $_SESSION['scriptcase']['charset'], 'UTF-8');
                      if (is_file($mbConvertFileName)) {
                          $this->attached_file = $mbConvertFileName;
                          $this->attached_file_scfile_name = $mbConvertScFileName;
                      }
                  }
                  if (is_file($this->attached_file))  
                  { 
                      $this->NM_size_docs[$this->attached_file_scfile_name] = $this->sc_file_size($this->attached_file);
                      if ($this->nmgp_opcao == "incluir")
                      { 
                          $this->SC_IMG_attached_file = $this->attached_file;
                      } 
                      else 
                      { 
                          $arq_attached_file = fopen($this->attached_file, "r") ; 
                          $reg_attached_file = fread($arq_attached_file, filesize($this->attached_file)) ; 
                          fclose($arq_attached_file) ;  
                      } 
                      $this->attached_file =  trim($this->attached_file_scfile_name) ;  
                      $dir_img = $this->Ini->root . $this->Ini->path_imagens . "/attached_files" . "/"; 
                     if ($this->nmgp_opcao != "incluir")
                     { 
                      if (nm_mkdir($dir_img))  
                      { 
                          $arq_attached_file = fopen($dir_img . trim($this->attached_file_scfile_name), "w") ; 
                          fwrite($arq_attached_file, $reg_attached_file) ;  
                          fclose($arq_attached_file) ;  
                      } 
                      else 
                      { 
                          $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_attached_file'] . ": " . $this->Ini->Nm_lang['lang_errm_ivdr']; 
                          $this->attached_file = "";
                          if (!isset($Campos_Erros['attached_file']))
                          {
                              $Campos_Erros['attached_file'] = array();
                          }
                          $Campos_Erros['attached_file'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                          if (!isset($this->NM_ajax_info['errList']['attached_file']) || !is_array($this->NM_ajax_info['errList']['attached_file']))
                          {
                              $this->NM_ajax_info['errList']['attached_file'] = array();
                          }
                          $this->NM_ajax_info['errList']['attached_file'][] = $this->Ini->Nm_lang['lang_errm_ivdr'];
                      } 
                     } 
                  } 
                  else 
                  { 
                      $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_attached_file'] . " " . $this->Ini->Nm_lang['lang_errm_upld']; 
                      $this->attached_file = "";
                      if (!isset($Campos_Erros['attached_file']))
                      {
                          $Campos_Erros['attached_file'] = array();
                      }
                      $Campos_Erros['attached_file'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                      if (!isset($this->NM_ajax_info['errList']['attached_file']) || !is_array($this->NM_ajax_info['errList']['attached_file']))
                      {
                          $this->NM_ajax_info['errList']['attached_file'] = array();
                      }
                      $this->NM_ajax_info['errList']['attached_file'][] = $this->Ini->Nm_lang['lang_errm_upld'];
                  } 
              } 
              else 
              { 
                  if ($nm_browser == "Konqueror")  
                  { 
                      $this->attached_file = "" ; 
                  } 
                  else 
                  { 
                      $Campos_Crit .= "" . $this->Ini->Nm_lang['lang_public_fiche_prof_sante_fld_attached_file'] . " " . $this->Ini->Nm_lang['lang_errm_ivtp']; 
                      if (!isset($Campos_Erros['attached_file']))
                      {
                          $Campos_Erros['attached_file'] = array();
                      }
                      $Campos_Erros['attached_file'][] = $this->Ini->Nm_lang['geracao_tp_inval'];
                      if (!isset($this->NM_ajax_info['errList']['attached_file']) || !is_array($this->NM_ajax_info['errList']['attached_file']))
                      {
                          $this->NM_ajax_info['errList']['attached_file'] = array();
                      }
                      $this->NM_ajax_info['errList']['attached_file'][] = $this->Ini->Nm_lang['geracao_tp_inval'];
                  } 
              } 
          } 
          elseif (!empty($this->attached_file_salva) && $this->attached_file_limpa != "S")
          {
              $this->attached_file = $this->attached_file_salva;
          }
      } 
      elseif (!empty($this->attached_file_salva) && $this->attached_file_limpa != "S")
      {
          $this->attached_file = $this->attached_file_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['code_fiche'] = $this->code_fiche;
    $this->nmgp_dados_form['date_declaration'] = (strlen(trim($this->date_declaration)) > 19) ? str_replace(".", ":", $this->date_declaration) : trim($this->date_declaration);
    $this->nmgp_dados_form['structure'] = $this->structure;
    $this->nmgp_dados_form['user_fk'] = $this->user_fk;
    $this->nmgp_dados_form['maladie_suspectee_nm_fk'] = $this->maladie_suspectee_nm_fk;
    $this->nmgp_dados_form['type_prelevement_nm_fk'] = $this->type_prelevement_nm_fk;
    $this->nmgp_dados_form['date_reception_prelevement'] = (strlen(trim($this->date_reception_prelevement)) > 19) ? str_replace(".", ":", $this->date_reception_prelevement) : trim($this->date_reception_prelevement);
    $this->nmgp_dados_form['date_resultats_labo'] = (strlen(trim($this->date_resultats_labo)) > 19) ? str_replace(".", ":", $this->date_resultats_labo) : trim($this->date_resultats_labo);
    $this->nmgp_dados_form['resultats_labo'] = $this->resultats_labo;
    if (empty($this->attached_file))
    {
        $this->attached_file = $this->nmgp_dados_form['attached_file'];
    }
    $this->nmgp_dados_form['attached_file'] = $this->attached_file;
    $this->nmgp_dados_form['attached_file_limpa'] = $this->attached_file_limpa;
    $this->nmgp_dados_form['commentaires'] = $this->commentaires;
    $this->nmgp_dados_form['commentaires_labo'] = $this->commentaires_labo;
    $this->nmgp_dados_form['id_fiche_ps'] = $this->id_fiche_ps;
    $this->nmgp_dados_form['wilaya'] = $this->wilaya;
    $this->nmgp_dados_form['commune'] = $this->commune;
    $this->nmgp_dados_form['nom_rapporteur'] = $this->nom_rapporteur;
    $this->nmgp_dados_form['tel_rapporteur'] = $this->tel_rapporteur;
    $this->nmgp_dados_form['email_rapporteur'] = $this->email_rapporteur;
    $this->nmgp_dados_form['nom_malade'] = $this->nom_malade;
    $this->nmgp_dados_form['prenom_malade'] = $this->prenom_malade;
    $this->nmgp_dados_form['date_naissance_malade'] = $this->date_naissance_malade;
    $this->nmgp_dados_form['age_malade'] = $this->age_malade;
    $this->nmgp_dados_form['sexe_nm_fk'] = $this->sexe_nm_fk;
    $this->nmgp_dados_form['profession_malade'] = $this->profession_malade;
    $this->nmgp_dados_form['adresse_malade'] = $this->adresse_malade;
    $this->nmgp_dados_form['wilaya_malade'] = $this->wilaya_malade;
    $this->nmgp_dados_form['commune_malade'] = $this->commune_malade;
    $this->nmgp_dados_form['lieu_travail'] = $this->lieu_travail;
    $this->nmgp_dados_form['tel_malade'] = $this->tel_malade;
    $this->nmgp_dados_form['email_malade'] = $this->email_malade;
    $this->nmgp_dados_form['lieux_frequentes'] = $this->lieux_frequentes;
    $this->nmgp_dados_form['date_apparition_symptomes'] = $this->date_apparition_symptomes;
    $this->nmgp_dados_form['autres_symptomes'] = $this->autres_symptomes;
    $this->nmgp_dados_form['hospitalisation'] = $this->hospitalisation;
    $this->nmgp_dados_form['date_hospitalisation'] = $this->date_hospitalisation;
    $this->nmgp_dados_form['evacuation'] = $this->evacuation;
    $this->nmgp_dados_form['date_evacuation'] = $this->date_evacuation;
    $this->nmgp_dados_form['structure_evacuation'] = $this->structure_evacuation;
    $this->nmgp_dados_form['antecedent_medicaux'] = $this->antecedent_medicaux;
    $this->nmgp_dados_form['longitude'] = $this->longitude;
    $this->nmgp_dados_form['latitude'] = $this->latitude;
    $this->nmgp_dados_form['envoie'] = $this->envoie;
    $this->nmgp_dados_form['envoie_ack'] = $this->envoie_ack;
    $this->nmgp_dados_form['valide'] = $this->valide;
    $this->nmgp_dados_form['descr_invalidite'] = $this->descr_invalidite;
    $this->nmgp_dados_form['validator_fk'] = $this->validator_fk;
    $this->nmgp_dados_form['mobile'] = $this->mobile;
    $this->nmgp_dados_form['evolution_nm_fk'] = $this->evolution_nm_fk;
    $this->nmgp_dados_form['symptomes'] = $this->symptomes;
    $this->nmgp_dados_form['device_id'] = $this->device_id;
    $this->nmgp_dados_form['maladie_suspectee_by_ia'] = $this->maladie_suspectee_by_ia;
    $this->nmgp_dados_form['deleted'] = $this->deleted;
    $this->nmgp_dados_form['date_validation'] = $this->date_validation;
    $this->nmgp_dados_form['user_labo_fk'] = $this->user_labo_fk;
    $this->nmgp_dados_form['date_confirmation_labo'] = $this->date_confirmation_labo;
    $this->nmgp_dados_form['maladie_confirmee_labo'] = $this->maladie_confirmee_labo;
    $this->nmgp_dados_form['statut_maladie'] = $this->statut_maladie;
    $this->nmgp_dados_form['date_sortie'] = $this->date_sortie;
    $this->nmgp_dados_form['date_deces'] = $this->date_deces;
    $this->nmgp_dados_form['date_prelevements'] = $this->date_prelevements;
    $this->nmgp_dados_form['labo_destination'] = $this->labo_destination;
    $this->nmgp_dados_form['nin'] = $this->nin;
    $this->nmgp_dados_form['commentaires_semep'] = $this->commentaires_semep;
    $this->nmgp_dados_form['statut_fiche'] = $this->statut_fiche;
    $this->nmgp_dados_form['autre_evolution'] = $this->autre_evolution;
    $this->nmgp_dados_form['cas_similaires'] = $this->cas_similaires;
    $this->nmgp_dados_form['unite_age_nm_fk'] = $this->unite_age_nm_fk;
    $this->nmgp_dados_form['pays_origine'] = $this->pays_origine;
    $this->nmgp_dados_form['nationalite_nm_fk'] = $this->nationalite_nm_fk;
    $this->nmgp_dados_form['spacer1'] = $this->spacer1;
    $this->nmgp_dados_form['spacer2'] = $this->spacer2;
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_form'] = $this->nmgp_dados_form;
   }
   function nm_tira_formatacao()
   {
      global $nm_form_submit;
         $this->Before_unformat = array();
         $this->formatado = false;
      $this->Before_unformat['date_declaration'] = $this->date_declaration;
      $this->Before_unformat['date_declaration_hora'] = $this->date_declaration_hora;
      nm_limpa_data($this->date_declaration, $this->field_config['date_declaration']['date_sep']) ; 
      nm_limpa_hora($this->date_declaration_hora, $this->field_config['date_declaration']['time_sep']) ; 
      $this->Before_unformat['date_reception_prelevement'] = $this->date_reception_prelevement;
      nm_limpa_data($this->date_reception_prelevement, $this->field_config['date_reception_prelevement']['date_sep']) ; 
      $this->Before_unformat['date_resultats_labo'] = $this->date_resultats_labo;
      nm_limpa_data($this->date_resultats_labo, $this->field_config['date_resultats_labo']['date_sep']) ; 
      $this->Before_unformat['id_fiche_ps'] = $this->id_fiche_ps;
      nm_limpa_numero($this->id_fiche_ps, $this->field_config['id_fiche_ps']['symbol_grp']) ; 
      $this->Before_unformat['date_naissance_malade'] = $this->date_naissance_malade;
      nm_limpa_data($this->date_naissance_malade, $this->field_config['date_naissance_malade']['date_sep']) ; 
      $this->Before_unformat['age_malade'] = $this->age_malade;
      nm_limpa_numero($this->age_malade, $this->field_config['age_malade']['symbol_grp']) ; 
      $this->Before_unformat['date_apparition_symptomes'] = $this->date_apparition_symptomes;
      nm_limpa_data($this->date_apparition_symptomes, $this->field_config['date_apparition_symptomes']['date_sep']) ; 
      $this->Before_unformat['date_hospitalisation'] = $this->date_hospitalisation;
      nm_limpa_data($this->date_hospitalisation, $this->field_config['date_hospitalisation']['date_sep']) ; 
      $this->Before_unformat['date_evacuation'] = $this->date_evacuation;
      nm_limpa_data($this->date_evacuation, $this->field_config['date_evacuation']['date_sep']) ; 
      $this->Before_unformat['longitude'] = $this->longitude;
      if (!empty($this->field_config['longitude']['symbol_dec']))
      {
         nm_limpa_valor($this->longitude, $this->field_config['longitude']['symbol_dec'], $this->field_config['longitude']['symbol_grp']);
      }
      $this->Before_unformat['latitude'] = $this->latitude;
      if (!empty($this->field_config['latitude']['symbol_dec']))
      {
         nm_limpa_valor($this->latitude, $this->field_config['latitude']['symbol_dec'], $this->field_config['latitude']['symbol_grp']);
      }
      $this->Before_unformat['date_validation'] = $this->date_validation;
      $this->Before_unformat['date_validation_hora'] = $this->date_validation_hora;
      nm_limpa_data($this->date_validation, $this->field_config['date_validation']['date_sep']) ; 
      nm_limpa_hora($this->date_validation_hora, $this->field_config['date_validation']['time_sep']) ; 
      $this->Before_unformat['date_confirmation_labo'] = $this->date_confirmation_labo;
      $this->Before_unformat['date_confirmation_labo_hora'] = $this->date_confirmation_labo_hora;
      nm_limpa_data($this->date_confirmation_labo, $this->field_config['date_confirmation_labo']['date_sep']) ; 
      nm_limpa_hora($this->date_confirmation_labo_hora, $this->field_config['date_confirmation_labo']['time_sep']) ; 
      $this->Before_unformat['date_sortie'] = $this->date_sortie;
      nm_limpa_data($this->date_sortie, $this->field_config['date_sortie']['date_sep']) ; 
      $this->Before_unformat['date_deces'] = $this->date_deces;
      nm_limpa_data($this->date_deces, $this->field_config['date_deces']['date_sep']) ; 
      $this->Before_unformat['date_prelevements'] = $this->date_prelevements;
      nm_limpa_data($this->date_prelevements, $this->field_config['date_prelevements']['date_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 == "id_fiche_ps")
      {
          nm_limpa_numero($this->id_fiche_ps, $this->field_config['id_fiche_ps']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "age_malade")
      {
          nm_limpa_numero($this->age_malade, $this->field_config['age_malade']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "longitude")
      {
          if (!empty($this->field_config['longitude']['symbol_dec']))
          {
             nm_limpa_valor($this->longitude, $this->field_config['longitude']['symbol_dec'], $this->field_config['longitude']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "latitude")
      {
          if (!empty($this->field_config['latitude']['symbol_dec']))
          {
             nm_limpa_valor($this->latitude, $this->field_config['latitude']['symbol_dec'], $this->field_config['latitude']['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->date_declaration) && 'null' != $this->date_declaration) || (!empty($format_fields) && isset($format_fields['date_declaration'])))
      {
          $nm_separa_data = strpos($this->field_config['date_declaration']['date_format'], ";") ;
          $guarda_format_hora = $this->field_config['date_declaration']['date_format'];
          $this->field_config['date_declaration']['date_format'] = substr($this->field_config['date_declaration']['date_format'], 0, $nm_separa_data) ;
          $separador = strpos($this->date_declaration, " ") ; 
          $this->date_declaration_hora = substr($this->date_declaration, $separador + 1) ; 
          $this->date_declaration = substr($this->date_declaration, 0, $separador) ; 
          nm_volta_data($this->date_declaration, $this->field_config['date_declaration']['date_format']) ; 
          nmgp_Form_Datas($this->date_declaration, $this->field_config['date_declaration']['date_format'], $this->field_config['date_declaration']['date_sep']) ;  
          $this->field_config['date_declaration']['date_format'] = substr($guarda_format_hora, $nm_separa_data + 1) ;
          nm_volta_hora($this->date_declaration_hora, $this->field_config['date_declaration']['date_format']) ; 
          nmgp_Form_Hora($this->date_declaration_hora, $this->field_config['date_declaration']['date_format'], $this->field_config['date_declaration']['time_sep']) ;  
          $this->field_config['date_declaration']['date_format'] = $guarda_format_hora ;
      }
      elseif ('null' == $this->date_declaration || '' == $this->date_declaration)
      {
          $this->date_declaration_hora = '';
          $this->date_declaration = '';
      }
      if ((!empty($this->date_reception_prelevement) && 'null' != $this->date_reception_prelevement) || (!empty($format_fields) && isset($format_fields['date_reception_prelevement'])))
      {
          nm_volta_data($this->date_reception_prelevement, $this->field_config['date_reception_prelevement']['date_format']) ; 
          nmgp_Form_Datas($this->date_reception_prelevement, $this->field_config['date_reception_prelevement']['date_format'], $this->field_config['date_reception_prelevement']['date_sep']) ;  
      }
      elseif ('null' == $this->date_reception_prelevement || '' == $this->date_reception_prelevement)
      {
          $this->date_reception_prelevement = '';
      }
      if ((!empty($this->date_resultats_labo) && 'null' != $this->date_resultats_labo) || (!empty($format_fields) && isset($format_fields['date_resultats_labo'])))
      {
          nm_volta_data($this->date_resultats_labo, $this->field_config['date_resultats_labo']['date_format']) ; 
          nmgp_Form_Datas($this->date_resultats_labo, $this->field_config['date_resultats_labo']['date_format'], $this->field_config['date_resultats_labo']['date_sep']) ;  
      }
      elseif ('null' == $this->date_resultats_labo || '' == $this->date_resultats_labo)
      {
          $this->date_resultats_labo = '';
      }
   }
   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_limpa_alfa(&$str)
   {
   }
//
//-- 
   function nm_converte_datas($use_null = true, $bForce = false)
   {
      $guarda_format_hora = $this->field_config['date_declaration']['date_format'];
      if ($this->date_declaration != "")  
      { 
          $nm_separa_data = strpos($this->field_config['date_declaration']['date_format'], ";") ;
          $this->field_config['date_declaration']['date_format'] = substr($this->field_config['date_declaration']['date_format'], 0, $nm_separa_data) ;
          nm_conv_data($this->date_declaration, $this->field_config['date_declaration']['date_format']) ; 
          if ('pdo_sqlsrv' == strtolower($this->Ini->nm_tpbanco) || 'pdo_dblib' == strtolower($this->Ini->nm_tpbanco))
          {
              $this->date_declaration = str_replace('-', '', $this->date_declaration);
          }
          $this->field_config['date_declaration']['date_format'] = substr($guarda_format_hora, $nm_separa_data + 1) ;
          nm_conv_hora($this->date_declaration_hora, $this->field_config['date_declaration']['date_format']) ; 
          if ($this->date_declaration_hora == "" )  
          { 
              $this->date_declaration_hora = "00:00:00:000" ; 
          }
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sqlite))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4) . "." . substr($this->date_declaration_hora, -3);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $this->date_declaration_hora = substr($this->date_declaration_hora, 0, -4);
          }
          if ($this->date_declaration != "")  
          { 
              $this->date_declaration .= " " . $this->date_declaration_hora ; 
          }
      } 
      if ($this->date_declaration == "" && $use_null)  
      { 
          $this->date_declaration = "null" ; 
      } 
      $this->field_config['date_declaration']['date_format'] = $guarda_format_hora;
      $guarda_format_hora = $this->field_config['date_reception_prelevement']['date_format'];
      if ($this->date_reception_prelevement != "")  
      { 
          nm_conv_data($this->date_reception_prelevement, $this->field_config['date_reception_prelevement']['date_format']) ; 
          $this->date_reception_prelevement_hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->date_reception_prelevement_hora = substr($this->date_reception_prelevement_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->date_reception_prelevement_hora = substr($this->date_reception_prelevement_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->date_reception_prelevement_hora = substr($this->date_reception_prelevement_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->date_reception_prelevement_hora = substr($this->date_reception_prelevement_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->date_reception_prelevement_hora = substr($this->date_reception_prelevement_hora, 0, -4);
          }
      } 
      if ($this->date_reception_prelevement == "" && $use_null)  
      { 
          $this->date_reception_prelevement = "null" ; 
      } 
      $this->field_config['date_reception_prelevement']['date_format'] = $guarda_format_hora;
      $guarda_format_hora = $this->field_config['date_resultats_labo']['date_format'];
      if ($this->date_resultats_labo != "")  
      { 
          nm_conv_data($this->date_resultats_labo, $this->field_config['date_resultats_labo']['date_format']) ; 
          $this->date_resultats_labo_hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->date_resultats_labo_hora = substr($this->date_resultats_labo_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->date_resultats_labo_hora = substr($this->date_resultats_labo_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->date_resultats_labo_hora = substr($this->date_resultats_labo_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->date_resultats_labo_hora = substr($this->date_resultats_labo_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->date_resultats_labo_hora = substr($this->date_resultats_labo_hora, 0, -4);
          }
      } 
      if ($this->date_resultats_labo == "" && $use_null)  
      { 
          $this->date_resultats_labo = "null" ; 
      } 
      $this->field_config['date_resultats_labo']['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_code_fiche();
          $this->ajax_return_values_date_declaration();
          $this->ajax_return_values_structure();
          $this->ajax_return_values_user_fk();
          $this->ajax_return_values_maladie_suspectee_nm_fk();
          $this->ajax_return_values_type_prelevement_nm_fk();
          $this->ajax_return_values_date_reception_prelevement();
          $this->ajax_return_values_date_resultats_labo();
          $this->ajax_return_values_resultats_labo();
          $this->ajax_return_values_attached_file();
          $this->ajax_return_values_commentaires();
          $this->ajax_return_values_commentaires_labo();
          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']['id_fiche_ps']['keyVal'] = form_fiche_pro_sante_labo_edit_pack_protect_string($this->nmgp_dados_form['id_fiche_ps']);
          }
   } // ajax_return_values

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

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

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

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

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

 
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'] = array(); 
}
$aLookup[] = array(form_fiche_pro_sante_labo_edit_pack_protect_string('') => str_replace('<', '&lt;',form_fiche_pro_sante_labo_edit_pack_protect_string('...')));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'][] = '';
   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_date_declaration = $this->date_declaration;
   $old_value_date_declaration_hora = $this->date_declaration_hora;
   $old_value_date_reception_prelevement = $this->date_reception_prelevement;
   $old_value_date_resultats_labo = $this->date_resultats_labo;
   $this->nm_tira_formatacao();
   if ($this->nmgp_opcao != "nada") {
       $this->nm_converte_datas(false);
   }


   $unformatted_value_date_declaration = $this->date_declaration;
   $unformatted_value_date_declaration_hora = $this->date_declaration_hora;
   $unformatted_value_date_reception_prelevement = $this->date_reception_prelevement;
   $unformatted_value_date_resultats_labo = $this->date_resultats_labo;

   $nm_comando = "SELECT nomenclature_item_code, nomenclature_item  FROM \"public\".ref_nomenclature_items  WHERE nomenclature_fk = 'MALADIES' ORDER BY nomenclature_item_order";

   $this->date_declaration = $old_value_date_declaration;
   $this->date_declaration_hora = $old_value_date_declaration_hora;
   $this->date_reception_prelevement = $old_value_date_reception_prelevement;
   $this->date_resultats_labo = $old_value_date_resultats_labo;

   $_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) 
       { 
              $aLookup[] = array(form_fiche_pro_sante_labo_edit_pack_protect_string(NM_charset_to_utf8($rs->fields[0])) => str_replace('<', '&lt;', form_fiche_pro_sante_labo_edit_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]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'][] = $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=\"maladie_suspectee_nm_fk\"";
          if (isset($this->NM_ajax_info['select_html']['maladie_suspectee_nm_fk']) && !empty($this->NM_ajax_info['select_html']['maladie_suspectee_nm_fk']))
          {
              $sSelComp = str_replace('{SC_100PERC_CLASS_INPUT}', $this->classes_100perc_fields['input'], $this->NM_ajax_info['select_html']['maladie_suspectee_nm_fk']);
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->maladie_suspectee_nm_fk == $sValue)
                  {
                      $this->_tmp_lookup_maladie_suspectee_nm_fk = $sLabel;
                  }

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

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

 
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'] = 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_date_declaration = $this->date_declaration;
   $old_value_date_declaration_hora = $this->date_declaration_hora;
   $old_value_date_reception_prelevement = $this->date_reception_prelevement;
   $old_value_date_resultats_labo = $this->date_resultats_labo;
   $this->nm_tira_formatacao();
   if ($this->nmgp_opcao != "nada") {
       $this->nm_converte_datas(false);
   }


   $unformatted_value_date_declaration = $this->date_declaration;
   $unformatted_value_date_declaration_hora = $this->date_declaration_hora;
   $unformatted_value_date_reception_prelevement = $this->date_reception_prelevement;
   $unformatted_value_date_resultats_labo = $this->date_resultats_labo;

   $nm_comando = "SELECT nomenclature_item_code, nomenclature_item  FROM \"public\".ref_nomenclature_items  WHERE nomenclature_fk = 'TYPPRELEV' ORDER BY nomenclature_item";

   $this->date_declaration = $old_value_date_declaration;
   $this->date_declaration_hora = $old_value_date_declaration_hora;
   $this->date_reception_prelevement = $old_value_date_reception_prelevement;
   $this->date_resultats_labo = $old_value_date_resultats_labo;

   $_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) 
       { 
              $aLookup[] = array(form_fiche_pro_sante_labo_edit_pack_protect_string(NM_charset_to_utf8($rs->fields[0])) => str_replace('<', '&lt;', form_fiche_pro_sante_labo_edit_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]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'][] = $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;
          $sOptComp = "";
          if (isset($this->NM_ajax_info['select_html']['type_prelevement_nm_fk']) && !empty($this->NM_ajax_info['select_html']['type_prelevement_nm_fk']))
          {
              $sOptComp = str_replace('{SC_100PERC_CLASS_INPUT}', $this->classes_100perc_fields['input'], $this->NM_ajax_info['select_html']['type_prelevement_nm_fk']);
          }
          $this->NM_ajax_info['fldList']['type_prelevement_nm_fk'] = array(
                       'row'    => '',
               'type'    => 'checkbox',
               'switch'  => true,
               'valList' => explode(';', $sTmpValue),
               'optList' => $aLookup,
               'colNum'  => 3,
               'optComp'  => $sOptComp,
               'optClass' => 'sc-ui-checkbox-type_prelevement_nm_fk',
              );
          $aLabel     = array();
          $aLabelTemp = array();
          foreach ($this->NM_ajax_info['fldList']['type_prelevement_nm_fk']['valList'] as $i => $v)
          {
              $this->NM_ajax_info['fldList']['type_prelevement_nm_fk']['valList'][$i] = form_fiche_pro_sante_labo_edit_pack_protect_string($v);
          }
          foreach ($aLookupOrig as $aValData)
          {
              if (in_array(key($aValData), $this->NM_ajax_info['fldList']['type_prelevement_nm_fk']['valList']))
              {
                  $aLabelTemp[key($aValData)] = current($aValData);
              }
          }
          foreach ($this->NM_ajax_info['fldList']['type_prelevement_nm_fk']['valList'] as $iIndex => $sValue)
          {
              $aLabel[$iIndex] = (isset($aLabelTemp[$sValue])) ? $aLabelTemp[$sValue] : $sValue;
          }
          $this->NM_ajax_info['fldList']['type_prelevement_nm_fk']['labList'] = $aLabel;
          }
   }

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

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

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

          //----- attached_file
   function ajax_return_values_attached_file($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("attached_file", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->attached_file);
              $aLookup = array();
   $out_attached_file = '';
   $out1_attached_file = '';
   if ($this->attached_file != "" && $this->attached_file != "none")   
   { 
       $path_attached_file = $this->Ini->root . $this->Ini->path_imagens . "/attached_files" . "/" . $this->attached_file;
       $md5_attached_file  = md5("/attached_files" . $this->attached_file);
       nm_fix_SubDirUpload($this->attached_file,$this->Ini->root . $this->Ini->path_imagens,"/attached_files");
        if (is_file($path_attached_file))  
       { 
           $NM_ler_img = true;
           $out_attached_file = $this->Ini->path_imag_temp . "/sc_attached_file_" . $md5_attached_file . ".gif" ;  
           $out1_attached_file = $out_attached_file; 
           if (is_file($this->Ini->root . $out_attached_file))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_attached_file) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_ler_img = false;
               } 
           } 
           if ($NM_ler_img) 
           { 
               $tmp_attached_file = fopen($path_attached_file, "r") ; 
               $reg_attached_file = fread($tmp_attached_file, filesize($path_attached_file)) ; 
               fclose($tmp_attached_file) ;  
               $arq_attached_file = fopen($this->Ini->root . $out_attached_file, "w") ;  
               fwrite($arq_attached_file, $reg_attached_file) ;  
               fclose($arq_attached_file) ;  
           } 
           $sc_obj_img = new nm_trata_img($this->Ini->root . $out_attached_file, true);
           $this->nmgp_return_img['attached_file'][0] = $sc_obj_img->getHeight();
           $this->nmgp_return_img['attached_file'][1] = $sc_obj_img->getWidth();
           $NM_redim_img = true;
           $md5_attached_file  = md5($this->attached_file);
           $out_attached_file = $this->Ini->path_imag_temp . "/sc_attached_file_100100" . $md5_attached_file . ".gif" ;  
           if (is_file($this->Ini->root . $out_attached_file))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_attached_file) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_redim_img = false;
               } 
           } 
           if ($NM_redim_img) 
           { 
               if (!$this->Ini->Gd_missing)
               { 
                   $sc_obj_img = new nm_trata_img($this->Ini->root . $out1_attached_file, true);
                   $sc_obj_img->setWidth(100);
                   $sc_obj_img->setHeight(100);
                   $sc_obj_img->setManterAspecto(true);
                   $sc_obj_img->createImg($this->Ini->root . $out_attached_file);
               } 
               else 
               { 
                   $out_attached_file = $out1_attached_file;
               } 
           } 
       } 
   } 
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['attached_file'] = array(
                       'row'    => '',
               'type'    => 'imagem',
               'valList' => array($sTmpValue),
               'imgFile' => $out_attached_file,
               'imgOrig' => $out1_attached_file,
               'keepImg' => $sKeepImage,
              );
          }
   }

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

          //----- commentaires_labo
   function ajax_return_values_commentaires_labo($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("commentaires_labo", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->commentaires_labo);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['commentaires_labo'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($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]['form_fiche_pro_sante_labo_edit']['upload_dir'][$fieldName]))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['upload_dir'][$fieldName][] = $fileName;
                }
            }
            @closedir($resDir);
        }
        if (!in_array($originalName, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_dir'][$fieldName]))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_dir'][$fieldName][] = $originalName;
            return $originalName;
        }
        else
        {
            $newName = $this->fetchFileNextName($originalName, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['upload_dir'][$fieldName]);
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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()
   {
   } // ajax_add_parameters
  function nm_proc_onload($bFormat = true)
  {
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Field_no_validate'] = array();
      if (!$this->NM_ajax_flag || !isset($this->nmgp_refresh_fields)) {
      $_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_maladie_suspectee_nm_fk = $this->maladie_suspectee_nm_fk;
    $original_user_fk = $this->user_fk;
}
  $this->init_fields();
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_maladie_suspectee_nm_fk != $this->maladie_suspectee_nm_fk || (isset($bFlagRead_maladie_suspectee_nm_fk) && $bFlagRead_maladie_suspectee_nm_fk)))
    {
        $this->ajax_return_values_maladie_suspectee_nm_fk(true);
    }
    if (($original_user_fk != $this->user_fk || (isset($bFlagRead_user_fk) && $bFlagRead_user_fk)))
    {
        $this->ajax_return_values_user_fk(true);
    }
}
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off'; 
      }
      if (empty($this->date_declaration))
      {
          $this->date_declaration_hora = $this->date_declaration;
      }
      if (empty($this->date_validation))
      {
          $this->date_validation_hora = $this->date_validation;
      }
      if (empty($this->date_confirmation_labo))
      {
          $this->date_confirmation_labo_hora = $this->date_confirmation_labo;
      }
      $this->nm_guardar_campos();
      if ($bFormat) $this->nm_formatar_campos();
  }
//
//----------------------------------------------------
//-----> 
//----------------------------------------------------
//
   function nm_troca_decimal($sc_parm1, $sc_parm2) 
   { 
      $this->longitude = str_replace($sc_parm1, $sc_parm2, $this->longitude); 
      $this->latitude = str_replace($sc_parm1, $sc_parm2, $this->latitude); 
   } 
   function nm_poe_aspas_decimal() 
   { 
      $this->longitude = "'" . $this->longitude . "'";
      $this->latitude = "'" . $this->latitude . "'";
   } 
   function nm_tira_aspas_decimal() 
   { 
      $this->longitude = str_replace("'", "", $this->longitude); 
      $this->latitude = str_replace("'", "", $this->latitude); 
   } 
//----------- 


   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 nm_acessa_banco() 
   { 
      global  $nm_form_submit, $teste_validade, $sc_where;
 
      $NM_val_null = array();
      $NM_val_form = array();
      $this->sc_erro_insert = "";
      $this->sc_erro_update = "";
      $this->sc_erro_delete = "";
      $this->SC_log_atv = false;
      if ("alterar" == $this->nmgp_opcao || "excluir" == $this->nmgp_opcao)
      {
          $this->NM_gera_log_key($this->nmgp_opcao);
      }
      if ("alterar" == $this->nmgp_opcao || "excluir" == $this->nmgp_opcao)
      {
          $this->NM_gera_log_old();
      }
      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();
      $_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 ('alterar' == $this->nmgp_opcao || 'igual' == $this->nmgp_opcao) { $this->statut_fiche = "L"; } 
      $NM_val_form['code_fiche'] = $this->code_fiche;
      $NM_val_form['date_declaration'] = $this->date_declaration;
      $NM_val_form['structure'] = $this->structure;
      $NM_val_form['user_fk'] = $this->user_fk;
      $NM_val_form['maladie_suspectee_nm_fk'] = $this->maladie_suspectee_nm_fk;
      $NM_val_form['type_prelevement_nm_fk'] = $this->type_prelevement_nm_fk;
      $NM_val_form['date_reception_prelevement'] = $this->date_reception_prelevement;
      $NM_val_form['date_resultats_labo'] = $this->date_resultats_labo;
      $NM_val_form['resultats_labo'] = $this->resultats_labo;
      $NM_val_form['attached_file'] = $this->attached_file;
      $NM_val_form['commentaires'] = $this->commentaires;
      $NM_val_form['commentaires_labo'] = $this->commentaires_labo;
      $NM_val_form['id_fiche_ps'] = $this->id_fiche_ps;
      $NM_val_form['wilaya'] = $this->wilaya;
      $NM_val_form['commune'] = $this->commune;
      $NM_val_form['nom_rapporteur'] = $this->nom_rapporteur;
      $NM_val_form['tel_rapporteur'] = $this->tel_rapporteur;
      $NM_val_form['email_rapporteur'] = $this->email_rapporteur;
      $NM_val_form['nom_malade'] = $this->nom_malade;
      $NM_val_form['prenom_malade'] = $this->prenom_malade;
      $NM_val_form['date_naissance_malade'] = $this->date_naissance_malade;
      $NM_val_form['age_malade'] = $this->age_malade;
      $NM_val_form['sexe_nm_fk'] = $this->sexe_nm_fk;
      $NM_val_form['profession_malade'] = $this->profession_malade;
      $NM_val_form['adresse_malade'] = $this->adresse_malade;
      $NM_val_form['wilaya_malade'] = $this->wilaya_malade;
      $NM_val_form['commune_malade'] = $this->commune_malade;
      $NM_val_form['lieu_travail'] = $this->lieu_travail;
      $NM_val_form['tel_malade'] = $this->tel_malade;
      $NM_val_form['email_malade'] = $this->email_malade;
      $NM_val_form['lieux_frequentes'] = $this->lieux_frequentes;
      $NM_val_form['date_apparition_symptomes'] = $this->date_apparition_symptomes;
      $NM_val_form['autres_symptomes'] = $this->autres_symptomes;
      $NM_val_form['hospitalisation'] = $this->hospitalisation;
      $NM_val_form['date_hospitalisation'] = $this->date_hospitalisation;
      $NM_val_form['evacuation'] = $this->evacuation;
      $NM_val_form['date_evacuation'] = $this->date_evacuation;
      $NM_val_form['structure_evacuation'] = $this->structure_evacuation;
      $NM_val_form['antecedent_medicaux'] = $this->antecedent_medicaux;
      $NM_val_form['longitude'] = $this->longitude;
      $NM_val_form['latitude'] = $this->latitude;
      $NM_val_form['envoie'] = $this->envoie;
      $NM_val_form['envoie_ack'] = $this->envoie_ack;
      $NM_val_form['valide'] = $this->valide;
      $NM_val_form['descr_invalidite'] = $this->descr_invalidite;
      $NM_val_form['validator_fk'] = $this->validator_fk;
      $NM_val_form['mobile'] = $this->mobile;
      $NM_val_form['evolution_nm_fk'] = $this->evolution_nm_fk;
      $NM_val_form['symptomes'] = $this->symptomes;
      $NM_val_form['device_id'] = $this->device_id;
      $NM_val_form['maladie_suspectee_by_ia'] = $this->maladie_suspectee_by_ia;
      $NM_val_form['deleted'] = $this->deleted;
      $NM_val_form['date_validation'] = $this->date_validation;
      $NM_val_form['user_labo_fk'] = $this->user_labo_fk;
      $NM_val_form['date_confirmation_labo'] = $this->date_confirmation_labo;
      $NM_val_form['maladie_confirmee_labo'] = $this->maladie_confirmee_labo;
      $NM_val_form['statut_maladie'] = $this->statut_maladie;
      $NM_val_form['date_sortie'] = $this->date_sortie;
      $NM_val_form['date_deces'] = $this->date_deces;
      $NM_val_form['date_prelevements'] = $this->date_prelevements;
      $NM_val_form['labo_destination'] = $this->labo_destination;
      $NM_val_form['nin'] = $this->nin;
      $NM_val_form['commentaires_semep'] = $this->commentaires_semep;
      $NM_val_form['statut_fiche'] = $this->statut_fiche;
      $NM_val_form['autre_evolution'] = $this->autre_evolution;
      $NM_val_form['cas_similaires'] = $this->cas_similaires;
      $NM_val_form['unite_age_nm_fk'] = $this->unite_age_nm_fk;
      $NM_val_form['pays_origine'] = $this->pays_origine;
      $NM_val_form['nationalite_nm_fk'] = $this->nationalite_nm_fk;
      $NM_val_form['spacer1'] = $this->spacer1;
      $NM_val_form['spacer2'] = $this->spacer2;
      if ($this->id_fiche_ps === "" || is_null($this->id_fiche_ps))  
      { 
          $this->id_fiche_ps = 0;
      } 
      if ($this->age_malade === "" || is_null($this->age_malade))  
      { 
          $this->age_malade = 0;
          $this->sc_force_zero[] = 'age_malade';
      } 
      if ($this->longitude === "" || is_null($this->longitude))  
      { 
          $this->longitude = 0;
          $this->sc_force_zero[] = 'longitude';
      } 
      if ($this->latitude === "" || is_null($this->latitude))  
      { 
          $this->latitude = 0;
          $this->sc_force_zero[] = 'latitude';
      } 
      $nm_bases_lob_geral = array_merge($this->Ini->nm_bases_oracle, $this->Ini->nm_bases_ibase, $this->Ini->nm_bases_informix, $this->Ini->nm_bases_mysql, $this->Ini->nm_bases_access, $this->Ini->nm_bases_sqlite, array('pdo_ibm'), array('pdo_sqlsrv'));
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['decimal_db'] == ",") 
      {
          $this->nm_troca_decimal(".", ",");
      }
      if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir") 
      {
          $this->code_fiche_before_qstr = $this->code_fiche;
          $this->code_fiche = substr($this->Db->qstr($this->code_fiche), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->code_fiche = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->code_fiche);
          }
          if ($this->code_fiche == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->code_fiche = "null"; 
              $NM_val_null[] = "code_fiche";
          } 
          if ($this->date_declaration == "")  
          { 
              $this->date_declaration = "null"; 
              $NM_val_null[] = "date_declaration";
          } 
          $this->wilaya_before_qstr = $this->wilaya;
          $this->wilaya = substr($this->Db->qstr($this->wilaya), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->wilaya = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->wilaya);
          }
          if ($this->wilaya == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->wilaya = "null"; 
              $NM_val_null[] = "wilaya";
          } 
          $this->commune_before_qstr = $this->commune;
          $this->commune = substr($this->Db->qstr($this->commune), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->commune = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->commune);
          }
          if ($this->commune == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->commune = "null"; 
              $NM_val_null[] = "commune";
          } 
          $this->structure_before_qstr = $this->structure;
          $this->structure = substr($this->Db->qstr($this->structure), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->structure = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->structure);
          }
          if ($this->structure == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->structure = "null"; 
              $NM_val_null[] = "structure";
          } 
          $this->nom_rapporteur_before_qstr = $this->nom_rapporteur;
          $this->nom_rapporteur = substr($this->Db->qstr($this->nom_rapporteur), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->nom_rapporteur = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->nom_rapporteur);
          }
          if ($this->nom_rapporteur == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->nom_rapporteur = "null"; 
              $NM_val_null[] = "nom_rapporteur";
          } 
          $this->tel_rapporteur_before_qstr = $this->tel_rapporteur;
          $this->tel_rapporteur = substr($this->Db->qstr($this->tel_rapporteur), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->tel_rapporteur = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->tel_rapporteur);
          }
          if ($this->tel_rapporteur == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->tel_rapporteur = "null"; 
              $NM_val_null[] = "tel_rapporteur";
          } 
          $this->email_rapporteur_before_qstr = $this->email_rapporteur;
          $this->email_rapporteur = substr($this->Db->qstr($this->email_rapporteur), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->email_rapporteur = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->email_rapporteur);
          }
          if ($this->email_rapporteur == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->email_rapporteur = "null"; 
              $NM_val_null[] = "email_rapporteur";
          } 
          $this->maladie_suspectee_nm_fk_before_qstr = $this->maladie_suspectee_nm_fk;
          $this->maladie_suspectee_nm_fk = substr($this->Db->qstr($this->maladie_suspectee_nm_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->maladie_suspectee_nm_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->maladie_suspectee_nm_fk);
          }
          if ($this->maladie_suspectee_nm_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->maladie_suspectee_nm_fk = "null"; 
              $NM_val_null[] = "maladie_suspectee_nm_fk";
          } 
          $this->nom_malade_before_qstr = $this->nom_malade;
          $this->nom_malade = substr($this->Db->qstr($this->nom_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->nom_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->nom_malade);
          }
          if ($this->nom_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->nom_malade = "null"; 
              $NM_val_null[] = "nom_malade";
          } 
          $this->prenom_malade_before_qstr = $this->prenom_malade;
          $this->prenom_malade = substr($this->Db->qstr($this->prenom_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->prenom_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->prenom_malade);
          }
          if ($this->prenom_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->prenom_malade = "null"; 
              $NM_val_null[] = "prenom_malade";
          } 
          if ($this->date_naissance_malade == "")  
          { 
              $this->date_naissance_malade = "null"; 
              $NM_val_null[] = "date_naissance_malade";
          } 
          $this->sexe_nm_fk_before_qstr = $this->sexe_nm_fk;
          $this->sexe_nm_fk = substr($this->Db->qstr($this->sexe_nm_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->sexe_nm_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->sexe_nm_fk);
          }
          if ($this->sexe_nm_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->sexe_nm_fk = "null"; 
              $NM_val_null[] = "sexe_nm_fk";
          } 
          $this->profession_malade_before_qstr = $this->profession_malade;
          $this->profession_malade = substr($this->Db->qstr($this->profession_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->profession_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->profession_malade);
          }
          if ($this->profession_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->profession_malade = "null"; 
              $NM_val_null[] = "profession_malade";
          } 
          $this->adresse_malade_before_qstr = $this->adresse_malade;
          $this->adresse_malade = substr($this->Db->qstr($this->adresse_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->adresse_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->adresse_malade);
          }
          if ($this->adresse_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->adresse_malade = "null"; 
              $NM_val_null[] = "adresse_malade";
          } 
          $this->wilaya_malade_before_qstr = $this->wilaya_malade;
          $this->wilaya_malade = substr($this->Db->qstr($this->wilaya_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->wilaya_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->wilaya_malade);
          }
          if ($this->wilaya_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->wilaya_malade = "null"; 
              $NM_val_null[] = "wilaya_malade";
          } 
          $this->commune_malade_before_qstr = $this->commune_malade;
          $this->commune_malade = substr($this->Db->qstr($this->commune_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->commune_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->commune_malade);
          }
          if ($this->commune_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->commune_malade = "null"; 
              $NM_val_null[] = "commune_malade";
          } 
          $this->lieu_travail_before_qstr = $this->lieu_travail;
          $this->lieu_travail = substr($this->Db->qstr($this->lieu_travail), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->lieu_travail = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->lieu_travail);
          }
          if ($this->lieu_travail == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->lieu_travail = "null"; 
              $NM_val_null[] = "lieu_travail";
          } 
          $this->tel_malade_before_qstr = $this->tel_malade;
          $this->tel_malade = substr($this->Db->qstr($this->tel_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->tel_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->tel_malade);
          }
          if ($this->tel_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->tel_malade = "null"; 
              $NM_val_null[] = "tel_malade";
          } 
          $this->email_malade_before_qstr = $this->email_malade;
          $this->email_malade = substr($this->Db->qstr($this->email_malade), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->email_malade = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->email_malade);
          }
          if ($this->email_malade == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->email_malade = "null"; 
              $NM_val_null[] = "email_malade";
          } 
          $this->lieux_frequentes_before_qstr = $this->lieux_frequentes;
          $this->lieux_frequentes = substr($this->Db->qstr($this->lieux_frequentes), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->lieux_frequentes = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->lieux_frequentes);
          }
          if ($this->lieux_frequentes == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->lieux_frequentes = "null"; 
              $NM_val_null[] = "lieux_frequentes";
          } 
          if ($this->date_apparition_symptomes == "")  
          { 
              $this->date_apparition_symptomes = "null"; 
              $NM_val_null[] = "date_apparition_symptomes";
          } 
          $this->autres_symptomes_before_qstr = $this->autres_symptomes;
          $this->autres_symptomes = substr($this->Db->qstr($this->autres_symptomes), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->autres_symptomes = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->autres_symptomes);
          }
          if ($this->autres_symptomes == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->autres_symptomes = "null"; 
              $NM_val_null[] = "autres_symptomes";
          } 
          $this->hospitalisation_before_qstr = $this->hospitalisation;
          $this->hospitalisation = substr($this->Db->qstr($this->hospitalisation), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->hospitalisation = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->hospitalisation);
          }
          if ($this->hospitalisation == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->hospitalisation = "null"; 
              $NM_val_null[] = "hospitalisation";
          } 
          if ($this->date_hospitalisation == "")  
          { 
              $this->date_hospitalisation = "null"; 
              $NM_val_null[] = "date_hospitalisation";
          } 
          $this->evacuation_before_qstr = $this->evacuation;
          $this->evacuation = substr($this->Db->qstr($this->evacuation), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->evacuation = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->evacuation);
          }
          if ($this->evacuation == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->evacuation = "null"; 
              $NM_val_null[] = "evacuation";
          } 
          if ($this->date_evacuation == "")  
          { 
              $this->date_evacuation = "null"; 
              $NM_val_null[] = "date_evacuation";
          } 
          $this->structure_evacuation_before_qstr = $this->structure_evacuation;
          $this->structure_evacuation = substr($this->Db->qstr($this->structure_evacuation), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->structure_evacuation = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->structure_evacuation);
          }
          if ($this->structure_evacuation == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->structure_evacuation = "null"; 
              $NM_val_null[] = "structure_evacuation";
          } 
          $this->antecedent_medicaux_before_qstr = $this->antecedent_medicaux;
          $this->antecedent_medicaux = substr($this->Db->qstr($this->antecedent_medicaux), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->antecedent_medicaux = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->antecedent_medicaux);
          }
          if ($this->antecedent_medicaux == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->antecedent_medicaux = "null"; 
              $NM_val_null[] = "antecedent_medicaux";
          } 
          $this->commentaires_before_qstr = $this->commentaires;
          $this->commentaires = substr($this->Db->qstr($this->commentaires), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->commentaires = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->commentaires);
          }
          if ($this->commentaires == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->commentaires = "null"; 
              $NM_val_null[] = "commentaires";
          } 
          $this->envoie_before_qstr = $this->envoie;
          $this->envoie = substr($this->Db->qstr($this->envoie), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->envoie = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->envoie);
          }
          if ($this->envoie == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->envoie = "null"; 
              $NM_val_null[] = "envoie";
          } 
          $this->envoie_ack_before_qstr = $this->envoie_ack;
          $this->envoie_ack = substr($this->Db->qstr($this->envoie_ack), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->envoie_ack = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->envoie_ack);
          }
          if ($this->envoie_ack == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->envoie_ack = "null"; 
              $NM_val_null[] = "envoie_ack";
          } 
          $this->valide_before_qstr = $this->valide;
          $this->valide = substr($this->Db->qstr($this->valide), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->valide = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->valide);
          }
          if ($this->valide == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->valide = "null"; 
              $NM_val_null[] = "valide";
          } 
          $this->descr_invalidite_before_qstr = $this->descr_invalidite;
          $this->descr_invalidite = substr($this->Db->qstr($this->descr_invalidite), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->descr_invalidite = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->descr_invalidite);
          }
          if ($this->descr_invalidite == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->descr_invalidite = "null"; 
              $NM_val_null[] = "descr_invalidite";
          } 
          $this->user_fk_before_qstr = $this->user_fk;
          $this->user_fk = substr($this->Db->qstr($this->user_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->user_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->user_fk);
          }
          if ($this->user_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->user_fk = "null"; 
              $NM_val_null[] = "user_fk";
          } 
          $this->validator_fk_before_qstr = $this->validator_fk;
          $this->validator_fk = substr($this->Db->qstr($this->validator_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->validator_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->validator_fk);
          }
          if ($this->validator_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->validator_fk = "null"; 
              $NM_val_null[] = "validator_fk";
          } 
          $this->mobile_before_qstr = $this->mobile;
          $this->mobile = substr($this->Db->qstr($this->mobile), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->mobile = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->mobile);
          }
          if ($this->mobile == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->mobile = "null"; 
              $NM_val_null[] = "mobile";
          } 
          $this->evolution_nm_fk_before_qstr = $this->evolution_nm_fk;
          $this->evolution_nm_fk = substr($this->Db->qstr($this->evolution_nm_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->evolution_nm_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->evolution_nm_fk);
          }
          if ($this->evolution_nm_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->evolution_nm_fk = "null"; 
              $NM_val_null[] = "evolution_nm_fk";
          } 
          $this->symptomes_before_qstr = $this->symptomes;
          $this->symptomes = substr($this->Db->qstr($this->symptomes), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->symptomes = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->symptomes);
          }
          if ($this->symptomes == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->symptomes = "null"; 
              $NM_val_null[] = "symptomes";
          } 
          $this->device_id_before_qstr = $this->device_id;
          $this->device_id = substr($this->Db->qstr($this->device_id), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->device_id = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->device_id);
          }
          if ($this->device_id == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->device_id = "null"; 
              $NM_val_null[] = "device_id";
          } 
          $this->maladie_suspectee_by_ia_before_qstr = $this->maladie_suspectee_by_ia;
          $this->maladie_suspectee_by_ia = substr($this->Db->qstr($this->maladie_suspectee_by_ia), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->maladie_suspectee_by_ia = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->maladie_suspectee_by_ia);
          }
          if ($this->maladie_suspectee_by_ia == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->maladie_suspectee_by_ia = "null"; 
              $NM_val_null[] = "maladie_suspectee_by_ia";
          } 
          $this->deleted_before_qstr = $this->deleted;
          $this->deleted = substr($this->Db->qstr($this->deleted), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->deleted = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->deleted);
          }
          if ($this->deleted == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->deleted = "null"; 
              $NM_val_null[] = "deleted";
          } 
          if ($this->date_validation == "")  
          { 
              $this->date_validation = "null"; 
              $NM_val_null[] = "date_validation";
          } 
          $this->user_labo_fk_before_qstr = $this->user_labo_fk;
          $this->user_labo_fk = substr($this->Db->qstr($this->user_labo_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->user_labo_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->user_labo_fk);
          }
          if ($this->user_labo_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->user_labo_fk = "null"; 
              $NM_val_null[] = "user_labo_fk";
          } 
          if ($this->date_confirmation_labo == "")  
          { 
              $this->date_confirmation_labo = "null"; 
              $NM_val_null[] = "date_confirmation_labo";
          } 
          $this->maladie_confirmee_labo_before_qstr = $this->maladie_confirmee_labo;
          $this->maladie_confirmee_labo = substr($this->Db->qstr($this->maladie_confirmee_labo), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->maladie_confirmee_labo = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->maladie_confirmee_labo);
          }
          if ($this->maladie_confirmee_labo == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->maladie_confirmee_labo = "null"; 
              $NM_val_null[] = "maladie_confirmee_labo";
          } 
          $this->statut_maladie_before_qstr = $this->statut_maladie;
          $this->statut_maladie = substr($this->Db->qstr($this->statut_maladie), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->statut_maladie = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->statut_maladie);
          }
          if ($this->statut_maladie == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->statut_maladie = "null"; 
              $NM_val_null[] = "statut_maladie";
          } 
          if ($this->date_sortie == "")  
          { 
              $this->date_sortie = "null"; 
              $NM_val_null[] = "date_sortie";
          } 
          if ($this->date_deces == "")  
          { 
              $this->date_deces = "null"; 
              $NM_val_null[] = "date_deces";
          } 
          if ($this->date_prelevements == "")  
          { 
              $this->date_prelevements = "null"; 
              $NM_val_null[] = "date_prelevements";
          } 
          if ($this->date_reception_prelevement == "")  
          { 
              $this->date_reception_prelevement = "null"; 
              $NM_val_null[] = "date_reception_prelevement";
          } 
          if ($this->date_resultats_labo == "")  
          { 
              $this->date_resultats_labo = "null"; 
              $NM_val_null[] = "date_resultats_labo";
          } 
          $this->type_prelevement_nm_fk_before_qstr = $this->type_prelevement_nm_fk;
          $this->type_prelevement_nm_fk = substr($this->Db->qstr($this->type_prelevement_nm_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->type_prelevement_nm_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->type_prelevement_nm_fk);
          }
          if ($this->type_prelevement_nm_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->type_prelevement_nm_fk = "null"; 
              $NM_val_null[] = "type_prelevement_nm_fk";
          } 
          $this->resultats_labo_before_qstr = $this->resultats_labo;
          $this->resultats_labo = substr($this->Db->qstr($this->resultats_labo), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->resultats_labo = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->resultats_labo);
          }
          if ($this->resultats_labo == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->resultats_labo = "null"; 
              $NM_val_null[] = "resultats_labo";
          } 
          $this->labo_destination_before_qstr = $this->labo_destination;
          $this->labo_destination = substr($this->Db->qstr($this->labo_destination), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->labo_destination = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->labo_destination);
          }
          if ($this->labo_destination == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->labo_destination = "null"; 
              $NM_val_null[] = "labo_destination";
          } 
          $this->nin_before_qstr = $this->nin;
          $this->nin = substr($this->Db->qstr($this->nin), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->nin = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->nin);
          }
          if ($this->nin == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->nin = "null"; 
              $NM_val_null[] = "nin";
          } 
          $this->commentaires_labo_before_qstr = $this->commentaires_labo;
          $this->commentaires_labo = substr($this->Db->qstr($this->commentaires_labo), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->commentaires_labo = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->commentaires_labo);
          }
          if ($this->commentaires_labo == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->commentaires_labo = "null"; 
              $NM_val_null[] = "commentaires_labo";
          } 
          $this->commentaires_semep_before_qstr = $this->commentaires_semep;
          $this->commentaires_semep = substr($this->Db->qstr($this->commentaires_semep), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->commentaires_semep = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->commentaires_semep);
          }
          if ($this->commentaires_semep == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->commentaires_semep = "null"; 
              $NM_val_null[] = "commentaires_semep";
          } 
          $this->statut_fiche_before_qstr = $this->statut_fiche;
          $this->statut_fiche = substr($this->Db->qstr($this->statut_fiche), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->statut_fiche = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->statut_fiche);
          }
          if ($this->statut_fiche == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->statut_fiche = "null"; 
              $NM_val_null[] = "statut_fiche";
          } 
          $this->autre_evolution_before_qstr = $this->autre_evolution;
          $this->autre_evolution = substr($this->Db->qstr($this->autre_evolution), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->autre_evolution = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->autre_evolution);
          }
          if ($this->autre_evolution == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->autre_evolution = "null"; 
              $NM_val_null[] = "autre_evolution";
          } 
          $this->attached_file_before_qstr = $this->attached_file;
          $this->attached_file = substr($this->Db->qstr($this->attached_file), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->attached_file = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->attached_file);
          }
          if ($this->attached_file == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->attached_file = "null"; 
              $NM_val_null[] = "attached_file";
          } 
          $this->cas_similaires_before_qstr = $this->cas_similaires;
          $this->cas_similaires = substr($this->Db->qstr($this->cas_similaires), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->cas_similaires = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->cas_similaires);
          }
          if ($this->cas_similaires == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->cas_similaires = "null"; 
              $NM_val_null[] = "cas_similaires";
          } 
          $this->unite_age_nm_fk_before_qstr = $this->unite_age_nm_fk;
          $this->unite_age_nm_fk = substr($this->Db->qstr($this->unite_age_nm_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->unite_age_nm_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->unite_age_nm_fk);
          }
          if ($this->unite_age_nm_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->unite_age_nm_fk = "null"; 
              $NM_val_null[] = "unite_age_nm_fk";
          } 
          $this->pays_origine_before_qstr = $this->pays_origine;
          $this->pays_origine = substr($this->Db->qstr($this->pays_origine), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->pays_origine = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->pays_origine);
          }
          if ($this->pays_origine == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->pays_origine = "null"; 
              $NM_val_null[] = "pays_origine";
          } 
          $this->nationalite_nm_fk_before_qstr = $this->nationalite_nm_fk;
          $this->nationalite_nm_fk = substr($this->Db->qstr($this->nationalite_nm_fk), 1, -1); 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->nationalite_nm_fk = str_replace(array("\\r\\n", "\\n", "\r\n"), array("\r\n", "\n", "\n"), $this->nationalite_nm_fk);
          }
          if ($this->nationalite_nm_fk == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->nationalite_nm_fk = "null"; 
              $NM_val_null[] = "nationalite_nm_fk";
          } 
      }
      if ($this->nmgp_opcao == "alterar") 
      {
          $SC_fields_update = array(); 
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['decimal_db'] == ",") 
          {
              $this->nm_poe_aspas_decimal();
          }
          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 id_fiche_ps = $this->id_fiche_ps ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps ";
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              if ($this->NM_ajax_flag)
              {
                 form_fiche_pro_sante_labo_edit_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[] = "code_fiche = '$this->code_fiche', date_declaration = #$this->date_declaration#, \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = #$this->date_reception_prelevement#, date_resultats_labo = #$this->date_resultats_labo#, type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "code_fiche = '$this->code_fiche', date_declaration = " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", date_resultats_labo = " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "code_fiche = '$this->code_fiche', date_declaration = " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", date_resultats_labo = " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "code_fiche = '$this->code_fiche', date_declaration = EXTEND('$this->date_declaration', YEAR TO FRACTION), \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = EXTEND('$this->date_reception_prelevement', YEAR TO DAY), date_resultats_labo = EXTEND('$this->date_resultats_labo', YEAR TO DAY), type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "code_fiche = '$this->code_fiche', date_declaration = " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", date_resultats_labo = " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "code_fiche = '$this->code_fiche', date_declaration = " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", date_resultats_labo = " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              else 
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET ";  
                  $SC_fields_update[] = "code_fiche = '$this->code_fiche', date_declaration = " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", \"structure\" = '$this->structure', user_fk = '$this->user_fk', date_reception_prelevement = " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", date_resultats_labo = " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", type_prelevement_nm_fk = '$this->type_prelevement_nm_fk', resultats_labo = '$this->resultats_labo', commentaires_labo = '$this->commentaires_labo'"; 
              } 
              if (isset($NM_val_form['wilaya']) && $NM_val_form['wilaya'] != $this->nmgp_dados_select['wilaya']) 
              { 
                  $SC_fields_update[] = "wilaya = '$this->wilaya'"; 
              } 
              if (isset($NM_val_form['commune']) && $NM_val_form['commune'] != $this->nmgp_dados_select['commune']) 
              { 
                  $SC_fields_update[] = "commune = '$this->commune'"; 
              } 
              if (isset($NM_val_form['nom_rapporteur']) && $NM_val_form['nom_rapporteur'] != $this->nmgp_dados_select['nom_rapporteur']) 
              { 
                  $SC_fields_update[] = "nom_rapporteur = '$this->nom_rapporteur'"; 
              } 
              if (isset($NM_val_form['tel_rapporteur']) && $NM_val_form['tel_rapporteur'] != $this->nmgp_dados_select['tel_rapporteur']) 
              { 
                  $SC_fields_update[] = "tel_rapporteur = '$this->tel_rapporteur'"; 
              } 
              if (isset($NM_val_form['email_rapporteur']) && $NM_val_form['email_rapporteur'] != $this->nmgp_dados_select['email_rapporteur']) 
              { 
                  $SC_fields_update[] = "email_rapporteur = '$this->email_rapporteur'"; 
              } 
              if (isset($NM_val_form['maladie_suspectee_nm_fk']) && $NM_val_form['maladie_suspectee_nm_fk'] != $this->nmgp_dados_select['maladie_suspectee_nm_fk']) 
              { 
                  $SC_fields_update[] = "maladie_suspectee_nm_fk = '$this->maladie_suspectee_nm_fk'"; 
              } 
              if (isset($NM_val_form['nom_malade']) && $NM_val_form['nom_malade'] != $this->nmgp_dados_select['nom_malade']) 
              { 
                  $SC_fields_update[] = "nom_malade = '$this->nom_malade'"; 
              } 
              if (isset($NM_val_form['prenom_malade']) && $NM_val_form['prenom_malade'] != $this->nmgp_dados_select['prenom_malade']) 
              { 
                  $SC_fields_update[] = "prenom_malade = '$this->prenom_malade'"; 
              } 
              if (isset($NM_val_form['date_naissance_malade']) && $NM_val_form['date_naissance_malade'] != $this->nmgp_dados_select['date_naissance_malade']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_naissance_malade = #$this->date_naissance_malade#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_naissance_malade = EXTEND('" . $this->date_naissance_malade . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_naissance_malade = " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['age_malade']) && $NM_val_form['age_malade'] != $this->nmgp_dados_select['age_malade']) 
              { 
                  $SC_fields_update[] = "age_malade = $this->age_malade"; 
              } 
              if (isset($NM_val_form['sexe_nm_fk']) && $NM_val_form['sexe_nm_fk'] != $this->nmgp_dados_select['sexe_nm_fk']) 
              { 
                  $SC_fields_update[] = "sexe_nm_fk = '$this->sexe_nm_fk'"; 
              } 
              if (isset($NM_val_form['profession_malade']) && $NM_val_form['profession_malade'] != $this->nmgp_dados_select['profession_malade']) 
              { 
                  $SC_fields_update[] = "profession_malade = '$this->profession_malade'"; 
              } 
              if (isset($NM_val_form['adresse_malade']) && $NM_val_form['adresse_malade'] != $this->nmgp_dados_select['adresse_malade']) 
              { 
                  $SC_fields_update[] = "adresse_malade = '$this->adresse_malade'"; 
              } 
              if (isset($NM_val_form['wilaya_malade']) && $NM_val_form['wilaya_malade'] != $this->nmgp_dados_select['wilaya_malade']) 
              { 
                  $SC_fields_update[] = "wilaya_malade = '$this->wilaya_malade'"; 
              } 
              if (isset($NM_val_form['commune_malade']) && $NM_val_form['commune_malade'] != $this->nmgp_dados_select['commune_malade']) 
              { 
                  $SC_fields_update[] = "commune_malade = '$this->commune_malade'"; 
              } 
              if (isset($NM_val_form['lieu_travail']) && $NM_val_form['lieu_travail'] != $this->nmgp_dados_select['lieu_travail']) 
              { 
                  $SC_fields_update[] = "lieu_travail = '$this->lieu_travail'"; 
              } 
              if (isset($NM_val_form['tel_malade']) && $NM_val_form['tel_malade'] != $this->nmgp_dados_select['tel_malade']) 
              { 
                  $SC_fields_update[] = "tel_malade = '$this->tel_malade'"; 
              } 
              if (isset($NM_val_form['email_malade']) && $NM_val_form['email_malade'] != $this->nmgp_dados_select['email_malade']) 
              { 
                  $SC_fields_update[] = "email_malade = '$this->email_malade'"; 
              } 
              if (isset($NM_val_form['lieux_frequentes']) && $NM_val_form['lieux_frequentes'] != $this->nmgp_dados_select['lieux_frequentes']) 
              { 
                  $SC_fields_update[] = "lieux_frequentes = '$this->lieux_frequentes'"; 
              } 
              if (isset($NM_val_form['date_apparition_symptomes']) && $NM_val_form['date_apparition_symptomes'] != $this->nmgp_dados_select['date_apparition_symptomes']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_apparition_symptomes = #$this->date_apparition_symptomes#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_apparition_symptomes = EXTEND('" . $this->date_apparition_symptomes . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_apparition_symptomes = " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['autres_symptomes']) && $NM_val_form['autres_symptomes'] != $this->nmgp_dados_select['autres_symptomes']) 
              { 
                  $SC_fields_update[] = "autres_symptomes = '$this->autres_symptomes'"; 
              } 
              if (isset($NM_val_form['hospitalisation']) && $NM_val_form['hospitalisation'] != $this->nmgp_dados_select['hospitalisation']) 
              { 
                  $SC_fields_update[] = "hospitalisation = '$this->hospitalisation'"; 
              } 
              if (isset($NM_val_form['date_hospitalisation']) && $NM_val_form['date_hospitalisation'] != $this->nmgp_dados_select['date_hospitalisation']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_hospitalisation = #$this->date_hospitalisation#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_hospitalisation = EXTEND('" . $this->date_hospitalisation . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_hospitalisation = " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['evacuation']) && $NM_val_form['evacuation'] != $this->nmgp_dados_select['evacuation']) 
              { 
                  $SC_fields_update[] = "evacuation = '$this->evacuation'"; 
              } 
              if (isset($NM_val_form['date_evacuation']) && $NM_val_form['date_evacuation'] != $this->nmgp_dados_select['date_evacuation']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_evacuation = #$this->date_evacuation#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_evacuation = EXTEND('" . $this->date_evacuation . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_evacuation = " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['structure_evacuation']) && $NM_val_form['structure_evacuation'] != $this->nmgp_dados_select['structure_evacuation']) 
              { 
                  $SC_fields_update[] = "structure_evacuation = '$this->structure_evacuation'"; 
              } 
              if (isset($NM_val_form['antecedent_medicaux']) && $NM_val_form['antecedent_medicaux'] != $this->nmgp_dados_select['antecedent_medicaux']) 
              { 
                  $SC_fields_update[] = "antecedent_medicaux = '$this->antecedent_medicaux'"; 
              } 
              if (isset($NM_val_form['commentaires']) && $NM_val_form['commentaires'] != $this->nmgp_dados_select['commentaires']) 
              { 
                  $SC_fields_update[] = "commentaires = '$this->commentaires'"; 
              } 
              if (isset($NM_val_form['longitude']) && $NM_val_form['longitude'] != $this->nmgp_dados_select['longitude']) 
              { 
                  $SC_fields_update[] = "longitude = $this->longitude"; 
              } 
              if (isset($NM_val_form['latitude']) && $NM_val_form['latitude'] != $this->nmgp_dados_select['latitude']) 
              { 
                  $SC_fields_update[] = "latitude = $this->latitude"; 
              } 
              if (isset($NM_val_form['envoie']) && $NM_val_form['envoie'] != $this->nmgp_dados_select['envoie']) 
              { 
                  $SC_fields_update[] = "envoie = '$this->envoie'"; 
              } 
              if (isset($NM_val_form['envoie_ack']) && $NM_val_form['envoie_ack'] != $this->nmgp_dados_select['envoie_ack']) 
              { 
                  $SC_fields_update[] = "envoie_ack = '$this->envoie_ack'"; 
              } 
              if (isset($NM_val_form['valide']) && $NM_val_form['valide'] != $this->nmgp_dados_select['valide']) 
              { 
                  $SC_fields_update[] = "valide = '$this->valide'"; 
              } 
              if (isset($NM_val_form['descr_invalidite']) && $NM_val_form['descr_invalidite'] != $this->nmgp_dados_select['descr_invalidite']) 
              { 
                  $SC_fields_update[] = "descr_invalidite = '$this->descr_invalidite'"; 
              } 
              if (isset($NM_val_form['validator_fk']) && $NM_val_form['validator_fk'] != $this->nmgp_dados_select['validator_fk']) 
              { 
                  $SC_fields_update[] = "validator_fk = '$this->validator_fk'"; 
              } 
              if (isset($NM_val_form['mobile']) && $NM_val_form['mobile'] != $this->nmgp_dados_select['mobile']) 
              { 
                  $SC_fields_update[] = "mobile = '$this->mobile'"; 
              } 
              if (isset($NM_val_form['evolution_nm_fk']) && $NM_val_form['evolution_nm_fk'] != $this->nmgp_dados_select['evolution_nm_fk']) 
              { 
                  $SC_fields_update[] = "evolution_nm_fk = '$this->evolution_nm_fk'"; 
              } 
              if (isset($NM_val_form['symptomes']) && $NM_val_form['symptomes'] != $this->nmgp_dados_select['symptomes']) 
              { 
                  $SC_fields_update[] = "symptomes = '$this->symptomes'"; 
              } 
              if (isset($NM_val_form['device_id']) && $NM_val_form['device_id'] != $this->nmgp_dados_select['device_id']) 
              { 
                  $SC_fields_update[] = "device_id = '$this->device_id'"; 
              } 
              if (isset($NM_val_form['maladie_suspectee_by_ia']) && $NM_val_form['maladie_suspectee_by_ia'] != $this->nmgp_dados_select['maladie_suspectee_by_ia']) 
              { 
                  $SC_fields_update[] = "maladie_suspectee_by_ia = '$this->maladie_suspectee_by_ia'"; 
              } 
              if (isset($NM_val_form['deleted']) && $NM_val_form['deleted'] != $this->nmgp_dados_select['deleted']) 
              { 
                  $SC_fields_update[] = "deleted = '$this->deleted'"; 
              } 
              if (isset($NM_val_form['date_validation']) && $NM_val_form['date_validation'] != $this->nmgp_dados_select['date_validation']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_validation = #$this->date_validation#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_validation = EXTEND('" . $this->date_validation . "', YEAR TO FRACTION)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_validation = " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['user_labo_fk']) && $NM_val_form['user_labo_fk'] != $this->nmgp_dados_select['user_labo_fk']) 
              { 
                  $SC_fields_update[] = "user_labo_fk = '$this->user_labo_fk'"; 
              } 
              if (isset($NM_val_form['date_confirmation_labo']) && $NM_val_form['date_confirmation_labo'] != $this->nmgp_dados_select['date_confirmation_labo']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_confirmation_labo = #$this->date_confirmation_labo#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_confirmation_labo = EXTEND('" . $this->date_confirmation_labo . "', YEAR TO FRACTION)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_confirmation_labo = " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['maladie_confirmee_labo']) && $NM_val_form['maladie_confirmee_labo'] != $this->nmgp_dados_select['maladie_confirmee_labo']) 
              { 
                  $SC_fields_update[] = "maladie_confirmee_labo = '$this->maladie_confirmee_labo'"; 
              } 
              if (isset($NM_val_form['statut_maladie']) && $NM_val_form['statut_maladie'] != $this->nmgp_dados_select['statut_maladie']) 
              { 
                  $SC_fields_update[] = "statut_maladie = '$this->statut_maladie'"; 
              } 
              if (isset($NM_val_form['date_sortie']) && $NM_val_form['date_sortie'] != $this->nmgp_dados_select['date_sortie']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_sortie = #$this->date_sortie#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_sortie = EXTEND('" . $this->date_sortie . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_sortie = " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['date_deces']) && $NM_val_form['date_deces'] != $this->nmgp_dados_select['date_deces']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_deces = #$this->date_deces#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_deces = EXTEND('" . $this->date_deces . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_deces = " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['date_prelevements']) && $NM_val_form['date_prelevements'] != $this->nmgp_dados_select['date_prelevements']) 
              { 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $SC_fields_update[] = "date_prelevements = #$this->date_prelevements#"; 
                  } 
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $SC_fields_update[] = "date_prelevements = EXTEND('" . $this->date_prelevements . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $SC_fields_update[] = "date_prelevements = " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ""; 
                  } 
              } 
              if (isset($NM_val_form['labo_destination']) && $NM_val_form['labo_destination'] != $this->nmgp_dados_select['labo_destination']) 
              { 
                  $SC_fields_update[] = "labo_destination = '$this->labo_destination'"; 
              } 
              if (isset($NM_val_form['nin']) && $NM_val_form['nin'] != $this->nmgp_dados_select['nin']) 
              { 
                  $SC_fields_update[] = "nin = '$this->nin'"; 
              } 
              if (isset($NM_val_form['commentaires_semep']) && $NM_val_form['commentaires_semep'] != $this->nmgp_dados_select['commentaires_semep']) 
              { 
                  $SC_fields_update[] = "commentaires_semep = '$this->commentaires_semep'"; 
              } 
              if (isset($NM_val_form['statut_fiche']) && $NM_val_form['statut_fiche'] != $this->nmgp_dados_select['statut_fiche']) 
              { 
                  $SC_fields_update[] = "statut_fiche = '$this->statut_fiche'"; 
              } 
              if (isset($NM_val_form['autre_evolution']) && $NM_val_form['autre_evolution'] != $this->nmgp_dados_select['autre_evolution']) 
              { 
                  $SC_fields_update[] = "autre_evolution = '$this->autre_evolution'"; 
              } 
              if (isset($NM_val_form['cas_similaires']) && $NM_val_form['cas_similaires'] != $this->nmgp_dados_select['cas_similaires']) 
              { 
                  $SC_fields_update[] = "cas_similaires = '$this->cas_similaires'"; 
              } 
              if (isset($NM_val_form['unite_age_nm_fk']) && $NM_val_form['unite_age_nm_fk'] != $this->nmgp_dados_select['unite_age_nm_fk']) 
              { 
                  $SC_fields_update[] = "unite_age_nm_fk = '$this->unite_age_nm_fk'"; 
              } 
              if (isset($NM_val_form['pays_origine']) && $NM_val_form['pays_origine'] != $this->nmgp_dados_select['pays_origine']) 
              { 
                  $SC_fields_update[] = "pays_origine = '$this->pays_origine'"; 
              } 
              if (isset($NM_val_form['nationalite_nm_fk']) && $NM_val_form['nationalite_nm_fk'] != $this->nmgp_dados_select['nationalite_nm_fk']) 
              { 
                  $SC_fields_update[] = "nationalite_nm_fk = '$this->nationalite_nm_fk'"; 
              } 
              $aEraseFiles  = array();
              $temp_cmd_sql = "";
              if ($this->attached_file_limpa == "S")
              {
                  $sDirErase     = $this->Ini->root . $this->Ini->path_imagens . "/attached_files" . "/";
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['attached_file']);
                  if ($this->attached_file != "null")
                  {
                      $this->attached_file = '';
                  }
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                  {
                      $temp_cmd_sql = "attached_file = '" . $this->attached_file . "'";
                  }
                  else
                  {
                      $temp_cmd_sql = "attached_file = '" . $this->attached_file . "'";
                  }
                  $this->attached_file = "";
              }
              else
              {
                  if ($this->attached_file != "none" && $this->attached_file != "")
                  {
                      $NM_conteudo =  $this->attached_file;
                      if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
                      {
                      $temp_cmd_sql .= " attached_file = '$NM_conteudo'";
                      }
                      else
                      {
                          $temp_cmd_sql .= " attached_file = '$NM_conteudo'";
                      }
                  }
                  else
                  {
                      $aDoNotUpdate[] = "attached_file";
                  }
              }
              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 id_fiche_ps = $this->id_fiche_ps ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $comando .= " WHERE id_fiche_ps = $this->id_fiche_ps ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $comando .= " WHERE id_fiche_ps = $this->id_fiche_ps ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $comando .= " WHERE id_fiche_ps = $this->id_fiche_ps ";  
              }  
              else  
              {
                  $comando .= " WHERE id_fiche_ps = $this->id_fiche_ps ";  
              }  
              $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) ; 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                $comando = str_replace("EXTEND('', YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND('', YEAR TO DAY)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO DAY)", "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)
                              {
                                  form_fiche_pro_sante_labo_edit_pack_ajax_response();
                              }
                              exit;  
                          }   
                      }   
                  }   
              }   
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql)) 
              { 
              }   
              $this->code_fiche = $this->code_fiche_before_qstr;
              $this->wilaya = $this->wilaya_before_qstr;
              $this->commune = $this->commune_before_qstr;
              $this->structure = $this->structure_before_qstr;
              $this->nom_rapporteur = $this->nom_rapporteur_before_qstr;
              $this->tel_rapporteur = $this->tel_rapporteur_before_qstr;
              $this->email_rapporteur = $this->email_rapporteur_before_qstr;
              $this->maladie_suspectee_nm_fk = $this->maladie_suspectee_nm_fk_before_qstr;
              $this->nom_malade = $this->nom_malade_before_qstr;
              $this->prenom_malade = $this->prenom_malade_before_qstr;
              $this->sexe_nm_fk = $this->sexe_nm_fk_before_qstr;
              $this->profession_malade = $this->profession_malade_before_qstr;
              $this->adresse_malade = $this->adresse_malade_before_qstr;
              $this->wilaya_malade = $this->wilaya_malade_before_qstr;
              $this->commune_malade = $this->commune_malade_before_qstr;
              $this->lieu_travail = $this->lieu_travail_before_qstr;
              $this->tel_malade = $this->tel_malade_before_qstr;
              $this->email_malade = $this->email_malade_before_qstr;
              $this->lieux_frequentes = $this->lieux_frequentes_before_qstr;
              $this->autres_symptomes = $this->autres_symptomes_before_qstr;
              $this->hospitalisation = $this->hospitalisation_before_qstr;
              $this->evacuation = $this->evacuation_before_qstr;
              $this->structure_evacuation = $this->structure_evacuation_before_qstr;
              $this->antecedent_medicaux = $this->antecedent_medicaux_before_qstr;
              $this->commentaires = $this->commentaires_before_qstr;
              $this->envoie = $this->envoie_before_qstr;
              $this->envoie_ack = $this->envoie_ack_before_qstr;
              $this->valide = $this->valide_before_qstr;
              $this->descr_invalidite = $this->descr_invalidite_before_qstr;
              $this->user_fk = $this->user_fk_before_qstr;
              $this->validator_fk = $this->validator_fk_before_qstr;
              $this->mobile = $this->mobile_before_qstr;
              $this->evolution_nm_fk = $this->evolution_nm_fk_before_qstr;
              $this->symptomes = $this->symptomes_before_qstr;
              $this->device_id = $this->device_id_before_qstr;
              $this->maladie_suspectee_by_ia = $this->maladie_suspectee_by_ia_before_qstr;
              $this->deleted = $this->deleted_before_qstr;
              $this->user_labo_fk = $this->user_labo_fk_before_qstr;
              $this->maladie_confirmee_labo = $this->maladie_confirmee_labo_before_qstr;
              $this->statut_maladie = $this->statut_maladie_before_qstr;
              $this->type_prelevement_nm_fk = $this->type_prelevement_nm_fk_before_qstr;
              $this->resultats_labo = $this->resultats_labo_before_qstr;
              $this->labo_destination = $this->labo_destination_before_qstr;
              $this->nin = $this->nin_before_qstr;
              $this->commentaires_labo = $this->commentaires_labo_before_qstr;
              $this->commentaires_semep = $this->commentaires_semep_before_qstr;
              $this->statut_fiche = $this->statut_fiche_before_qstr;
              $this->autre_evolution = $this->autre_evolution_before_qstr;
              $this->attached_file = $this->attached_file_before_qstr;
              $this->cas_similaires = $this->cas_similaires_before_qstr;
              $this->unite_age_nm_fk = $this->unite_age_nm_fk_before_qstr;
              $this->pays_origine = $this->pays_origine_before_qstr;
              $this->nationalite_nm_fk = $this->nationalite_nm_fk_before_qstr;
              if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
              { 
              }   
              if ($this->attached_file_limpa == "S")
              {
                  $this->NM_ajax_info['fldList']['attached_file_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;
              }
              $this->NM_gera_log_new();
              $this->NM_gera_log_compress();

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


              if     (isset($NM_val_form) && isset($NM_val_form['code_fiche'])) { $this->code_fiche = $NM_val_form['code_fiche']; }
              elseif (isset($this->code_fiche)) { $this->nm_limpa_alfa($this->code_fiche); }
              if     (isset($NM_val_form) && isset($NM_val_form['structure'])) { $this->structure = $NM_val_form['structure']; }
              elseif (isset($this->structure)) { $this->nm_limpa_alfa($this->structure); }
              if     (isset($NM_val_form) && isset($NM_val_form['maladie_suspectee_nm_fk'])) { $this->maladie_suspectee_nm_fk = $NM_val_form['maladie_suspectee_nm_fk']; }
              elseif (isset($this->maladie_suspectee_nm_fk)) { $this->nm_limpa_alfa($this->maladie_suspectee_nm_fk); }
              if     (isset($NM_val_form) && isset($NM_val_form['commentaires'])) { $this->commentaires = $NM_val_form['commentaires']; }
              elseif (isset($this->commentaires)) { $this->nm_limpa_alfa($this->commentaires); }
              if     (isset($NM_val_form) && isset($NM_val_form['user_fk'])) { $this->user_fk = $NM_val_form['user_fk']; }
              elseif (isset($this->user_fk)) { $this->nm_limpa_alfa($this->user_fk); }
              if     (isset($NM_val_form) && isset($NM_val_form['type_prelevement_nm_fk'])) { $this->type_prelevement_nm_fk = $NM_val_form['type_prelevement_nm_fk']; }
              elseif (isset($this->type_prelevement_nm_fk)) { $this->nm_limpa_alfa($this->type_prelevement_nm_fk); }
              if     (isset($NM_val_form) && isset($NM_val_form['resultats_labo'])) { $this->resultats_labo = $NM_val_form['resultats_labo']; }
              elseif (isset($this->resultats_labo)) { $this->nm_limpa_alfa($this->resultats_labo); }
              if     (isset($NM_val_form) && isset($NM_val_form['commentaires_labo'])) { $this->commentaires_labo = $NM_val_form['commentaires_labo']; }
              elseif (isset($this->commentaires_labo)) { $this->nm_limpa_alfa($this->commentaires_labo); }

              $this->nm_formatar_campos();
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
              }

              $aOldRefresh               = $this->nmgp_refresh_fields;
              $this->nmgp_refresh_fields = array_diff(array('code_fiche', 'date_declaration', 'structure', 'user_fk', 'maladie_suspectee_nm_fk', 'type_prelevement_nm_fk', 'date_reception_prelevement', 'date_resultats_labo', 'resultats_labo', 'commentaires', 'commentaires_labo'), $aDoNotUpdate);
              $this->ajax_return_values();
              $this->nmgp_refresh_fields = $aOldRefresh;

              $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]['form_fiche_pro_sante_labo_edit']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['decimal_db'] == ",") 
          {
              $this->nm_poe_aspas_decimal();
          }
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          { 
              $NM_seq_auto = "NEXT VALUE FOR fiche_signaleqtique_prof_sante_id_fiche_ps_seq, ";
              $NM_cmp_auto = "id_fiche_ps, ";
          } 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          { 
              $NM_seq_auto = "fiche_signaleqtique_prof_sante_id_fiche_ps_seq.NEXTVAL, ";
              $NM_cmp_auto = "id_fiche_ps, ";
          } 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          { 
              $NM_seq_auto = "nextval('fiche_signaleqtique_prof_sante_id_fiche_ps_seq'), ";
              $NM_cmp_auto = "id_fiche_ps, ";
          } 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
          { 
              $NM_seq_auto = "gen_id(fiche_signaleqtique_prof_sante_id_fiche_ps_seq, 1), ";
              $NM_cmp_auto = "id_fiche_ps, ";
          } 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sqlite))
          { 
              $NM_seq_auto = "NULL, ";
              $NM_cmp_auto = "id_fiche_ps, ";
          } 
          $bInsertOk = true;
          $aInsertOk = array(); 
          $bInsertOk = $bInsertOk && empty($aInsertOk);
          if (!isset($_POST['nmgp_ins_valid']) || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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)
                  {
                      form_fiche_pro_sante_labo_edit_pack_ajax_response();
                      exit;
                  }
              }
          }
          if ($bInsertOk)
          { 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES ('$this->code_fiche', #$this->date_declaration#, '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', #$this->date_naissance_malade#, $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', #$this->date_apparition_symptomes#, '$this->autres_symptomes', '$this->hospitalisation', #$this->date_hospitalisation#, '$this->evacuation', #$this->date_evacuation#, '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', #$this->date_validation#, '$this->user_labo_fk', #$this->date_confirmation_labo#, '$this->maladie_confirmee_labo', '$this->statut_maladie', #$this->date_sortie#, #$this->date_deces#, #$this->date_prelevements#, #$this->date_reception_prelevement#, #$this->date_resultats_labo#, '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              { 
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
              { 
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', EXTEND('$this->date_declaration', YEAR TO FRACTION), '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', EXTEND('$this->date_naissance_malade', YEAR TO DAY), $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', EXTEND('$this->date_apparition_symptomes', YEAR TO DAY), '$this->autres_symptomes', '$this->hospitalisation', EXTEND('$this->date_hospitalisation', YEAR TO DAY), '$this->evacuation', EXTEND('$this->date_evacuation', YEAR TO DAY), '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', EXTEND('$this->date_validation', YEAR TO FRACTION), '$this->user_labo_fk', EXTEND('$this->date_confirmation_labo', YEAR TO FRACTION), '$this->maladie_confirmee_labo', '$this->statut_maladie', EXTEND('$this->date_sortie', YEAR TO DAY), EXTEND('$this->date_deces', YEAR TO DAY), EXTEND('$this->date_prelevements', YEAR TO DAY), EXTEND('$this->date_reception_prelevement', YEAR TO DAY), EXTEND('$this->date_resultats_labo', YEAR TO DAY), '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sqlite))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              elseif ($this->Ini->nm_tpbanco == 'pdo_ibm')
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              else
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk) VALUES (" . $NM_seq_auto . "'$this->code_fiche', " . $this->Ini->date_delim . $this->date_declaration . $this->Ini->date_delim1 . ", '$this->wilaya', '$this->commune', '$this->structure', '$this->nom_rapporteur', '$this->tel_rapporteur', '$this->email_rapporteur', '$this->maladie_suspectee_nm_fk', '$this->nom_malade', '$this->prenom_malade', " . $this->Ini->date_delim . $this->date_naissance_malade . $this->Ini->date_delim1 . ", $this->age_malade, '$this->sexe_nm_fk', '$this->profession_malade', '$this->adresse_malade', '$this->wilaya_malade', '$this->commune_malade', '$this->lieu_travail', '$this->tel_malade', '$this->email_malade', '$this->lieux_frequentes', " . $this->Ini->date_delim . $this->date_apparition_symptomes . $this->Ini->date_delim1 . ", '$this->autres_symptomes', '$this->hospitalisation', " . $this->Ini->date_delim . $this->date_hospitalisation . $this->Ini->date_delim1 . ", '$this->evacuation', " . $this->Ini->date_delim . $this->date_evacuation . $this->Ini->date_delim1 . ", '$this->structure_evacuation', '$this->antecedent_medicaux', '$this->commentaires', $this->longitude, $this->latitude, '$this->envoie', '$this->envoie_ack', '$this->valide', '$this->descr_invalidite', '$this->user_fk', '$this->validator_fk', '$this->mobile', '$this->evolution_nm_fk', '$this->symptomes', '$this->device_id', '$this->maladie_suspectee_by_ia', '$this->deleted', " . $this->Ini->date_delim . $this->date_validation . $this->Ini->date_delim1 . ", '$this->user_labo_fk', " . $this->Ini->date_delim . $this->date_confirmation_labo . $this->Ini->date_delim1 . ", '$this->maladie_confirmee_labo', '$this->statut_maladie', " . $this->Ini->date_delim . $this->date_sortie . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_deces . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_prelevements . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_reception_prelevement . $this->Ini->date_delim1 . ", " . $this->Ini->date_delim . $this->date_resultats_labo . $this->Ini->date_delim1 . ", '$this->type_prelevement_nm_fk', '$this->resultats_labo', '$this->labo_destination', '$this->nin', '$this->commentaires_labo', '$this->commentaires_semep', '$this->statut_fiche', '$this->autre_evolution', '$this->attached_file', '$this->cas_similaires', '$this->unite_age_nm_fk', '$this->pays_origine', '$this->nationalite_nm_fk')"; 
              }
              $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) ; 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                $comando = str_replace("EXTEND('', YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND('', YEAR TO DAY)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO DAY)", "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)
                          {
                              form_fiche_pro_sante_labo_edit_pack_ajax_response();
                              exit; 
                          }
                      }  
                  }  
              }  
              if ('refresh_insert' != $this->nmgp_opcao)
              {
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase)) 
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select @@identity"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      $this->NM_rollback_db(); 
                      if ($this->NM_ajax_flag)
                      {
                          form_fiche_pro_sante_labo_edit_pack_ajax_response();
                      }
                      exit; 
                  } 
                  $this->id_fiche_ps =  $rsy->fields[0];
                 $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select last_insert_id()"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SELECT dbinfo('sqlca.sqlerrd1') FROM " . $this->Ini->nm_tabela; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select fiche_signaleqtique_prof_sante_id_fiche_ps_seq.currval from dual"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "values PREVVAL FOR fiche_signaleqtique_prof_sante_id_fiche_ps_seq"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select CURRVAL('fiche_signaleqtique_prof_sante_id_fiche_ps_seq')"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select gen_id(fiche_signaleqtique_prof_sante_id_fiche_ps_seq, 0) from " . $this->Ini->nm_tabela; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sqlite))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select last_insert_rowid()"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id_fiche_ps = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              $this->code_fiche = $this->code_fiche_before_qstr;
              $this->wilaya = $this->wilaya_before_qstr;
              $this->commune = $this->commune_before_qstr;
              $this->structure = $this->structure_before_qstr;
              $this->nom_rapporteur = $this->nom_rapporteur_before_qstr;
              $this->tel_rapporteur = $this->tel_rapporteur_before_qstr;
              $this->email_rapporteur = $this->email_rapporteur_before_qstr;
              $this->maladie_suspectee_nm_fk = $this->maladie_suspectee_nm_fk_before_qstr;
              $this->nom_malade = $this->nom_malade_before_qstr;
              $this->prenom_malade = $this->prenom_malade_before_qstr;
              $this->sexe_nm_fk = $this->sexe_nm_fk_before_qstr;
              $this->profession_malade = $this->profession_malade_before_qstr;
              $this->adresse_malade = $this->adresse_malade_before_qstr;
              $this->wilaya_malade = $this->wilaya_malade_before_qstr;
              $this->commune_malade = $this->commune_malade_before_qstr;
              $this->lieu_travail = $this->lieu_travail_before_qstr;
              $this->tel_malade = $this->tel_malade_before_qstr;
              $this->email_malade = $this->email_malade_before_qstr;
              $this->lieux_frequentes = $this->lieux_frequentes_before_qstr;
              $this->autres_symptomes = $this->autres_symptomes_before_qstr;
              $this->hospitalisation = $this->hospitalisation_before_qstr;
              $this->evacuation = $this->evacuation_before_qstr;
              $this->structure_evacuation = $this->structure_evacuation_before_qstr;
              $this->antecedent_medicaux = $this->antecedent_medicaux_before_qstr;
              $this->commentaires = $this->commentaires_before_qstr;
              $this->envoie = $this->envoie_before_qstr;
              $this->envoie_ack = $this->envoie_ack_before_qstr;
              $this->valide = $this->valide_before_qstr;
              $this->descr_invalidite = $this->descr_invalidite_before_qstr;
              $this->user_fk = $this->user_fk_before_qstr;
              $this->validator_fk = $this->validator_fk_before_qstr;
              $this->mobile = $this->mobile_before_qstr;
              $this->evolution_nm_fk = $this->evolution_nm_fk_before_qstr;
              $this->symptomes = $this->symptomes_before_qstr;
              $this->device_id = $this->device_id_before_qstr;
              $this->maladie_suspectee_by_ia = $this->maladie_suspectee_by_ia_before_qstr;
              $this->deleted = $this->deleted_before_qstr;
              $this->user_labo_fk = $this->user_labo_fk_before_qstr;
              $this->maladie_confirmee_labo = $this->maladie_confirmee_labo_before_qstr;
              $this->statut_maladie = $this->statut_maladie_before_qstr;
              $this->type_prelevement_nm_fk = $this->type_prelevement_nm_fk_before_qstr;
              $this->resultats_labo = $this->resultats_labo_before_qstr;
              $this->labo_destination = $this->labo_destination_before_qstr;
              $this->nin = $this->nin_before_qstr;
              $this->commentaires_labo = $this->commentaires_labo_before_qstr;
              $this->commentaires_semep = $this->commentaires_semep_before_qstr;
              $this->statut_fiche = $this->statut_fiche_before_qstr;
              $this->autre_evolution = $this->autre_evolution_before_qstr;
              $this->attached_file = $this->attached_file_before_qstr;
              $this->cas_similaires = $this->cas_similaires_before_qstr;
              $this->unite_age_nm_fk = $this->unite_age_nm_fk_before_qstr;
              $this->pays_origine = $this->pays_origine_before_qstr;
              $this->nationalite_nm_fk = $this->nationalite_nm_fk_before_qstr;
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql)) 
              { 
              }   
              }

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

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

              $dir_img = $this->Ini->root . $this->Ini->path_imagens . "/attached_files" . "/"; 
              if (nm_mkdir($dir_img))  
              { 
                  $reg_attached_file = ""; 
                  if (is_file($this->SC_IMG_attached_file)) { 
                      $arq_attached_file = fopen($this->SC_IMG_attached_file, "r") ; 
                      $reg_attached_file = fread($arq_attached_file, filesize($this->SC_IMG_attached_file)) ; 
                      fclose($arq_attached_file) ;  
                      $arq_attached_file = fopen($dir_img . trim($this->attached_file_scfile_name), "w") ; 
                      fwrite($arq_attached_file, $reg_attached_file) ;  
                      fclose($arq_attached_file) ;  
                  }
              } 
              $this->sc_evento = "insert"; 
              $this->code_fiche = $this->code_fiche_before_qstr;
              $this->wilaya = $this->wilaya_before_qstr;
              $this->commune = $this->commune_before_qstr;
              $this->structure = $this->structure_before_qstr;
              $this->nom_rapporteur = $this->nom_rapporteur_before_qstr;
              $this->tel_rapporteur = $this->tel_rapporteur_before_qstr;
              $this->email_rapporteur = $this->email_rapporteur_before_qstr;
              $this->maladie_suspectee_nm_fk = $this->maladie_suspectee_nm_fk_before_qstr;
              $this->nom_malade = $this->nom_malade_before_qstr;
              $this->prenom_malade = $this->prenom_malade_before_qstr;
              $this->sexe_nm_fk = $this->sexe_nm_fk_before_qstr;
              $this->profession_malade = $this->profession_malade_before_qstr;
              $this->adresse_malade = $this->adresse_malade_before_qstr;
              $this->wilaya_malade = $this->wilaya_malade_before_qstr;
              $this->commune_malade = $this->commune_malade_before_qstr;
              $this->lieu_travail = $this->lieu_travail_before_qstr;
              $this->tel_malade = $this->tel_malade_before_qstr;
              $this->email_malade = $this->email_malade_before_qstr;
              $this->lieux_frequentes = $this->lieux_frequentes_before_qstr;
              $this->autres_symptomes = $this->autres_symptomes_before_qstr;
              $this->hospitalisation = $this->hospitalisation_before_qstr;
              $this->evacuation = $this->evacuation_before_qstr;
              $this->structure_evacuation = $this->structure_evacuation_before_qstr;
              $this->antecedent_medicaux = $this->antecedent_medicaux_before_qstr;
              $this->commentaires = $this->commentaires_before_qstr;
              $this->envoie = $this->envoie_before_qstr;
              $this->envoie_ack = $this->envoie_ack_before_qstr;
              $this->valide = $this->valide_before_qstr;
              $this->descr_invalidite = $this->descr_invalidite_before_qstr;
              $this->user_fk = $this->user_fk_before_qstr;
              $this->validator_fk = $this->validator_fk_before_qstr;
              $this->mobile = $this->mobile_before_qstr;
              $this->evolution_nm_fk = $this->evolution_nm_fk_before_qstr;
              $this->symptomes = $this->symptomes_before_qstr;
              $this->device_id = $this->device_id_before_qstr;
              $this->maladie_suspectee_by_ia = $this->maladie_suspectee_by_ia_before_qstr;
              $this->deleted = $this->deleted_before_qstr;
              $this->user_labo_fk = $this->user_labo_fk_before_qstr;
              $this->maladie_confirmee_labo = $this->maladie_confirmee_labo_before_qstr;
              $this->statut_maladie = $this->statut_maladie_before_qstr;
              $this->type_prelevement_nm_fk = $this->type_prelevement_nm_fk_before_qstr;
              $this->resultats_labo = $this->resultats_labo_before_qstr;
              $this->labo_destination = $this->labo_destination_before_qstr;
              $this->nin = $this->nin_before_qstr;
              $this->commentaires_labo = $this->commentaires_labo_before_qstr;
              $this->commentaires_semep = $this->commentaires_semep_before_qstr;
              $this->statut_fiche = $this->statut_fiche_before_qstr;
              $this->autre_evolution = $this->autre_evolution_before_qstr;
              $this->attached_file = $this->attached_file_before_qstr;
              $this->cas_similaires = $this->cas_similaires_before_qstr;
              $this->unite_age_nm_fk = $this->unite_age_nm_fk_before_qstr;
              $this->pays_origine = $this->pays_origine_before_qstr;
              $this->nationalite_nm_fk = $this->nationalite_nm_fk_before_qstr;
              if (empty($this->sc_erro_insert)) {
                  $this->record_insert_ok = true;
              } 
              $this->NM_gera_log_key("incluir");
              $this->NM_gera_log_new();
              if ('refresh_insert' != $this->nmgp_opcao && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['sc_redir_insert']) || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['sc_redir_insert'] != "S"))
              {
              $this->nmgp_opcao = "novo"; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "R")
              { 
                   $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['return_edit'] = "new";
              } 
              }
              $this->nm_flag_iframe = true;
          } 
          if ($this->lig_edit_lookup)
          {
              $this->lig_edit_lookup_call = true;
          }
      } 
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['decimal_db'] == ",") 
      {
          $this->nm_tira_aspas_decimal();
      }
      if ($this->nmgp_opcao == "excluir") 
      { 
          $this->id_fiche_ps = substr($this->Db->qstr($this->id_fiche_ps), 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 id_fiche_ps = $this->id_fiche_ps"; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps"; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps"; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps"; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps"; 
              $rs1 = $this->Db->Execute("select count(*) AS countTest from " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
          }  
          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 id_fiche_ps = $this->id_fiche_ps "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
              }  
              else  
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where id_fiche_ps = $this->id_fiche_ps "); 
              }  
              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)
                      {
                          form_fiche_pro_sante_labo_edit_pack_ajax_response();
                          exit; 
                      }
                  } 
              } 
                  $sDirErase     = $this->Ini->root . $this->Ini->path_imagens . "/attached_files" . "/"; 
                  $aEraseFiles[] = array('dir' => $sDirErase, 'file' => $this->nmgp_dados_form['attached_file']);
              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]['form_fiche_pro_sante_labo_edit']['reg_start']--; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start'] < 0)
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start'] = 0; 
              }

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

              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['total']))
              {
                  unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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); 
          }

      }  
      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($NM_val_null))
      {
          foreach ($NM_val_null as $i_val_null => $sc_val_null_field)
          {
              eval('$this->' . $sc_val_null_field . ' = "";');
          }
      }
      if ($salva_opcao == "incluir" && $GLOBALS["erro_incl"] != 1) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['parms'] = "id_fiche_ps?#?$this->id_fiche_ps?@?"; 
      }
      $this->nmgp_dados_form['attached_file'] = ""; 
      $this->attached_file_limpa = ""; 
      $this->attached_file_salva = ""; 
      $this->NM_commit_db(); 
      if ($this->sc_evento != "insert" && $this->sc_evento != "update" && $this->sc_evento != "delete")
      { 
          $this->id_fiche_ps = null === $this->id_fiche_ps ? null : substr($this->Db->qstr($this->id_fiche_ps), 1, -1); 
      } 
      if (isset($this->NM_where_filter))
      {
          $this->NM_where_filter = str_replace("@percent@", "%", $this->NM_where_filter);
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter'] = trim($this->NM_where_filter);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['total']))
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['total']);
          }
      }
      $sc_where_filter = '';
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter_form'])
      {
          $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter_form'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter'] && $sc_where_filter != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter'])
      {
          if (empty($sc_where_filter))
          {
              $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter'];
          }
          else
          {
              $sc_where_filter .= " and (" . $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['parms'] = ""; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 1;  
          } 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
          { 
              $nmgp_select = "SELECT id_fiche_ps, code_fiche, str_replace (convert(char(10),date_declaration,102), '.', '-') + ' ' + convert(char(8),date_declaration,20), wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, str_replace (convert(char(10),date_naissance_malade,102), '.', '-') + ' ' + convert(char(8),date_naissance_malade,20), age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, str_replace (convert(char(10),date_apparition_symptomes,102), '.', '-') + ' ' + convert(char(8),date_apparition_symptomes,20), autres_symptomes, hospitalisation, str_replace (convert(char(10),date_hospitalisation,102), '.', '-') + ' ' + convert(char(8),date_hospitalisation,20), evacuation, str_replace (convert(char(10),date_evacuation,102), '.', '-') + ' ' + convert(char(8),date_evacuation,20), structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, str_replace (convert(char(10),date_validation,102), '.', '-') + ' ' + convert(char(8),date_validation,20), user_labo_fk, str_replace (convert(char(10),date_confirmation_labo,102), '.', '-') + ' ' + convert(char(8),date_confirmation_labo,20), maladie_confirmee_labo, statut_maladie, str_replace (convert(char(10),date_sortie,102), '.', '-') + ' ' + convert(char(8),date_sortie,20), str_replace (convert(char(10),date_deces,102), '.', '-') + ' ' + convert(char(8),date_deces,20), str_replace (convert(char(10),date_prelevements,102), '.', '-') + ' ' + convert(char(8),date_prelevements,20), str_replace (convert(char(10),date_reception_prelevement,102), '.', '-') + ' ' + convert(char(8),date_reception_prelevement,20), str_replace (convert(char(10),date_resultats_labo,102), '.', '-') + ' ' + convert(char(8),date_resultats_labo,20), type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk from " . $this->Ini->nm_tabela ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          { 
              $nmgp_select = "SELECT id_fiche_ps, code_fiche, convert(char(23),date_declaration,121), wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, convert(char(23),date_naissance_malade,121), age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, convert(char(23),date_apparition_symptomes,121), autres_symptomes, hospitalisation, convert(char(23),date_hospitalisation,121), evacuation, convert(char(23),date_evacuation,121), structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, convert(char(23),date_validation,121), user_labo_fk, convert(char(23),date_confirmation_labo,121), maladie_confirmee_labo, statut_maladie, convert(char(23),date_sortie,121), convert(char(23),date_deces,121), convert(char(23),date_prelevements,121), convert(char(23),date_reception_prelevement,121), convert(char(23),date_resultats_labo,121), type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk from " . $this->Ini->nm_tabela ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          { 
              $nmgp_select = "SELECT id_fiche_ps, code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk from " . $this->Ini->nm_tabela ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          { 
              $nmgp_select = "SELECT id_fiche_ps, code_fiche, EXTEND(date_declaration, YEAR TO FRACTION), wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, EXTEND(date_naissance_malade, YEAR TO DAY), age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, EXTEND(date_apparition_symptomes, YEAR TO DAY), autres_symptomes, hospitalisation, EXTEND(date_hospitalisation, YEAR TO DAY), evacuation, EXTEND(date_evacuation, YEAR TO DAY), structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, EXTEND(date_validation, YEAR TO FRACTION), user_labo_fk, EXTEND(date_confirmation_labo, YEAR TO FRACTION), maladie_confirmee_labo, statut_maladie, EXTEND(date_sortie, YEAR TO DAY), EXTEND(date_deces, YEAR TO DAY), EXTEND(date_prelevements, YEAR TO DAY), EXTEND(date_reception_prelevement, YEAR TO DAY), EXTEND(date_resultats_labo, YEAR TO DAY), type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk from " . $this->Ini->nm_tabela ; 
          } 
          else 
          { 
              $nmgp_select = "SELECT id_fiche_ps, code_fiche, date_declaration, wilaya, commune, \"structure\", nom_rapporteur, tel_rapporteur, email_rapporteur, maladie_suspectee_nm_fk, nom_malade, prenom_malade, date_naissance_malade, age_malade, sexe_nm_fk, profession_malade, adresse_malade, wilaya_malade, commune_malade, lieu_travail, tel_malade, email_malade, lieux_frequentes, date_apparition_symptomes, autres_symptomes, hospitalisation, date_hospitalisation, evacuation, date_evacuation, structure_evacuation, antecedent_medicaux, commentaires, longitude, latitude, envoie, envoie_ack, valide, descr_invalidite, user_fk, validator_fk, mobile, evolution_nm_fk, symptomes, device_id, maladie_suspectee_by_ia, deleted, date_validation, user_labo_fk, date_confirmation_labo, maladie_confirmee_labo, statut_maladie, date_sortie, date_deces, date_prelevements, date_reception_prelevement, date_resultats_labo, type_prelevement_nm_fk, resultats_labo, labo_destination, nin, commentaires_labo, commentaires_semep, statut_fiche, autre_evolution, attached_file, cas_similaires, unite_age_nm_fk, pays_origine, nationalite_nm_fk from " . $this->Ini->nm_tabela ; 
          } 
          $aWhere = array();
          $aWhere[] = "(code_fiche = '" . $_SESSION['var_code_fiche'] . "')";
          $aWhere[] = $sc_where_filter;
          if ($this->nmgp_opcao == "igual" || (($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "R") && ($this->sc_evento == "insert" || $this->sc_evento == "update")) )
          { 
              if (!empty($sc_where))
              {
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  {
                     $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
                  {
                     $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
                  {
                     $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  {
                     $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  else  
                  {
                     $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }
              } 
              else
              {
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  {
                      $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
                  {
                      $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
                  {
                      $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  {
                      $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }  
                  else  
                  {
                      $aWhere[] = "id_fiche_ps = $this->id_fiche_ps"; 
                  }
              } 
          } 
          $nmgp_select .= $this->returnWhere($aWhere) . ' ';
          $sc_order_by = "";
          $sc_order_by = "id_fiche_ps";
          $sc_order_by = str_replace("order by ", "", $sc_order_by);
          $sc_order_by = str_replace("ORDER BY ", "", trim($sc_order_by));
          if (!empty($sc_order_by))
          {
              $nmgp_select .= " order by $sc_order_by "; 
          }
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "R")
          {
              if ($this->sc_evento == "update")
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['select'] = $nmgp_select;
                  $this->nm_gera_html();
              } 
              elseif (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['select']))
              { 
                  $nmgp_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['select'];
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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_oracle) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start']) ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start']) ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['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']['retour'] = $this->nmgp_botoes['retour'] = "off";
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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->NM_ajax_info['buttonDisplay']['update'] = $this->nmgp_botoes['update'] = "off";
              $this->NM_ajax_info['buttonDisplay']['delete'] = $this->nmgp_botoes['delete'] = "off";
              return; 
          } 
          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 ($this->nmgp_opcao != "novo") 
          { 
              $this->id_fiche_ps = $rs->fields[0] ; 
              $this->nmgp_dados_select['id_fiche_ps'] = $this->id_fiche_ps;
              $this->code_fiche = $rs->fields[1] ; 
              $this->nmgp_dados_select['code_fiche'] = $this->code_fiche;
              $this->date_declaration = $rs->fields[2] ; 
              if (substr($this->date_declaration, 10, 1) == "-") 
              { 
                 $this->date_declaration = substr($this->date_declaration, 0, 10) . " " . substr($this->date_declaration, 11);
              } 
              if (substr($this->date_declaration, 13, 1) == ".") 
              { 
                 $this->date_declaration = substr($this->date_declaration, 0, 13) . ":" . substr($this->date_declaration, 14, 2) . ":" . substr($this->date_declaration, 17);
              } 
              $this->nmgp_dados_select['date_declaration'] = $this->date_declaration;
              $this->wilaya = $rs->fields[3] ; 
              $this->nmgp_dados_select['wilaya'] = $this->wilaya;
              $this->commune = $rs->fields[4] ; 
              $this->nmgp_dados_select['commune'] = $this->commune;
              $this->structure = $rs->fields[5] ; 
              $this->nmgp_dados_select['structure'] = $this->structure;
              $this->nom_rapporteur = $rs->fields[6] ; 
              $this->nmgp_dados_select['nom_rapporteur'] = $this->nom_rapporteur;
              $this->tel_rapporteur = $rs->fields[7] ; 
              $this->nmgp_dados_select['tel_rapporteur'] = $this->tel_rapporteur;
              $this->email_rapporteur = $rs->fields[8] ; 
              $this->nmgp_dados_select['email_rapporteur'] = $this->email_rapporteur;
              $this->maladie_suspectee_nm_fk = $rs->fields[9] ; 
              $this->nmgp_dados_select['maladie_suspectee_nm_fk'] = $this->maladie_suspectee_nm_fk;
              $this->nom_malade = $rs->fields[10] ; 
              $this->nmgp_dados_select['nom_malade'] = $this->nom_malade;
              $this->prenom_malade = $rs->fields[11] ; 
              $this->nmgp_dados_select['prenom_malade'] = $this->prenom_malade;
              $this->date_naissance_malade = $rs->fields[12] ; 
              $this->nmgp_dados_select['date_naissance_malade'] = $this->date_naissance_malade;
              $this->age_malade = $rs->fields[13] ; 
              $this->nmgp_dados_select['age_malade'] = $this->age_malade;
              $this->sexe_nm_fk = $rs->fields[14] ; 
              $this->nmgp_dados_select['sexe_nm_fk'] = $this->sexe_nm_fk;
              $this->profession_malade = $rs->fields[15] ; 
              $this->nmgp_dados_select['profession_malade'] = $this->profession_malade;
              $this->adresse_malade = $rs->fields[16] ; 
              $this->nmgp_dados_select['adresse_malade'] = $this->adresse_malade;
              $this->wilaya_malade = $rs->fields[17] ; 
              $this->nmgp_dados_select['wilaya_malade'] = $this->wilaya_malade;
              $this->commune_malade = $rs->fields[18] ; 
              $this->nmgp_dados_select['commune_malade'] = $this->commune_malade;
              $this->lieu_travail = $rs->fields[19] ; 
              $this->nmgp_dados_select['lieu_travail'] = $this->lieu_travail;
              $this->tel_malade = $rs->fields[20] ; 
              $this->nmgp_dados_select['tel_malade'] = $this->tel_malade;
              $this->email_malade = $rs->fields[21] ; 
              $this->nmgp_dados_select['email_malade'] = $this->email_malade;
              $this->lieux_frequentes = $rs->fields[22] ; 
              $this->nmgp_dados_select['lieux_frequentes'] = $this->lieux_frequentes;
              $this->date_apparition_symptomes = $rs->fields[23] ; 
              $this->nmgp_dados_select['date_apparition_symptomes'] = $this->date_apparition_symptomes;
              $this->autres_symptomes = $rs->fields[24] ; 
              $this->nmgp_dados_select['autres_symptomes'] = $this->autres_symptomes;
              $this->hospitalisation = $rs->fields[25] ; 
              $this->nmgp_dados_select['hospitalisation'] = $this->hospitalisation;
              $this->date_hospitalisation = $rs->fields[26] ; 
              $this->nmgp_dados_select['date_hospitalisation'] = $this->date_hospitalisation;
              $this->evacuation = $rs->fields[27] ; 
              $this->nmgp_dados_select['evacuation'] = $this->evacuation;
              $this->date_evacuation = $rs->fields[28] ; 
              $this->nmgp_dados_select['date_evacuation'] = $this->date_evacuation;
              $this->structure_evacuation = $rs->fields[29] ; 
              $this->nmgp_dados_select['structure_evacuation'] = $this->structure_evacuation;
              $this->antecedent_medicaux = $rs->fields[30] ; 
              $this->nmgp_dados_select['antecedent_medicaux'] = $this->antecedent_medicaux;
              $this->commentaires = $rs->fields[31] ; 
              $this->nmgp_dados_select['commentaires'] = $this->commentaires;
              $this->longitude = $rs->fields[32] ; 
              $this->nmgp_dados_select['longitude'] = $this->longitude;
              $this->latitude = $rs->fields[33] ; 
              $this->nmgp_dados_select['latitude'] = $this->latitude;
              $this->envoie = $rs->fields[34] ; 
              $this->nmgp_dados_select['envoie'] = $this->envoie;
              $this->envoie_ack = $rs->fields[35] ; 
              $this->nmgp_dados_select['envoie_ack'] = $this->envoie_ack;
              $this->valide = $rs->fields[36] ; 
              $this->nmgp_dados_select['valide'] = $this->valide;
              $this->descr_invalidite = $rs->fields[37] ; 
              $this->nmgp_dados_select['descr_invalidite'] = $this->descr_invalidite;
              $this->user_fk = $rs->fields[38] ; 
              $this->nmgp_dados_select['user_fk'] = $this->user_fk;
              $this->validator_fk = $rs->fields[39] ; 
              $this->nmgp_dados_select['validator_fk'] = $this->validator_fk;
              $this->mobile = $rs->fields[40] ; 
              $this->nmgp_dados_select['mobile'] = $this->mobile;
              $this->evolution_nm_fk = $rs->fields[41] ; 
              $this->nmgp_dados_select['evolution_nm_fk'] = $this->evolution_nm_fk;
              $this->symptomes = $rs->fields[42] ; 
              $this->nmgp_dados_select['symptomes'] = $this->symptomes;
              $this->device_id = $rs->fields[43] ; 
              $this->nmgp_dados_select['device_id'] = $this->device_id;
              $this->maladie_suspectee_by_ia = $rs->fields[44] ; 
              $this->nmgp_dados_select['maladie_suspectee_by_ia'] = $this->maladie_suspectee_by_ia;
              $this->deleted = $rs->fields[45] ; 
              $this->nmgp_dados_select['deleted'] = $this->deleted;
              $this->date_validation = $rs->fields[46] ; 
              if (substr($this->date_validation, 10, 1) == "-") 
              { 
                 $this->date_validation = substr($this->date_validation, 0, 10) . " " . substr($this->date_validation, 11);
              } 
              if (substr($this->date_validation, 13, 1) == ".") 
              { 
                 $this->date_validation = substr($this->date_validation, 0, 13) . ":" . substr($this->date_validation, 14, 2) . ":" . substr($this->date_validation, 17);
              } 
              $this->nmgp_dados_select['date_validation'] = $this->date_validation;
              $this->user_labo_fk = $rs->fields[47] ; 
              $this->nmgp_dados_select['user_labo_fk'] = $this->user_labo_fk;
              $this->date_confirmation_labo = $rs->fields[48] ; 
              if (substr($this->date_confirmation_labo, 10, 1) == "-") 
              { 
                 $this->date_confirmation_labo = substr($this->date_confirmation_labo, 0, 10) . " " . substr($this->date_confirmation_labo, 11);
              } 
              if (substr($this->date_confirmation_labo, 13, 1) == ".") 
              { 
                 $this->date_confirmation_labo = substr($this->date_confirmation_labo, 0, 13) . ":" . substr($this->date_confirmation_labo, 14, 2) . ":" . substr($this->date_confirmation_labo, 17);
              } 
              $this->nmgp_dados_select['date_confirmation_labo'] = $this->date_confirmation_labo;
              $this->maladie_confirmee_labo = $rs->fields[49] ; 
              $this->nmgp_dados_select['maladie_confirmee_labo'] = $this->maladie_confirmee_labo;
              $this->statut_maladie = $rs->fields[50] ; 
              $this->nmgp_dados_select['statut_maladie'] = $this->statut_maladie;
              $this->date_sortie = $rs->fields[51] ; 
              $this->nmgp_dados_select['date_sortie'] = $this->date_sortie;
              $this->date_deces = $rs->fields[52] ; 
              $this->nmgp_dados_select['date_deces'] = $this->date_deces;
              $this->date_prelevements = $rs->fields[53] ; 
              $this->nmgp_dados_select['date_prelevements'] = $this->date_prelevements;
              $this->date_reception_prelevement = $rs->fields[54] ; 
              $this->nmgp_dados_select['date_reception_prelevement'] = $this->date_reception_prelevement;
              $this->date_resultats_labo = $rs->fields[55] ; 
              $this->nmgp_dados_select['date_resultats_labo'] = $this->date_resultats_labo;
              $this->type_prelevement_nm_fk = $rs->fields[56] ; 
              $this->nmgp_dados_select['type_prelevement_nm_fk'] = $this->type_prelevement_nm_fk;
              $this->resultats_labo = $rs->fields[57] ; 
              $this->nmgp_dados_select['resultats_labo'] = $this->resultats_labo;
              $this->labo_destination = $rs->fields[58] ; 
              $this->nmgp_dados_select['labo_destination'] = $this->labo_destination;
              $this->nin = $rs->fields[59] ; 
              $this->nmgp_dados_select['nin'] = $this->nin;
              $this->commentaires_labo = $rs->fields[60] ; 
              $this->nmgp_dados_select['commentaires_labo'] = $this->commentaires_labo;
              $this->commentaires_semep = $rs->fields[61] ; 
              $this->nmgp_dados_select['commentaires_semep'] = $this->commentaires_semep;
              $this->statut_fiche = $rs->fields[62] ; 
              $this->nmgp_dados_select['statut_fiche'] = $this->statut_fiche;
              $this->autre_evolution = $rs->fields[63] ; 
              $this->nmgp_dados_select['autre_evolution'] = $this->autre_evolution;
              $this->attached_file = $rs->fields[64] ; 
              $this->nmgp_dados_select['attached_file'] = $this->attached_file;
              $this->cas_similaires = $rs->fields[65] ; 
              $this->nmgp_dados_select['cas_similaires'] = $this->cas_similaires;
              $this->unite_age_nm_fk = $rs->fields[66] ; 
              $this->nmgp_dados_select['unite_age_nm_fk'] = $this->unite_age_nm_fk;
              $this->pays_origine = $rs->fields[67] ; 
              $this->nmgp_dados_select['pays_origine'] = $this->pays_origine;
              $this->nationalite_nm_fk = $rs->fields[68] ; 
              $this->nmgp_dados_select['nationalite_nm_fk'] = $this->nationalite_nm_fk;
          $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->nm_troca_decimal(",", ".");
              $this->id_fiche_ps = (string)$this->id_fiche_ps; 
              $this->age_malade = (string)$this->age_malade; 
              $this->longitude = (string)$this->longitude; 
              $this->latitude = (string)$this->latitude; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['parms'] = "id_fiche_ps?#?$this->id_fiche_ps?@?";
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['sub_dir'][0]  = "/attached_files";
          } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['reg_start'];
              $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['reg_start'] < $qt_geral_reg_form_fiche_pro_sante_labo_edit;
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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->id_fiche_ps = "";  
              $this->nmgp_dados_form["id_fiche_ps"] = $this->id_fiche_ps;
              $this->code_fiche = "";  
              $this->nmgp_dados_form["code_fiche"] = $this->code_fiche;
              $this->date_declaration = "";  
              $this->date_declaration_hora = "" ;  
              $this->nmgp_dados_form["date_declaration"] = $this->date_declaration;
              $this->wilaya = "";  
              $this->nmgp_dados_form["wilaya"] = $this->wilaya;
              $this->commune = "";  
              $this->nmgp_dados_form["commune"] = $this->commune;
              $this->structure = "";  
              $this->nmgp_dados_form["structure"] = $this->structure;
              $this->nom_rapporteur = "";  
              $this->nmgp_dados_form["nom_rapporteur"] = $this->nom_rapporteur;
              $this->tel_rapporteur = "";  
              $this->nmgp_dados_form["tel_rapporteur"] = $this->tel_rapporteur;
              $this->email_rapporteur = "";  
              $this->nmgp_dados_form["email_rapporteur"] = $this->email_rapporteur;
              $this->maladie_suspectee_nm_fk = "";  
              $this->nmgp_dados_form["maladie_suspectee_nm_fk"] = $this->maladie_suspectee_nm_fk;
              $this->nom_malade = "";  
              $this->nmgp_dados_form["nom_malade"] = $this->nom_malade;
              $this->prenom_malade = "";  
              $this->nmgp_dados_form["prenom_malade"] = $this->prenom_malade;
              $this->date_naissance_malade = "";  
              $this->date_naissance_malade_hora = "" ;  
              $this->nmgp_dados_form["date_naissance_malade"] = $this->date_naissance_malade;
              $this->age_malade = "";  
              $this->nmgp_dados_form["age_malade"] = $this->age_malade;
              $this->sexe_nm_fk = "";  
              $this->nmgp_dados_form["sexe_nm_fk"] = $this->sexe_nm_fk;
              $this->profession_malade = "";  
              $this->nmgp_dados_form["profession_malade"] = $this->profession_malade;
              $this->adresse_malade = "";  
              $this->nmgp_dados_form["adresse_malade"] = $this->adresse_malade;
              $this->wilaya_malade = "";  
              $this->nmgp_dados_form["wilaya_malade"] = $this->wilaya_malade;
              $this->commune_malade = "";  
              $this->nmgp_dados_form["commune_malade"] = $this->commune_malade;
              $this->lieu_travail = "";  
              $this->nmgp_dados_form["lieu_travail"] = $this->lieu_travail;
              $this->tel_malade = "";  
              $this->nmgp_dados_form["tel_malade"] = $this->tel_malade;
              $this->email_malade = "";  
              $this->nmgp_dados_form["email_malade"] = $this->email_malade;
              $this->lieux_frequentes = "";  
              $this->nmgp_dados_form["lieux_frequentes"] = $this->lieux_frequentes;
              $this->date_apparition_symptomes = "";  
              $this->date_apparition_symptomes_hora = "" ;  
              $this->nmgp_dados_form["date_apparition_symptomes"] = $this->date_apparition_symptomes;
              $this->autres_symptomes = "";  
              $this->nmgp_dados_form["autres_symptomes"] = $this->autres_symptomes;
              $this->hospitalisation = "";  
              $this->nmgp_dados_form["hospitalisation"] = $this->hospitalisation;
              $this->date_hospitalisation = "";  
              $this->date_hospitalisation_hora = "" ;  
              $this->nmgp_dados_form["date_hospitalisation"] = $this->date_hospitalisation;
              $this->evacuation = "";  
              $this->nmgp_dados_form["evacuation"] = $this->evacuation;
              $this->date_evacuation = "";  
              $this->date_evacuation_hora = "" ;  
              $this->nmgp_dados_form["date_evacuation"] = $this->date_evacuation;
              $this->structure_evacuation = "";  
              $this->nmgp_dados_form["structure_evacuation"] = $this->structure_evacuation;
              $this->antecedent_medicaux = "";  
              $this->nmgp_dados_form["antecedent_medicaux"] = $this->antecedent_medicaux;
              $this->commentaires = "";  
              $this->nmgp_dados_form["commentaires"] = $this->commentaires;
              $this->longitude = "";  
              $this->nmgp_dados_form["longitude"] = $this->longitude;
              $this->latitude = "";  
              $this->nmgp_dados_form["latitude"] = $this->latitude;
              $this->envoie = "";  
              $this->nmgp_dados_form["envoie"] = $this->envoie;
              $this->envoie_ack = "";  
              $this->nmgp_dados_form["envoie_ack"] = $this->envoie_ack;
              $this->valide = "";  
              $this->nmgp_dados_form["valide"] = $this->valide;
              $this->descr_invalidite = "";  
              $this->nmgp_dados_form["descr_invalidite"] = $this->descr_invalidite;
              $this->user_fk = "";  
              $this->nmgp_dados_form["user_fk"] = $this->user_fk;
              $this->validator_fk = "";  
              $this->nmgp_dados_form["validator_fk"] = $this->validator_fk;
              $this->mobile = "";  
              $this->nmgp_dados_form["mobile"] = $this->mobile;
              $this->evolution_nm_fk = "";  
              $this->nmgp_dados_form["evolution_nm_fk"] = $this->evolution_nm_fk;
              $this->symptomes = "";  
              $this->nmgp_dados_form["symptomes"] = $this->symptomes;
              $this->device_id = "";  
              $this->nmgp_dados_form["device_id"] = $this->device_id;
              $this->maladie_suspectee_by_ia = "";  
              $this->nmgp_dados_form["maladie_suspectee_by_ia"] = $this->maladie_suspectee_by_ia;
              $this->deleted = "";  
              $this->nmgp_dados_form["deleted"] = $this->deleted;
              $this->date_validation = "";  
              $this->date_validation_hora = "" ;  
              $this->nmgp_dados_form["date_validation"] = $this->date_validation;
              $this->user_labo_fk = "";  
              $this->nmgp_dados_form["user_labo_fk"] = $this->user_labo_fk;
              $this->date_confirmation_labo = "";  
              $this->date_confirmation_labo_hora = "" ;  
              $this->nmgp_dados_form["date_confirmation_labo"] = $this->date_confirmation_labo;
              $this->maladie_confirmee_labo = "";  
              $this->nmgp_dados_form["maladie_confirmee_labo"] = $this->maladie_confirmee_labo;
              $this->statut_maladie = "";  
              $this->nmgp_dados_form["statut_maladie"] = $this->statut_maladie;
              $this->date_sortie = "";  
              $this->date_sortie_hora = "" ;  
              $this->nmgp_dados_form["date_sortie"] = $this->date_sortie;
              $this->date_deces = "";  
              $this->date_deces_hora = "" ;  
              $this->nmgp_dados_form["date_deces"] = $this->date_deces;
              $this->date_prelevements = "";  
              $this->date_prelevements_hora = "" ;  
              $this->nmgp_dados_form["date_prelevements"] = $this->date_prelevements;
              $this->date_reception_prelevement = "";  
              $this->date_reception_prelevement_hora = "" ;  
              $this->nmgp_dados_form["date_reception_prelevement"] = $this->date_reception_prelevement;
              $this->date_resultats_labo = "";  
              $this->date_resultats_labo_hora = "" ;  
              $this->nmgp_dados_form["date_resultats_labo"] = $this->date_resultats_labo;
              $this->type_prelevement_nm_fk = "";  
              $this->nmgp_dados_form["type_prelevement_nm_fk"] = $this->type_prelevement_nm_fk;
              $this->resultats_labo = "";  
              $this->nmgp_dados_form["resultats_labo"] = $this->resultats_labo;
              $this->labo_destination = "";  
              $this->nmgp_dados_form["labo_destination"] = $this->labo_destination;
              $this->nin = "";  
              $this->nmgp_dados_form["nin"] = $this->nin;
              $this->commentaires_labo = "";  
              $this->nmgp_dados_form["commentaires_labo"] = $this->commentaires_labo;
              $this->commentaires_semep = "";  
              $this->nmgp_dados_form["commentaires_semep"] = $this->commentaires_semep;
              $this->statut_fiche = "";  
              $this->nmgp_dados_form["statut_fiche"] = $this->statut_fiche;
              $this->autre_evolution = "";  
              $this->nmgp_dados_form["autre_evolution"] = $this->autre_evolution;
              $this->attached_file = "";  
              $this->attached_file_ul_name = "" ;  
              $this->attached_file_ul_type = "" ;  
              $this->nmgp_dados_form["attached_file"] = $this->attached_file;
              $this->cas_similaires = "";  
              $this->nmgp_dados_form["cas_similaires"] = $this->cas_similaires;
              $this->unite_age_nm_fk = "";  
              $this->nmgp_dados_form["unite_age_nm_fk"] = $this->unite_age_nm_fk;
              $this->pays_origine = "";  
              $this->nmgp_dados_form["pays_origine"] = $this->pays_origine;
              $this->nationalite_nm_fk = "";  
              $this->nmgp_dados_form["nationalite_nm_fk"] = $this->nationalite_nm_fk;
              $this->spacer1 = "";  
              $this->nmgp_dados_form["spacer1"] = $this->spacer1;
              $this->spacer2 = "";  
              $this->nmgp_dados_form["spacer2"] = $this->spacer2;
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_form'] = $this->nmgp_dados_form;
              $this->formatado = false;
          }
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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 NM_gera_log_key($evt) 
   {
       $this->SC_log_arr = array();
       $this->SC_log_atv = true;
       if ($evt == "incluir")
       {
           $this->SC_log_evt = "insert";
       }
       if ($evt == "alterar")
       {
           $this->SC_log_evt = "update";
       }
       if ($evt == "excluir")
       {
           $this->SC_log_evt = "delete";
       }
       $this->SC_log_arr['keys']['id_fiche_ps'] =  $this->id_fiche_ps;
   }
// 
   function NM_gera_log_old() 
   {
       if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select']))
       {
           $nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dados_select'];
           $this->SC_log_arr['fields']['code_fiche']['0'] =  $nmgp_dados_select['code_fiche'];
           $this->SC_log_arr['fields']['date_declaration']['0'] =  $nmgp_dados_select['date_declaration'];
           $this->SC_log_arr['fields']['wilaya']['0'] =  $nmgp_dados_select['wilaya'];
           $this->SC_log_arr['fields']['commune']['0'] =  $nmgp_dados_select['commune'];
           $this->SC_log_arr['fields']['structure']['0'] =  $nmgp_dados_select['structure'];
           $this->SC_log_arr['fields']['nom_rapporteur']['0'] =  $nmgp_dados_select['nom_rapporteur'];
           $this->SC_log_arr['fields']['tel_rapporteur']['0'] =  $nmgp_dados_select['tel_rapporteur'];
           $this->SC_log_arr['fields']['email_rapporteur']['0'] =  $nmgp_dados_select['email_rapporteur'];
           $this->SC_log_arr['fields']['maladie_suspectee_nm_fk']['0'] =  $nmgp_dados_select['maladie_suspectee_nm_fk'];
           $this->SC_log_arr['fields']['nom_malade']['0'] =  $nmgp_dados_select['nom_malade'];
           $this->SC_log_arr['fields']['prenom_malade']['0'] =  $nmgp_dados_select['prenom_malade'];
           $this->SC_log_arr['fields']['date_naissance_malade']['0'] =  $nmgp_dados_select['date_naissance_malade'];
           $this->SC_log_arr['fields']['age_malade']['0'] =  $nmgp_dados_select['age_malade'];
           $this->SC_log_arr['fields']['sexe_nm_fk']['0'] =  $nmgp_dados_select['sexe_nm_fk'];
           $this->SC_log_arr['fields']['profession_malade']['0'] =  $nmgp_dados_select['profession_malade'];
           $this->SC_log_arr['fields']['adresse_malade']['0'] =  $nmgp_dados_select['adresse_malade'];
           $this->SC_log_arr['fields']['wilaya_malade']['0'] =  $nmgp_dados_select['wilaya_malade'];
           $this->SC_log_arr['fields']['commune_malade']['0'] =  $nmgp_dados_select['commune_malade'];
           $this->SC_log_arr['fields']['lieu_travail']['0'] =  $nmgp_dados_select['lieu_travail'];
           $this->SC_log_arr['fields']['tel_malade']['0'] =  $nmgp_dados_select['tel_malade'];
           $this->SC_log_arr['fields']['email_malade']['0'] =  $nmgp_dados_select['email_malade'];
           $this->SC_log_arr['fields']['lieux_frequentes']['0'] =  $nmgp_dados_select['lieux_frequentes'];
           $this->SC_log_arr['fields']['date_apparition_symptomes']['0'] =  $nmgp_dados_select['date_apparition_symptomes'];
           $this->SC_log_arr['fields']['autres_symptomes']['0'] =  $nmgp_dados_select['autres_symptomes'];
           $this->SC_log_arr['fields']['hospitalisation']['0'] =  $nmgp_dados_select['hospitalisation'];
           $this->SC_log_arr['fields']['date_hospitalisation']['0'] =  $nmgp_dados_select['date_hospitalisation'];
           $this->SC_log_arr['fields']['evacuation']['0'] =  $nmgp_dados_select['evacuation'];
           $this->SC_log_arr['fields']['date_evacuation']['0'] =  $nmgp_dados_select['date_evacuation'];
           $this->SC_log_arr['fields']['structure_evacuation']['0'] =  $nmgp_dados_select['structure_evacuation'];
           $this->SC_log_arr['fields']['antecedent_medicaux']['0'] =  $nmgp_dados_select['antecedent_medicaux'];
           $this->SC_log_arr['fields']['commentaires']['0'] =  $nmgp_dados_select['commentaires'];
           $this->SC_log_arr['fields']['longitude']['0'] =  $nmgp_dados_select['longitude'];
           $this->SC_log_arr['fields']['latitude']['0'] =  $nmgp_dados_select['latitude'];
           $this->SC_log_arr['fields']['envoie']['0'] =  $nmgp_dados_select['envoie'];
           $this->SC_log_arr['fields']['envoie_ack']['0'] =  $nmgp_dados_select['envoie_ack'];
           $this->SC_log_arr['fields']['valide']['0'] =  $nmgp_dados_select['valide'];
           $this->SC_log_arr['fields']['descr_invalidite']['0'] =  $nmgp_dados_select['descr_invalidite'];
           $this->SC_log_arr['fields']['user_fk']['0'] =  $nmgp_dados_select['user_fk'];
           $this->SC_log_arr['fields']['validator_fk']['0'] =  $nmgp_dados_select['validator_fk'];
           $this->SC_log_arr['fields']['mobile']['0'] =  $nmgp_dados_select['mobile'];
           $this->SC_log_arr['fields']['evolution_nm_fk']['0'] =  $nmgp_dados_select['evolution_nm_fk'];
           $this->SC_log_arr['fields']['symptomes']['0'] =  $nmgp_dados_select['symptomes'];
           $this->SC_log_arr['fields']['device_id']['0'] =  $nmgp_dados_select['device_id'];
           $this->SC_log_arr['fields']['maladie_suspectee_by_ia']['0'] =  $nmgp_dados_select['maladie_suspectee_by_ia'];
           $this->SC_log_arr['fields']['deleted']['0'] =  $nmgp_dados_select['deleted'];
           $this->SC_log_arr['fields']['date_validation']['0'] =  $nmgp_dados_select['date_validation'];
           $this->SC_log_arr['fields']['user_labo_fk']['0'] =  $nmgp_dados_select['user_labo_fk'];
           $this->SC_log_arr['fields']['date_confirmation_labo']['0'] =  $nmgp_dados_select['date_confirmation_labo'];
           $this->SC_log_arr['fields']['maladie_confirmee_labo']['0'] =  $nmgp_dados_select['maladie_confirmee_labo'];
           $this->SC_log_arr['fields']['statut_maladie']['0'] =  $nmgp_dados_select['statut_maladie'];
           $this->SC_log_arr['fields']['date_sortie']['0'] =  $nmgp_dados_select['date_sortie'];
           $this->SC_log_arr['fields']['date_deces']['0'] =  $nmgp_dados_select['date_deces'];
           $this->SC_log_arr['fields']['date_prelevements']['0'] =  $nmgp_dados_select['date_prelevements'];
           $this->SC_log_arr['fields']['date_reception_prelevement']['0'] =  $nmgp_dados_select['date_reception_prelevement'];
           $this->SC_log_arr['fields']['date_resultats_labo']['0'] =  $nmgp_dados_select['date_resultats_labo'];
           $this->SC_log_arr['fields']['type_prelevement_nm_fk']['0'] =  $nmgp_dados_select['type_prelevement_nm_fk'];
           $this->SC_log_arr['fields']['resultats_labo']['0'] =  $nmgp_dados_select['resultats_labo'];
           $this->SC_log_arr['fields']['labo_destination']['0'] =  $nmgp_dados_select['labo_destination'];
           $this->SC_log_arr['fields']['nin']['0'] =  $nmgp_dados_select['nin'];
           $this->SC_log_arr['fields']['commentaires_labo']['0'] =  $nmgp_dados_select['commentaires_labo'];
           $this->SC_log_arr['fields']['commentaires_semep']['0'] =  $nmgp_dados_select['commentaires_semep'];
           $this->SC_log_arr['fields']['statut_fiche']['0'] =  $nmgp_dados_select['statut_fiche'];
           $this->SC_log_arr['fields']['autre_evolution']['0'] =  $nmgp_dados_select['autre_evolution'];
           $this->SC_log_arr['fields']['attached_file']['0'] =  $nmgp_dados_select['attached_file'];
           $this->SC_log_arr['fields']['cas_similaires']['0'] =  $nmgp_dados_select['cas_similaires'];
           $this->SC_log_arr['fields']['unite_age_nm_fk']['0'] =  $nmgp_dados_select['unite_age_nm_fk'];
           $this->SC_log_arr['fields']['pays_origine']['0'] =  $nmgp_dados_select['pays_origine'];
           $this->SC_log_arr['fields']['nationalite_nm_fk']['0'] =  $nmgp_dados_select['nationalite_nm_fk'];
       }
   }
// 
   function NM_gera_log_new() 
   {
       $this->SC_log_arr['fields']['code_fiche']['1'] =  $this->code_fiche;
       $this->SC_log_arr['fields']['date_declaration']['1'] =  $this->date_declaration;
       $this->SC_log_arr['fields']['wilaya']['1'] =  $this->wilaya;
       $this->SC_log_arr['fields']['commune']['1'] =  $this->commune;
       $this->SC_log_arr['fields']['structure']['1'] =  $this->structure;
       $this->SC_log_arr['fields']['nom_rapporteur']['1'] =  $this->nom_rapporteur;
       $this->SC_log_arr['fields']['tel_rapporteur']['1'] =  $this->tel_rapporteur;
       $this->SC_log_arr['fields']['email_rapporteur']['1'] =  $this->email_rapporteur;
       $this->SC_log_arr['fields']['maladie_suspectee_nm_fk']['1'] =  $this->maladie_suspectee_nm_fk;
       $this->SC_log_arr['fields']['nom_malade']['1'] =  $this->nom_malade;
       $this->SC_log_arr['fields']['prenom_malade']['1'] =  $this->prenom_malade;
       $this->SC_log_arr['fields']['date_naissance_malade']['1'] =  $this->date_naissance_malade;
       $this->SC_log_arr['fields']['age_malade']['1'] =  $this->age_malade;
       $this->SC_log_arr['fields']['sexe_nm_fk']['1'] =  $this->sexe_nm_fk;
       $this->SC_log_arr['fields']['profession_malade']['1'] =  $this->profession_malade;
       $this->SC_log_arr['fields']['adresse_malade']['1'] =  $this->adresse_malade;
       $this->SC_log_arr['fields']['wilaya_malade']['1'] =  $this->wilaya_malade;
       $this->SC_log_arr['fields']['commune_malade']['1'] =  $this->commune_malade;
       $this->SC_log_arr['fields']['lieu_travail']['1'] =  $this->lieu_travail;
       $this->SC_log_arr['fields']['tel_malade']['1'] =  $this->tel_malade;
       $this->SC_log_arr['fields']['email_malade']['1'] =  $this->email_malade;
       $this->SC_log_arr['fields']['lieux_frequentes']['1'] =  $this->lieux_frequentes;
       $this->SC_log_arr['fields']['date_apparition_symptomes']['1'] =  $this->date_apparition_symptomes;
       $this->SC_log_arr['fields']['autres_symptomes']['1'] =  $this->autres_symptomes;
       $this->SC_log_arr['fields']['hospitalisation']['1'] =  $this->hospitalisation;
       $this->SC_log_arr['fields']['date_hospitalisation']['1'] =  $this->date_hospitalisation;
       $this->SC_log_arr['fields']['evacuation']['1'] =  $this->evacuation;
       $this->SC_log_arr['fields']['date_evacuation']['1'] =  $this->date_evacuation;
       $this->SC_log_arr['fields']['structure_evacuation']['1'] =  $this->structure_evacuation;
       $this->SC_log_arr['fields']['antecedent_medicaux']['1'] =  $this->antecedent_medicaux;
       $this->SC_log_arr['fields']['commentaires']['1'] =  $this->commentaires;
       $this->SC_log_arr['fields']['longitude']['1'] =  $this->longitude;
       $this->SC_log_arr['fields']['latitude']['1'] =  $this->latitude;
       $this->SC_log_arr['fields']['envoie']['1'] =  $this->envoie;
       $this->SC_log_arr['fields']['envoie_ack']['1'] =  $this->envoie_ack;
       $this->SC_log_arr['fields']['valide']['1'] =  $this->valide;
       $this->SC_log_arr['fields']['descr_invalidite']['1'] =  $this->descr_invalidite;
       $this->SC_log_arr['fields']['user_fk']['1'] =  $this->user_fk;
       $this->SC_log_arr['fields']['validator_fk']['1'] =  $this->validator_fk;
       $this->SC_log_arr['fields']['mobile']['1'] =  $this->mobile;
       $this->SC_log_arr['fields']['evolution_nm_fk']['1'] =  $this->evolution_nm_fk;
       $this->SC_log_arr['fields']['symptomes']['1'] =  $this->symptomes;
       $this->SC_log_arr['fields']['device_id']['1'] =  $this->device_id;
       $this->SC_log_arr['fields']['maladie_suspectee_by_ia']['1'] =  $this->maladie_suspectee_by_ia;
       $this->SC_log_arr['fields']['deleted']['1'] =  $this->deleted;
       $this->SC_log_arr['fields']['date_validation']['1'] =  $this->date_validation;
       $this->SC_log_arr['fields']['user_labo_fk']['1'] =  $this->user_labo_fk;
       $this->SC_log_arr['fields']['date_confirmation_labo']['1'] =  $this->date_confirmation_labo;
       $this->SC_log_arr['fields']['maladie_confirmee_labo']['1'] =  $this->maladie_confirmee_labo;
       $this->SC_log_arr['fields']['statut_maladie']['1'] =  $this->statut_maladie;
       $this->SC_log_arr['fields']['date_sortie']['1'] =  $this->date_sortie;
       $this->SC_log_arr['fields']['date_deces']['1'] =  $this->date_deces;
       $this->SC_log_arr['fields']['date_prelevements']['1'] =  $this->date_prelevements;
       $this->SC_log_arr['fields']['date_reception_prelevement']['1'] =  $this->date_reception_prelevement;
       $this->SC_log_arr['fields']['date_resultats_labo']['1'] =  $this->date_resultats_labo;
       $this->SC_log_arr['fields']['type_prelevement_nm_fk']['1'] =  $this->type_prelevement_nm_fk;
       $this->SC_log_arr['fields']['resultats_labo']['1'] =  $this->resultats_labo;
       $this->SC_log_arr['fields']['labo_destination']['1'] =  $this->labo_destination;
       $this->SC_log_arr['fields']['nin']['1'] =  $this->nin;
       $this->SC_log_arr['fields']['commentaires_labo']['1'] =  $this->commentaires_labo;
       $this->SC_log_arr['fields']['commentaires_semep']['1'] =  $this->commentaires_semep;
       $this->SC_log_arr['fields']['statut_fiche']['1'] =  $this->statut_fiche;
       $this->SC_log_arr['fields']['autre_evolution']['1'] =  $this->autre_evolution;
       $this->SC_log_arr['fields']['attached_file']['1'] =  $this->attached_file;
       $this->SC_log_arr['fields']['cas_similaires']['1'] =  $this->cas_similaires;
       $this->SC_log_arr['fields']['unite_age_nm_fk']['1'] =  $this->unite_age_nm_fk;
       $this->SC_log_arr['fields']['pays_origine']['1'] =  $this->pays_origine;
       $this->SC_log_arr['fields']['nationalite_nm_fk']['1'] =  $this->nationalite_nm_fk;
   }
// 
   function NM_gera_log_compress() 
   {
       foreach ($this->SC_log_arr['fields'] as $fild => $data_f)
       {
           if ($data_f[0] == $data_f[1] || ($data_f[0] == "" && $data_f[1] == "null"))
           {
               unset($this->SC_log_arr['fields'][$fild]);
           }
       }
   }
// 
   function NM_gera_log_output() 
   {
       $Log_output = "";
       $prim_delim = "";
       $Log_labels = array();
       $Log_labels['code_fiche'] =  "{lang_public_fiche_prof_sante_fld_code_fiche}";
       $Log_labels['date_declaration'] =  "{lang_public_fiche_prof_sante_fld_date_declaration}";
       $Log_labels['wilaya'] =  "{lang_public_fiche_prof_sante_fld_wilaya}";
       $Log_labels['commune'] =  "{lang_public_fiche_prof_sante_fld_commune}";
       $Log_labels['structure'] =  "{lang_public_fiche_prof_sante_fld_structure}";
       $Log_labels['nom_rapporteur'] =  "{lang_public_fiche_prof_sante_fld_nom_rapporteur}";
       $Log_labels['tel_rapporteur'] =  "{lang_public_fiche_prof_sante_fld_tel_rapporteur}";
       $Log_labels['email_rapporteur'] =  "{lang_public_fiche_prof_sante_fld_email_rapporteur}";
       $Log_labels['maladie_suspectee_nm_fk'] =  "{lang_public_fiche_prof_sante_fld_maladie_suspectee_nm_fk}";
       $Log_labels['nom_malade'] =  "{lang_public_fiche_prof_sante_fld_nom_malade}";
       $Log_labels['prenom_malade'] =  "{lang_public_fiche_prof_sante_fld_prenom_malade}";
       $Log_labels['date_naissance_malade'] =  "{lang_public_fiche_prof_sante_fld_date_naissance_malade}";
       $Log_labels['age_malade'] =  "{lang_public_fiche_prof_sante_fld_age_malade}";
       $Log_labels['sexe_nm_fk'] =  "{lang_public_fiche_prof_sante_fld_sexe_nm_fk}";
       $Log_labels['profession_malade'] =  "{lang_public_fiche_prof_sante_fld_profession_malade}";
       $Log_labels['adresse_malade'] =  "{lang_public_fiche_prof_sante_fld_adresse_malade}";
       $Log_labels['wilaya_malade'] =  "{lang_public_fiche_prof_sante_fld_wilaya_malade}";
       $Log_labels['commune_malade'] =  "{lang_public_fiche_prof_sante_fld_commune_malade}";
       $Log_labels['lieu_travail'] =  "{lang_public_fiche_prof_sante_fld_lieu_travail}";
       $Log_labels['tel_malade'] =  "{lang_public_fiche_prof_sante_fld_tel_malade}";
       $Log_labels['email_malade'] =  "{lang_public_fiche_prof_sante_fld_email_malade}";
       $Log_labels['lieux_frequentes'] =  "{lang_public_fiche_prof_sante_fld_lieux_frequentes}";
       $Log_labels['date_apparition_symptomes'] =  "{lang_public_fiche_prof_sante_fld_date_apparition_symptomes}";
       $Log_labels['autres_symptomes'] =  "{lang_public_fiche_prof_sante_fld_autres_symptomes}";
       $Log_labels['hospitalisation'] =  "{lang_public_fiche_prof_sante_fld_hospitalisation}";
       $Log_labels['date_hospitalisation'] =  "{lang_public_fiche_prof_sante_fld_date_hospitalisation}";
       $Log_labels['evacuation'] =  "{lang_public_fiche_prof_sante_fld_evacuation}";
       $Log_labels['date_evacuation'] =  "{lang_public_fiche_prof_sante_fld_date_evacuation}";
       $Log_labels['structure_evacuation'] =  "{lang_public_fiche_prof_sante_fld_structure_evacuation}";
       $Log_labels['antecedent_medicaux'] =  "{lang_public_fiche_prof_sante_fld_antecedent_medicaux}";
       $Log_labels['commentaires'] =  "{lang_public_fiche_prof_sante_fld_commentaires}";
       $Log_labels['longitude'] =  "{lang_public_fiche_prof_sante_fld_longitude}";
       $Log_labels['latitude'] =  "{lang_public_fiche_prof_sante_fld_latitude}";
       $Log_labels['envoie'] =  "{lang_public_fiche_prof_sante_fld_envoie}";
       $Log_labels['envoie_ack'] =  "{lang_public_fiche_prof_sante_fld_envoie_ack}";
       $Log_labels['valide'] =  "{lang_public_fiche_prof_sante_fld_valide}";
       $Log_labels['descr_invalidite'] =  "{lang_public_fiche_prof_sante_fld_descr_invalidite}";
       $Log_labels['user_fk'] =  "{lang_public_fiche_prof_sante_fld_user_fk}";
       $Log_labels['validator_fk'] =  "{lang_public_fiche_prof_sante_fld_validator_fk}";
       $Log_labels['mobile'] =  "{lang_public_fiche_prof_sante_fld_mobile}";
       $Log_labels['evolution_nm_fk'] =  "{lang_public_fiche_prof_sante_fld_evolution_nm_fk}";
       $Log_labels['symptomes'] =  "{lang_public_fiche_prof_sante_fld_symptomes}";
       $Log_labels['device_id'] =  "{lang_public_fiche_prof_sante_fld_device_id}";
       $Log_labels['maladie_suspectee_by_ia'] =  "{lang_public_fiche_prof_sante_fld_maladie_suspectee_by_ia}";
       $Log_labels['deleted'] =  "{lang_public_fiche_prof_sante_fld_deleted}";
       $Log_labels['date_validation'] =  "{lang_public_fiche_prof_sante_fld_date_validation}";
       $Log_labels['user_labo_fk'] =  "{lang_public_fiche_prof_sante_fld_user_labo_fk}";
       $Log_labels['date_confirmation_labo'] =  "{lang_public_fiche_prof_sante_fld_date_confirmation_labo}";
       $Log_labels['maladie_confirmee_labo'] =  "{lang_public_fiche_prof_sante_fld_maladie_confirmee_labo}";
       $Log_labels['statut_maladie'] =  "{lang_public_fiche_prof_sante_fld_statut_maladie}";
       $Log_labels['date_sortie'] =  "{lang_public_fiche_prof_sante_fld_date_sortie}";
       $Log_labels['date_deces'] =  "{lang_public_fiche_prof_sante_fld_date_deces}";
       $Log_labels['date_prelevements'] =  "{lang_public_fiche_prof_sante_fld_date_prelevements}";
       $Log_labels['date_reception_prelevement'] =  "{lang_public_fiche_prof_sante_fld_date_reception_prelevement}";
       $Log_labels['date_resultats_labo'] =  "{lang_public_fiche_prof_sante_fld_date_resultats_labo}";
       $Log_labels['type_prelevement_nm_fk'] =  "{lang_public_fiche_prof_sante_fld_type_prelevement_nm_fk}";
       $Log_labels['resultats_labo'] =  "{lang_public_fiche_prof_sante_fld_resultats_labo}";
       $Log_labels['labo_destination'] =  "{lang_public_fiche_prof_sante_fld_labo_destination}";
       $Log_labels['nin'] =  "{lang_public_fiche_prof_sante_fld_nin}";
       $Log_labels['commentaires_labo'] =  "{lang_public_fiche_prof_sante_fld_commentaires_labo}";
       $Log_labels['commentaires_semep'] =  "{lang_public_fiche_prof_sante_fld_commentaires_semep}";
       $Log_labels['statut_fiche'] =  "{lang_public_fiche_prof_sante_fld_statut_fiche}";
       $Log_labels['autre_evolution'] =  "{lang_public_fiche_prof_sante_fld_autre_evolution}";
       $Log_labels['attached_file'] =  "{lang_public_fiche_prof_sante_fld_attached_file}";
       $Log_labels['cas_similaires'] =  "{lang_public_fiche_prof_sante_fld_cas_similaires}";
       $Log_labels['unite_age_nm_fk'] =  "{lang_public_fiche_prof_sante_fld_unite_age_nm_fk}";
       $Log_labels['pays_origine'] =  "{lang_public_fiche_prof_sante_fld_pays_origine}";
       $Log_labels['nationalite_nm_fk'] =  "{lang_public_fiche_prof_sante_fld_nationalite_nm_fk}";
       foreach ($this->SC_log_arr as $type => $dats)
       {
           if ($type == "keys")
           {
               $Log_output .= "--> keys <-- ";
               foreach ($dats as $key => $data)
               {
                   $Log_output .=  $prim_delim . $key . " : " . $data;
                   $prim_delim  = "||";
               }
           }
           if ($type == "fields")
           {
               $Log_output .= $prim_delim . "--> fields <-- ";
               $prim_delim = "";
               if (empty($dats) && $this->SC_log_evt == "update")
               {
                   return;
               }
               foreach ($dats as $key => $data)
               {
                   foreach ($data as $tp => $val)
                   {
                      $tpok = ($tp == 0) ? " (old) " : " (new) ";
                      $Log_output .= $prim_delim . $key . $tpok . " : " . $val;
                      $prim_delim  = "||";
                   }
                   $Log_output .= $prim_delim . $key . " (label) " . " : " . $Log_labels[$key];
               }
           }
       }
       $this->NM_gera_log_insert("Scriptcase", $this->SC_log_evt, $Log_output);
   }
        function initializeRecordState() {
                $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['record_state'] = array();
        }

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

                $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['record_state']) || !isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['record_state'][$sc_seq_vert])) {
                        return;
                }

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

//
function evacuation_onClick()
{
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
$original_structure_evacuation = $this->structure_evacuation;
$original_date_evacuation = $this->date_evacuation;

if ($this->evacuation =='O'){
	

	$this->nmgp_cmp_hidden["date_evacuation"] = 'on'; $this->NM_ajax_info['fieldDisplay']['date_evacuation'] = 'on';
	$this->nmgp_cmp_hidden["structure_evacuation"] = 'on'; $this->NM_ajax_info['fieldDisplay']['structure_evacuation'] = 'on';

	
}
else{
	
	$this->nmgp_cmp_hidden["date_evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_evacuation'] = 'off';
	$this->nmgp_cmp_hidden["structure_evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['structure_evacuation'] = 'off';
	
	$this->date_evacuation  = NULL;
	$this->structure_evacuation  = NULL;
	
}

$modificado_structure_evacuation = $this->structure_evacuation;
$modificado_date_evacuation = $this->date_evacuation;
$this->nm_formatar_campos();
if ($original_structure_evacuation !== $modificado_structure_evacuation || isset($this->nmgp_cmp_readonly['structure_evacuation']) || (isset($bFlagRead_structure_evacuation) && $bFlagRead_structure_evacuation))
{
    $this->ajax_return_values_structure_evacuation(true);
}
if ($original_date_evacuation !== $modificado_date_evacuation || isset($this->nmgp_cmp_readonly['date_evacuation']) || (isset($bFlagRead_date_evacuation) && $bFlagRead_date_evacuation))
{
    $this->ajax_return_values_date_evacuation(true);
}
$this->NM_ajax_info['event_field'] = 'evacuation';
form_fiche_pro_sante_labo_edit_pack_ajax_response();
exit;
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function evolution_nm_fk_onClick()
{
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  

$this->init_fields_script_init();

if ($this->evolution_nm_fk =='DECESEVOL'){
	
	$this->nmgp_cmp_hidden["date_deces"] = 'on'; $this->NM_ajax_info['fieldDisplay']['date_deces'] = 'on';

}
else{
	
	$this->nmgp_cmp_hidden["date_deces"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_deces'] = 'off';
}

if ($this->evolution_nm_fk =='GUERISON'){
	
	$this->nmgp_cmp_hidden["date_sortie"] = 'on'; $this->NM_ajax_info['fieldDisplay']['date_sortie'] = 'on';

}
else{
	
	$this->nmgp_cmp_hidden["date_sortie"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_sortie'] = 'off';
}

$this->nm_formatar_campos();
$this->NM_ajax_info['event_field'] = 'evolution';
form_fiche_pro_sante_labo_edit_pack_ajax_response();
exit;
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function hospitalisation_onClick()
{
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  

if ($this->hospitalisation =='O'){
	

	$this->nmgp_cmp_hidden["date_hospitalisation"] = 'on'; $this->NM_ajax_info['fieldDisplay']['date_hospitalisation'] = 'on';
	
	$this->nmgp_cmp_hidden["date_evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_evacuation'] = 'off';
	$this->nmgp_cmp_hidden["structure_evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['structure_evacuation'] = 'off';
	$this->nmgp_cmp_hidden["evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['evacuation'] = 'off';
	;		
	$this->evacuation  = 'N';
	$this->date_evacuation  = NULL;
	$this->structure_evacuation  = NULL;
	
}
else{
	
	$this->nmgp_cmp_hidden["date_hospitalisation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_hospitalisation'] = 'off';
	;		
	$this->nmgp_cmp_hidden["evacuation"] = 'on'; $this->NM_ajax_info['fieldDisplay']['evacuation'] = 'on';
}

$this->nm_formatar_campos();
$this->NM_ajax_info['event_field'] = 'hospitalisation';
form_fiche_pro_sante_labo_edit_pack_ajax_response();
exit;
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function init_fields()
{
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  



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

$this->nmgp_cmp_hidden["date_deces"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_deces'] = 'off'; 
$this->nmgp_cmp_hidden["date_sortie"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_sortie'] = 'off';
	
$this->nmgp_cmp_hidden["date_hospitalisation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_hospitalisation'] = 'off';
$this->nmgp_cmp_hidden["date_evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['date_evacuation'] = 'off';
$this->nmgp_cmp_hidden["structure_evacuation"] = 'off'; $this->NM_ajax_info['fieldDisplay']['structure_evacuation'] = 'off';
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function supprimer_fiche()
{
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
$id = $this->id_fiche_ps ;
$code = $this->code_fiche ;

$desc = "Fiche $code, supprimée avec succès";
$update_table  = 'fiche_prof_sante';      
$update_where  = "id_fiche_ps = $id"; 
$update_fields = array(   
     "deleted = 'O'",
     
 );

$update_sql = 'UPDATE ' . $update_table
    . ' SET '   . implode(', ', $update_fields)
    . ' WHERE ' . $update_where;

     $nm_select = $update_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                form_fiche_pro_sante_labo_edit_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      




$this->NM_gera_log_insert("User", "delete", $desc);
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function send_request($_url, $_action, $_params){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$url = $_url;
	
	$params = $_params;

	$params['action'] = $_action;

	$payload = json_encode($_params);


	$ch = curl_init($url);

	curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

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

	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
	curl_setopt($ch, CURLOPT_MAXREDIRS, 10);


	$result = curl_exec($ch);

	$uuid_results = json_decode($result, true);

	$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	
	curl_close($ch);

	if ($httpCode==200 || $httpCode==201){
	
		return $uuid_results;

	}
	else{
		
		return array(0=>array('error'=>'999', 'message'=>"Erreur, code http:$httpCode, URL: $_url-$_action, Sended JSON:".json_encode($_params).'- Returned JSON:'.json_encode($uuid_results)));
		
	}
	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function add_private_notification($_user, $_subject, $_excerpt, $_details, $_alert = 'N', $_code_fiche=''){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$_dt = date('Y-m-d H:i:s');
	
	$insert_table  = 'public.alert_notification_private';      
	$insert_fields = array(   
					'user_fk' => "'".$_user."'",
					'notification_title' => "'".$_subject."'",
					'notification_excerpt' => "'".$_excerpt."'",
					'notification_details' => "'".$_details."'",
					'code_fiche' => (empty($_code_fiche)?'NULL':"'".$_code_fiche."'"),
		 			'notification_datetime' => "'".$_dt."'",
					'ai_alert' => (empty($_alert)?'NULL':"'".$_alert."'"),
					'readed' => "'N'",
				 );

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

	
     $nm_select = $insert_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                form_fiche_pro_sante_labo_edit_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      
	
		
	$_url = $this->get_setting('url_device_mgm_ws');
	$_action = 'getDeviceByUser';
	$request_array = array(
    	'action' => "$_action",
		'user_name'  => $_user,
		'name_space' => "AL",
	);
	
	$r = $this->send_request($_url, $_action, $request_array);
	
	$this->push_api_log('send_to_firebase', $_user.'.1'.json_encode($r));

	if (isset($r[0]['error']) && $r[0]['error']=='0'){
		
		$_device_id = $r[0]['device_id'];
		
		
		if (!empty($_device_id)){
		
			if ($this->send_notification_to_firebase($_device_id, $_subject, $_excerpt, $_details)){

				$this->push_api_log('send_to_firebase', $_user.'.2'.json_encode($r));
			}
			else{

				$this->push_api_log('send_to_firebase', $_user.'.'.$_device_id);
			}
		}
		
	}
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function send_notification_to_firebase($_device_id, $_subject, $_excerpt, $_message){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	
	
	$_url = $this->get_setting('alerts_notifification_ws_url');
	$_action = 'getSettings';
	$request_array = array(
    	'action' => "$_action",
		/*'code_declaration' => "$_code_declaration",
		'status' => "$_status",*/
	);
	
	$r = $this->send_request($_url, $_action, $request_array);

	if (isset($r[0]['error'])){
		
		if ($r[0]['error']=='0'){
			
			$_settings = $r[0]['settings'];
			
			$_url = $_settings['firebase_notification_url'];

			$_key = $_settings['firebase_notification_key'];


			/*------------------------------------------------*/


			$url = $_url;

			$params = array(

				'notification' => array('title'=>$_subject, 'body'=>$_excerpt),
				'to' => $_device_id,
				'data' => array('type'=>'personnel', 'contenu'=>$_message),

			);


			$payload = json_encode($params);

			$ch = curl_init($url);


			$authorization = "Authorization: " . $_key;

			$headers = array(
			   "Accept: application/json",
			   "Content-Type: application/json",
			   $authorization,	
			);


			curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

			curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


			curl_setopt($ch, CURLOPT_POST, 1);
			curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
			curl_setopt($ch, CURLOPT_MAXREDIRS, 10);


			$result = curl_exec($ch);

			$uuid_results = json_decode($result, true);
			
			$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	
			curl_close($ch);

			if ($httpCode==200 || $httpCode==201){

				
				
				return $uuid_results['success']==1;

			}
			else{

				return false;

			}

						
		}
		else{
			
			return false;
						
		}
	}
	else{
		
		return false;
				
	}


$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function get_setting($_setting_name){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	

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


	$url = '';
	
	if (isset($this->rs[0][0]))     
	{
		$url = $this->rs[0][0];
		
		
	}
		
	return $url;
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function stop_notification($_code_notif){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$_url = $this->get_setting('alerts_notifification_ws_url');	
	$_action = 'stop';
	
	$request_array = array(
		'action' => "$_action",
		'notification_code' => "$_code_notif",
		
	);
	
	$_results = $this->send_request($_url, $_action, $request_array);
	
	return $_results;
	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function remove_notification($_code_notif){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$_url = $this->get_setting('alerts_notifification_ws_url');	
	$_action = 'remove';
	
	$request_array = array(
		'action' => "$_action",
		'notification_code' => "$_code_notif",
		
	);
	
	$_results = $this->send_request($_url, $_action, $request_array);
	
	return $_results;
	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function restart_notification($_code_notif){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$_url = $this->get_setting('alerts_notifification_ws_url');	
	$_action = 'restart';
	
	$request_array = array(
		'action' => "$_action",
		'notification_code' => "$_code_notif",
		
	);
	
	$_results = $this->send_request($_url, $_action, $request_array);
	
	return $_results;
	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function disable_queue(){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$_url = $this->get_setting('alerts_notifification_ws_url');	
	
	$_action = 'disableQueue';
	
	$request_array = array(
		
		'action' => "$_action",
		
	);
	
	$_results = $this->send_request($_url, $_action, $request_array);
	
	return $_results;
	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function enable_queue(){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$_url = $this->get_setting('alerts_notifification_ws_url');	
	
	$_action = 'enableQueue';
	
	$request_array = array(
		
		'action' => "$_action",
		
	);
	
	$_results = $this->send_request($_url, $_action, $request_array);
	
	return $_results;
	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function add_notification_to_queue($_code_notif, $_subject, $_excerpt, $_message, $_wilayas, $_time, $_scope, $_notype, $_facilities, $_ref_users){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	


	$_url = $this->get_setting('alerts_notifification_ws_url');	
	
	
	$_action = 'addToQueue';
	
	$request_array = array(
		'action' => "$_action",
		'notification_code' => "$_code_notif",
		'subject' => "$_subject",
		'message' => "$_message",
		'excerpt' => "$_excerpt",
		'wilaya_targets' => "$_wilayas",
		'scheduled' => "$_time",
		'scope' => "$_scope",
		
		'notype' => $_notype,
		'facilities' => $_facilities,
		'alert_ref_users' => $_ref_users,
	);
	
	
	
	$_results = $this->send_request($_url, $_action, $request_array);
	
	return $_results;
	
/*
	$payload = json_encode($request_array);

	
	$ch = curl_init($url);
	
	
	curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

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

	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

	$result = curl_exec($ch);

	$uuid_results = json_decode($result, true);

	curl_close($ch);


	return $uuid_results;	
	*/

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function backgroundPost($url){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	$parts=parse_url($url);
  
  
	
    $fp = fsockopen($parts['host'], 
          isset($parts['port'])?$parts['port']:80, 
          $errno, $errstr, 30);
 
  if (!$fp) {
      return false;
  } else {
      $out = "POST ".$parts['path']." HTTP/1.1\r\n";
      $out.= "Host: ".$parts['host']."\r\n";
      $out.= "Content-Type: application/x-www-form-urlencoded\r\n";
      if (isset($parts['query'])) $out.= "Content-Length: ".strlen($parts['query'])."\r\n";
      $out.= "Connection: Close\r\n\r\n";
      if (isset($parts['query'])) $out.= $parts['query'];
 		
      fwrite($fp, $out);
	  
      fclose($fp);
      return true;
	}	

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function clean_array($a){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	$b=array();
	if (count($a)>0){
		
		$k=0; 
		while ($k<count($a)){
				
			if (!in_array($a[$k], $b)){
					$b[] = $a[$k];
					
				}
				$k++;
			}
	}
	return $b;

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function getMessage($temp, $maladie, $statut_maladie, $date_declaration, $etablissement, $dsp, $tel_medecin){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$txt = '';
	$txt = eregi_replace('<%Maladie>',$maladie,$temp);
	$txt = eregi_replace('<%Etablissement>',$etablissement,$txt);
	$txt = eregi_replace('<%Wilaya>',$dsp,$txt);
	$txt = eregi_replace('<%Tel_Medecin>',$tel_medecin,$txt);
	$txt = eregi_replace('<%Statut>',$this->statut_maladie,$txt);
	$txt = eregi_replace('<%Date_Declaration>',$this->date_declaration,$txt);
	

	return $txt;

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function getAggregatedMessage($temp, $maladie, $nb_cas, $fenobs, $niveau, $region){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  

	$txt = ''; 	
	$txt = eregi_replace('<%Maladie>',$maladie,$temp);	
	$txt = eregi_replace('<%NB_cas>',$nb_cas,$txt);
	$txt = eregi_replace('<%Niveau>',$niveau,$txt);
	$txt = eregi_replace('<%Region>',$region,$txt);	
	$txt = eregi_replace('<%Periode>',$fenobs,$txt);	
	return $txt;

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function push_api_log($_source, $_data){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
		$d = date('Y-m-d H:i:s');
	
		$_data = pg_escape_string($_data);
			
			
	
		$insert_table  = 'public.api_log';      
		$insert_fields = array(   
					'source' => "'".$_source."'",
					'input' => "'".$_data."'",
					'dateheure' => "'".$d."'",
					
				 );

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

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


		$_params = array();

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

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


		$_url = '';

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

		}

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


		$_url = '';

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

		}

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


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

			);

			

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

			curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

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

			curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

		
			$result = curl_exec($ch);

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

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


		$nmc = '';

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

		}


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

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


		$w = '';

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

		}


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

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


		$nmc = array();

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


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

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


		$nmc = '';

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

		}


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

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


		$nmc = array();

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


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


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

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


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


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

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


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


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

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


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


			$communes = array();


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

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


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


			$wilayas = array();


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

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


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

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


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


			$structures = array();


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

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


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


			$structures = array();


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

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


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

		if (filter_var($email, FILTER_VALIDATE_EMAIL)) {

			return true;
		}
		else{

			return false;

		}

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

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


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

$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'off';
}
function is_group_exists($_group){
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['contr_erro'] = 'on';
  
	
	$slogin = $this->Db->qstr($_group);
	

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

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


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

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

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


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

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


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


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

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

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

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

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



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



	$_gdx = array();

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

	}



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

	

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

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



	$_struc = array();

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

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

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


		$_ud= array();

		 $_ud['login'] = $var_username;

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

		$_g = $_ud['group'];



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


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


			if (isset($_gdetails)){

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

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


					if (isset($_struc)){

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

					}
			}

		}


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


	$inst = '';

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

	}


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

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

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


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


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

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


	$nuser = '';

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

	}

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


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

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


	$ngroup = '';

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

	}

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


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

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


	$ngroup = '';

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

	}

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


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

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


	$v = false;

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

			$v = true;
		}


	}

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


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

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


	$v = false;

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

			$v = true;
		}


	}

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


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

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


	$v = false;

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

			$v = true;
		}


	}

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


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

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


	$v = false;

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

			$v = true;
		}


	}

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


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

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


	$rgroup = '';

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

	}

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

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

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


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


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

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


	$inst = '';

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

	}

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

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


	$inst = '';

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

	}


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

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


	$inst = '';

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

	}


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

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


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

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


	$_wils = array();

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


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

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


		$_wils = array();

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


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

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


	$_coms = array();

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


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


	$_users = array();

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


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


	$_users = array();

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


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

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


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

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


	$_coms = array();

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


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

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


	$nwil = '';

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

	}


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

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


	$ncom = '';

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

	}


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


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

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

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




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

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

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

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

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



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



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

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

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

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

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

	$sql = '';

	if ($_reset=='O'){


		$this->delete_links($_group_id);

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


	}
	else{

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




	}



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

	/**
	 * Check for an existing record
	 */

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

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


	if (false == $this->dataset )
	{
		return true;
	}
	elseif ($this->dataset->EOF)
	{
		return false;
	}
	else
	{
		return true;
	}
$_SESSION['scriptcase']['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['botoes'] = $this->nmgp_botoes;
     if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")
     {
         $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "R") && $this->nm_flag_iframe && empty($this->nm_todas_criticas))
     {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe_ajax']))
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['retorno_edit'] = array("edit", "");
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['retorno_edit'] .= "&nmgp_opcao=edit";
          }
          if ($this->sc_evento == "insert" && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] == "F")
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe_ajax']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['retorno_edit'] = array("edit", "fim");
              }
              else
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['run_iframe_ajax']))
              {
                  $this->NM_ajax_info['ajaxJavascript'][] = array("parent.ajax_navigate", $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['retorno_edit'];
                  $this->NM_ajax_info['redir']['target'] = $sJsParent;
              }
              form_fiche_pro_sante_labo_edit_pack_ajax_response();
              exit;
          }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

         <html><body>
         <script type="text/javascript">
<?php
    
    if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe_ajax']))
    {
        $opc = ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['retorno_edit'] . "';";
    }
?>
         </script>
         </body></html>
<?php
         exit;
     }
//-- 
   if ($this->nmgp_opcao == "novo")
   { 
       $out_attached_file = "";  
   } 
   else 
   { 
       $out_attached_file = $this->attached_file;  
   } 
   if ($this->attached_file != "" && $this->attached_file != "none")   
   { 
       $path_attached_file = $this->Ini->root . $this->Ini->path_imagens . "/attached_files" . "/" . $this->attached_file;
       $md5_attached_file  = md5("/attached_files" . $this->attached_file);
       nm_fix_SubDirUpload($this->attached_file,$this->Ini->root . $this->Ini->path_imagens,"/attached_files");
        if (is_file($path_attached_file))  
       { 
           $NM_ler_img = true;
           $out_attached_file = $this->Ini->path_imag_temp . "/sc_attached_file_" . $md5_attached_file . ".gif" ;  
           if (is_file($this->Ini->root . $out_attached_file))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_attached_file) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_ler_img = false;
               } 
           } 
           if ($NM_ler_img) 
           { 
               $tmp_attached_file = fopen($path_attached_file, "r") ; 
               $reg_attached_file = fread($tmp_attached_file, filesize($path_attached_file)) ; 
               fclose($tmp_attached_file) ;  
               $arq_attached_file = fopen($this->Ini->root . $out_attached_file, "w") ;  
               fwrite($arq_attached_file, $reg_attached_file) ;  
               fclose($arq_attached_file) ;  
           } 
           $sc_obj_img = new nm_trata_img($this->Ini->root . $out_attached_file, true);
           $this->nmgp_return_img['attached_file'][0] = $sc_obj_img->getHeight();
           $this->nmgp_return_img['attached_file'][1] = $sc_obj_img->getWidth();
           $NM_redim_img = true;
           $out1_attached_file = $out_attached_file; 
           $md5_attached_file  = md5("/attached_files" . $this->attached_file);
           $out_attached_file = $this->Ini->path_imag_temp . "/sc_attached_file_100100" . $md5_attached_file . ".gif" ;  
           if (is_file($this->Ini->root . $out_attached_file))  
           { 
               $NM_img_time = filemtime($this->Ini->root . $out_attached_file) + 0; 
               if ($this->Ini->nm_timestamp < $NM_img_time)  
               { 
                   $NM_redim_img = false;
               } 
           } 
           if ($NM_redim_img) 
           { 
               if (!$this->Ini->Gd_missing)
               { 
                   $sc_obj_img = new nm_trata_img($this->Ini->root . $out1_attached_file, true);
                   $sc_obj_img->setWidth(100);
                   $sc_obj_img->setHeight(100);
                   $sc_obj_img->setManterAspecto(true);
                   $sc_obj_img->createImg($this->Ini->root . $out_attached_file);
               } 
               else 
               { 
                   $out_attached_file = $out1_attached_file;
               } 
           } 
       if ($this->Ini->Export_img_zip) {
           $this->Ini->Img_export_zip[] = $this->Ini->root . $out_attached_file;
           $out_attached_file = str_replace($this->Ini->path_imag_temp . "/", "", $out_attached_file);
       } 
       } 
   } 
   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_attached_file;
       if (isset($temp_out_attached_file))
       {
           $out_attached_file = $temp_out_attached_file;
       }
       global $temp_out1_attached_file;
       if (isset($temp_out1_attached_file))
       {
           $out1_attached_file = $temp_out1_attached_file;
       }
   }
    $this->date_reception_prelevement_Dt_max = date('Ymd'); 
    $trab_dt_dia = date('d'); 
    $trab_dt_mes = date('m'); 
    $trab_dt_ano = date('Y'); 
    $this->nm_data->nm_calc_data($trab_dt_dia, $trab_dt_mes, $trab_dt_ano, 21, 0, 0, "-"); 
    $this->date_reception_prelevement_Dt_min = $trab_dt_ano . $trab_dt_mes . $trab_dt_dia; 
    $this->date_resultats_labo_Dt_max = date('Ymd'); 
    $trab_dt_dia = date('d'); 
    $trab_dt_mes = date('m'); 
    $trab_dt_ano = date('Y'); 
    $this->nm_data->nm_calc_data($trab_dt_dia, $trab_dt_mes, $trab_dt_ano, 0, 6, 0, "-"); 
    $this->date_resultats_labo_Dt_min = $trab_dt_ano . $trab_dt_mes . $trab_dt_dia; 
        $this->initFormPages();
    include_once("form_fiche_pro_sante_labo_edit_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("code_fiche", "date_declaration", "structure", "user_fk", "maladie_suspectee_nm_fk", "type_prelevement_nm_fk", "date_reception_prelevement", "date_resultats_labo", "resultats_labo", "attached_file", "commentaires", "commentaires_labo"))) {
            $searchOk = true;
        }
        elseif ($field == $this->nmgp_fast_search && in_array($field, array("code_fiche", "date_declaration", "structure", "user_fk", "maladie_suspectee_nm_fk", "type_prelevement_nm_fk", "date_reception_prelevement", "date_resultats_labo", "resultats_labo", "attached_file", "commentaires", "commentaires_labo"))) {
            $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]['form_fiche_pro_sante_labo_edit']['table_refresh']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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)
   {
       $aDateParts = explode(';', $sFormat);

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

       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]['form_fiche_pro_sante_labo_edit']['csrf_token']))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['csrf_token'] = $this->scCsrfGenerateToken();
        }

        return $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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_maladie_suspectee_nm_fk()
   {
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'] = 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]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk']); 
   }
   else
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'] = array(); 
    }

   $old_value_date_declaration = $this->date_declaration;
   $old_value_date_declaration_hora = $this->date_declaration_hora;
   $old_value_date_reception_prelevement = $this->date_reception_prelevement;
   $old_value_date_resultats_labo = $this->date_resultats_labo;
   $this->nm_tira_formatacao();
   if ($this->nmgp_opcao != "nada") {
       $this->nm_converte_datas(false);
   }


   $unformatted_value_date_declaration = $this->date_declaration;
   $unformatted_value_date_declaration_hora = $this->date_declaration_hora;
   $unformatted_value_date_reception_prelevement = $this->date_reception_prelevement;
   $unformatted_value_date_resultats_labo = $this->date_resultats_labo;

   $nm_comando = "SELECT nomenclature_item_code, nomenclature_item  FROM \"public\".ref_nomenclature_items  WHERE nomenclature_fk = 'MALADIES' ORDER BY nomenclature_item_order";

   $this->date_declaration = $old_value_date_declaration;
   $this->date_declaration_hora = $old_value_date_declaration_hora;
   $this->date_reception_prelevement = $old_value_date_reception_prelevement;
   $this->date_resultats_labo = $old_value_date_resultats_labo;

   $_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) 
       { 
              $nmgp_def_dados .= $rs->fields[1] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_maladie_suspectee_nm_fk'][] = $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 Form_lookup_type_prelevement_nm_fk()
   {
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'] = 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]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk']); 
   }
   else
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'] = array(); 
    }

   $old_value_date_declaration = $this->date_declaration;
   $old_value_date_declaration_hora = $this->date_declaration_hora;
   $old_value_date_reception_prelevement = $this->date_reception_prelevement;
   $old_value_date_resultats_labo = $this->date_resultats_labo;
   $this->nm_tira_formatacao();
   if ($this->nmgp_opcao != "nada") {
       $this->nm_converte_datas(false);
   }


   $unformatted_value_date_declaration = $this->date_declaration;
   $unformatted_value_date_declaration_hora = $this->date_declaration_hora;
   $unformatted_value_date_reception_prelevement = $this->date_reception_prelevement;
   $unformatted_value_date_resultats_labo = $this->date_resultats_labo;

   $nm_comando = "SELECT nomenclature_item_code, nomenclature_item  FROM \"public\".ref_nomenclature_items  WHERE nomenclature_fk = 'TYPPRELEV' ORDER BY nomenclature_item";

   $this->date_declaration = $old_value_date_declaration;
   $this->date_declaration_hora = $old_value_date_declaration_hora;
   $this->date_reception_prelevement = $old_value_date_reception_prelevement;
   $this->date_resultats_labo = $old_value_date_resultats_labo;

   $_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) 
       { 
              $nmgp_def_dados .= $rs->fields[1] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['Lookup_type_prelevement_nm_fk'][] = $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]['form_fiche_pro_sante_labo_edit']['where_filter']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['total']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['fast_search']);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_detal'])) 
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_detal'];
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter'])
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter']);
              $this->NM_ajax_info['empty_filter'] = 'ok';
              form_fiche_pro_sante_labo_edit_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 == "code_fiche") 
          {
              $this->SC_monta_condicao($comando, "code_fiche", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "date_declaration") 
          {
              $this->SC_monta_condicao($comando, "date_declaration", $arg_search, $data_search, "DATETIME", false);
          }
          if ($field == "SC_all_Cmp" || $field == "structure") 
          {
              $this->SC_monta_condicao($comando, "\"structure\"", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "user_fk") 
          {
              $this->SC_monta_condicao($comando, "user_fk", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "maladie_suspectee_nm_fk") 
          {
              $data_lookup = $this->SC_lookup_maladie_suspectee_nm_fk($arg_search, $data_search);
              if (is_array($data_lookup) && !empty($data_lookup)) 
              {
                  $this->SC_monta_condicao($comando, "maladie_suspectee_nm_fk", $arg_search, $data_lookup, "VARCHAR", false);
              }
          }
          if ($field == "SC_all_Cmp" || $field == "type_prelevement_nm_fk") 
          {
              $data_lookup = $this->SC_lookup_type_prelevement_nm_fk($arg_search, $data_search);
              if (is_array($data_lookup) && !empty($data_lookup)) 
              {
                  $this->SC_monta_condicao($comando, "type_prelevement_nm_fk", $arg_search, $data_lookup, "VARCHAR", false);
              }
          }
          if ($field == "SC_all_Cmp" || $field == "date_reception_prelevement") 
          {
              $this->SC_monta_condicao($comando, "date_reception_prelevement", $arg_search, $data_search, "DATE", false);
          }
          if ($field == "SC_all_Cmp" || $field == "date_resultats_labo") 
          {
              $this->SC_monta_condicao($comando, "date_resultats_labo", $arg_search, $data_search, "DATE", false);
          }
          if ($field == "SC_all_Cmp" || $field == "resultats_labo") 
          {
              $this->SC_monta_condicao($comando, "resultats_labo", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "attached_file") 
          {
              $this->SC_monta_condicao($comando, "attached_file", $arg_search, $data_search, "VARCHAR", false);
          }
          if ($field == "SC_all_Cmp" || $field == "commentaires") 
          {
              $this->SC_monta_condicao($comando, "commentaires", $arg_search, $data_search, "TEXT", false);
          }
          if ($field == "SC_all_Cmp" || $field == "commentaires_labo") 
          {
              $this->SC_monta_condicao($comando, "commentaires_labo", $arg_search, $data_search, "TEXT", false);
          }
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_detal']) && !empty($comando)) 
      {
          $comando = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_detal'] . " and (" .  $comando . ")";
      }
      if (empty($comando)) 
      {
          $comando = " 1 <> 1 "; 
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter_form'])
      {
          $sc_where = " where " . $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter_form'] . " and ((code_fiche = '" . $_SESSION['var_code_fiche'] . "')) and (" . $comando . ")";
      }
      else
      {
          $sc_where = " where (code_fiche = '" . $_SESSION['var_code_fiche'] . "') and (" . $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_form_fiche_pro_sante_labo_edit = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['total'] = $qt_geral_reg_form_fiche_pro_sante_labo_edit;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['where_filter'] = $comando;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['fast_search'][0] = $field;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['fast_search'][1] = $arg_search;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['fast_search'][2] = $sv_data;
      $rt->Close(); 
      if (isset($rt->fields[0]) && $rt->fields[0] > 0 &&  isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter'])
      {
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter']);
          $this->NM_ajax_info['empty_filter'] = 'ok';
          form_fiche_pro_sante_labo_edit_pack_ajax_response();
          exit;
      }
      elseif (!isset($rt->fields[0]) || $rt->fields[0] == 0)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['empty_filter'] = true;
          $this->NM_ajax_info['empty_filter'] = 'ok';
          form_fiche_pro_sante_labo_edit_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_fiche_ps";$nm_numeric[] = "age_malade";$nm_numeric[] = "longitude";$nm_numeric[] = "latitude";
      if (in_array($campo_join, $nm_numeric))
      {
         if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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 (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 = "'";
         }
         if (in_array($campo_join, $nm_numeric) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase) && (strtoupper($condicao) == "II" || strtoupper($condicao) == "QP" || strtoupper($condicao) == "NP"))
         {
             $nome      = "CAST ($nome AS VARCHAR)";
             $nm_aspas  = "'";
             $nm_aspas1 = "'";
         }
         if (in_array($campo_join, $nm_numeric) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_progress) && (strtoupper($condicao) == "II" || strtoupper($condicao) == "QP" || strtoupper($condicao) == "NP"))
         {
             $nome      = "CAST ($nome AS VARCHAR(255))";
             $nm_aspas  = "'";
             $nm_aspas1 = "'";
         }
      $Nm_datas["date_declaration"] = "datetime";$Nm_datas["date_naissance_malade"] = "date";$Nm_datas["date_apparition_symptomes"] = "date";$Nm_datas["date_hospitalisation"] = "date";$Nm_datas["date_evacuation"] = "date";$Nm_datas["date_validation"] = "datetime";$Nm_datas["date_confirmation_labo"] = "datetime";$Nm_datas["date_sortie"] = "date";$Nm_datas["date_deces"] = "date";$Nm_datas["date_prelevements"] = "date";$Nm_datas["date_reception_prelevement"] = "date";$Nm_datas["date_resultats_labo"] = "date";
         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]['form_fiche_pro_sante_labo_edit']['SC_sep_date']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['SC_sep_date']))
              {
                  $nm_aspas  = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['SC_sep_date'];
                  $nm_aspas1 = $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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')";
          }
          elseif ($Nm_datas[$campo_join] == "date" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          {
              $nome = "convert(char(10)," . $nome . ",121)";
          }
          elseif (($Nm_datas[$campo_join] == "datetime" || $Nm_datas[$campo_join] == "timestamp") && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          {
              $nome = "convert(char(19)," . $nome . ",121)";
          }
          elseif (($Nm_datas[$campo_join] == "times" || $Nm_datas[$campo_join] == "datetime" || $Nm_datas[$campo_join] == "timestamp") && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $nome  = "TO_DATE(TO_CHAR(" . $nome . ", 'yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss')";
          }
          elseif ($Nm_datas[$campo_join] == "datetime" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $nome = "EXTEND(" . $nome . ", YEAR TO FRACTION)";
          }
          elseif ($Nm_datas[$campo_join] == "date" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $nome = "EXTEND(" . $nome . ", YEAR TO DAY)";
          }
          elseif ($Nm_datas[$campo_join] == "datetime" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_progress))
          {
              $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_progress))
          {
              $nome = "to_char (" . $nome . ", 'YYYY-MM-DD')";
          }
      }
         $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'] . $campo . $Nm_accent['arg_f'] . "%'" . $nm_fim_lower . $Nm_accent['arg_apos'];
            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'] . $campo . $Nm_accent['arg_f'] . "%'" . $nm_fim_lower . $Nm_accent['arg_apos'];
            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'] . $campo . $Nm_accent['arg_f'] . "%'" . $nm_fim_lower . $Nm_accent['arg_apos'];
            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_maladie_suspectee_nm_fk($condicao, $campo)
   {
       $result = array();
       $campo_orig = $campo;
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $nm_comando = "SELECT nomenclature_item, nomenclature_item_code FROM \"public\".ref_nomenclature_items WHERE (#cmp_inomenclature_item#cmp_f#cmp_apos LIKE '%#arg_i" . $campo . "#arg_f%'#arg_apos) AND (nomenclature_fk = 'MALADIES')" ; 
       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 SC_lookup_type_prelevement_nm_fk($condicao, $campo)
   {
       $result = array();
       $campo_orig = $campo;
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $nm_comando = "SELECT nomenclature_item, nomenclature_item_code FROM \"public\".ref_nomenclature_items WHERE (#cmp_inomenclature_item#cmp_f#cmp_apos LIKE '%#arg_i" . $campo . "#arg_f%'#arg_apos) AND (nomenclature_fk = 'TYPPRELEV')" ; 
       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 = "form_fiche_pro_sante_labo_edit_fim.php";
   }
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['redir']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['redir'] == 'redir')
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']);
   }
   unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['opc_ant']);
   if ($tipo == 2 && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['nm_run_menu']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['nm_run_menu'] == 1)
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['nm_run_menu'] = 2;
       $nmgp_saida_form = "form_fiche_pro_sante_labo_edit_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;
       }
       form_fiche_pro_sante_labo_edit_pack_ajax_response();
       exit;
   }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

   <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/sys__NM__img__NM__emergency_2785811.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]['form_fiche_pro_sante_labo_edit']['sc_modal']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['masterValue']))
{
    if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dashboard_info']['under_dashboard']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dashboard_info']['under_dashboard']) {
?>
var dbParentFrame = $(parent.document).find("[name='<?php echo $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dashboard_info']['parent_widget']; ?>']");
if (dbParentFrame && dbParentFrame[0] && dbParentFrame[0].contentWindow.scAjaxDetailValue)
{
<?php
        foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['masterValue']);
?>
}
<?php
    }
    else {
?>
if (parent && parent.scAjaxDetailValue)
{
<?php
        foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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]['form_fiche_pro_sante_labo_edit']['masterValue']);
?>
}
<?php
    }
}
?>
      document.form_ok.submit();
   </SCRIPT>
   </BODY>
   </HTML>
<?php
  exit;
}
    function getButtonIds($buttonName) {
        switch ($buttonName) {
            case "retour":
                return array("sc_retour_top.");
                break;
            case "update":
                return array("sc_b_upd_b.sc-unique-btn-1");
                break;
            case "exit":
                return array("sc_b_sai_b.sc-unique-btn-2");
                break;
        }

        return array($buttonName);
    } // getButtonIds

    function displayAppHeader()
    {
        if ($this->Embutida_call) {
            return;
        }
        if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['mostra_cab']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['mostra_cab'] == "N") {
            return;
        }
        if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dashboard_info']['under_dashboard'] && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dashboard_info']['compact_mode'] && !$_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['dashboard_info']['maximized']) {
            return;
        }
        if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['link_info']['compact_mode']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['link_info']['compact_mode']) {
            return;
        }
?>
    <tr><td class="sc-app-header">
<style>
    .scMenuTHeaderFont img, .scGridHeaderFont img , .scFormHeaderFont img , .scTabHeaderFont img , .scContainerHeaderFont img , .scFilterHeaderFont img { height:23px;}
</style>
<div class="scFormHeader" style="height: 54px; padding: 17px 15px; box-sizing: border-box;margin: -1px 0px 0px 0px;width: 100%;">
    <div class="scFormHeaderFont" style="float: left; text-transform: uppercase;"><?php if ($this->nmgp_opcao == "novo") { echo "" . $this->Ini->Nm_lang['lang_othr_frmi_title'] . " \"public\".fiche_prof_sante"; } else { echo "Fiche de déclaration de maladie"; } ?></div>
    <div class="scFormHeaderFont" style="float: right;"><?php echo "" . $_SESSION['var_code_fp_label'] . "" ?></div>
</div>
    </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]['form_fiche_pro_sante_labo_edit']['embutida_liga_form_btn_nav'])) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] != "F" && $_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['run_iframe'] != "R") {
        } else {
            return false;
        }
        return true;
    } // displayAppToolbars

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

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

    function scGetColumnOrderRule($fieldName, &$orderColName, &$orderColOrient, &$orderColRule)
    {
        $sortRule = 'nosort';
        if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['ordem_cmp'] == $fieldName) {
            $orderColName = $fieldName;
            if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_fiche_pro_sante_labo_edit']['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 "longitude":
                return true;
            case "latitude":
                return true;
            default:
                return false;
        }
        return false;
    }

    function scGetDefaultFieldOrder($fieldName)
    {
        switch ($fieldName) {
            case "date_declaration":
                return 'desc';
            case "date_reception_prelevement":
                return 'desc';
            case "date_resultats_labo":
                return 'desc';
            case "id_fiche_ps":
                return 'desc';
            case "date_naissance_malade":
                return 'desc';
            case "age_malade":
                return 'desc';
            case "date_apparition_symptomes":
                return 'desc';
            case "date_hospitalisation":
                return 'desc';
            case "date_evacuation":
                return 'desc';
            case "longitude":
                return 'desc';
            case "latitude":
                return 'desc';
            case "date_validation":
                return 'desc';
            case "date_confirmation_labo":
                return 'desc';
            case "date_sortie":
                return 'desc';
            case "date_deces":
                return 'desc';
            case "date_prelevements":
                return 'desc';
            default:
                return 'asc';
        }
        return 'asc';
    }
}
?>
