<?php
//
class form_accountants_acountants_mob_apl
{
   var $has_where_params = false;
   var $NM_is_redirected = false;
   var $NM_non_ajax_info = 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(),
                                'focus'             => '',
                                'navStatus'         => array(),
                                'navSummary'        => array(),
                                'redir'             => array(),
                                'blockDisplay'      => array(),
                                'fieldDisplay'      => array(),
                                'fieldLabel'        => array(),
                                'readOnly'          => array(),
                                'btnVars'           => array(),
                                'ajaxAlert'         => '',
                                'ajaxMessage'       => '',
                                'ajaxJavascript'    => array(),
                                'buttonDisplay'     => array(),
                                'buttonDisplayVert' => array(),
                                'calendarReload'    => false,
                                'quickSearchRes'    => false,
                                'displayMsg'        => false,
                                'displayMsgTxt'     => '',
                                'dyn_search'        => array(),
                                'empty_filter'      => '',
                               );
   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 $sn;
   var $transection_order;
   var $approved_on_month;
   var $approved_on_month_1;
   var $transection_date;
   var $income_outcome;
   var $income_outcome_1;
   var $income_outcome_type;
   var $income_outcome_type_1;
   var $details_from_menu;
   var $details_from_menu_1;
   var $description;
   var $appartment_shop;
   var $appartment_shop_1;
   var $for_month;
   var $for_month_1;
   var $for_year;
   var $for_year_1;
   var $payment_method;
   var $payment_method_1;
   var $check_number;
   var $payment_voucher;
   var $receipt_voucher;
   var $amount;
   var $depit;
   var $creditor;
   var $remarks;
   var $bank_balance;
   var $creator_name;
   var $creator_date_time;
   var $creator_date_time_hora;
   var $update_name;
   var $update_date_time;
   var $update_date_time_hora;
   var $nm_data;
   var $nmgp_opcao;
   var $nmgp_opc_ant;
   var $sc_evento;
   var $sc_insert_on;
   var $nmgp_clone;
   var $nmgp_return_img = array();
   var $nmgp_dados_form = array();
   var $nmgp_dados_select = array();
   var $nm_location;
   var $nm_flag_iframe;
   var $nm_flag_saida_novo;
   var $nmgp_botoes = array();
   var $nmgp_url_saida;
   var $nmgp_form_show;
   var $nmgp_form_empty;
   var $nmgp_cmp_readonly = array();
   var $nmgp_cmp_hidden = array();
   var $nm_mens_form_ins;
   var $nm_mens_form_upd;
   var $nm_mens_form_del;
   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();
//
//----- 
   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']['amount']))
          {
              $this->amount = $this->NM_ajax_info['param']['amount'];
          }
          if (isset($this->NM_ajax_info['param']['appartment_shop']))
          {
              $this->appartment_shop = $this->NM_ajax_info['param']['appartment_shop'];
          }
          if (isset($this->NM_ajax_info['param']['approved_on_month']))
          {
              $this->approved_on_month = $this->NM_ajax_info['param']['approved_on_month'];
          }
          if (isset($this->NM_ajax_info['param']['bank_balance']))
          {
              $this->bank_balance = $this->NM_ajax_info['param']['bank_balance'];
          }
          if (isset($this->NM_ajax_info['param']['check_number']))
          {
              $this->check_number = $this->NM_ajax_info['param']['check_number'];
          }
          if (isset($this->NM_ajax_info['param']['creditor']))
          {
              $this->creditor = $this->NM_ajax_info['param']['creditor'];
          }
          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']['depit']))
          {
              $this->depit = $this->NM_ajax_info['param']['depit'];
          }
          if (isset($this->NM_ajax_info['param']['description']))
          {
              $this->description = $this->NM_ajax_info['param']['description'];
          }
          if (isset($this->NM_ajax_info['param']['details_from_menu']))
          {
              $this->details_from_menu = $this->NM_ajax_info['param']['details_from_menu'];
          }
          if (isset($this->NM_ajax_info['param']['for_month']))
          {
              $this->for_month = $this->NM_ajax_info['param']['for_month'];
          }
          if (isset($this->NM_ajax_info['param']['for_year']))
          {
              $this->for_year = $this->NM_ajax_info['param']['for_year'];
          }
          if (isset($this->NM_ajax_info['param']['income_outcome']))
          {
              $this->income_outcome = $this->NM_ajax_info['param']['income_outcome'];
          }
          if (isset($this->NM_ajax_info['param']['income_outcome_type']))
          {
              $this->income_outcome_type = $this->NM_ajax_info['param']['income_outcome_type'];
          }
          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_arg_fast_search']))
          {
              $this->nmgp_arg_fast_search = $this->NM_ajax_info['param']['nmgp_arg_fast_search'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_cond_fast_search']))
          {
              $this->nmgp_cond_fast_search = $this->NM_ajax_info['param']['nmgp_cond_fast_search'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_fast_search']))
          {
              $this->nmgp_fast_search = $this->NM_ajax_info['param']['nmgp_fast_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']['payment_method']))
          {
              $this->payment_method = $this->NM_ajax_info['param']['payment_method'];
          }
          if (isset($this->NM_ajax_info['param']['payment_voucher']))
          {
              $this->payment_voucher = $this->NM_ajax_info['param']['payment_voucher'];
          }
          if (isset($this->NM_ajax_info['param']['receipt_voucher']))
          {
              $this->receipt_voucher = $this->NM_ajax_info['param']['receipt_voucher'];
          }
          if (isset($this->NM_ajax_info['param']['remarks']))
          {
              $this->remarks = $this->NM_ajax_info['param']['remarks'];
          }
          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']['sn']))
          {
              $this->sn = $this->NM_ajax_info['param']['sn'];
          }
          if (isset($this->NM_ajax_info['param']['transection_date']))
          {
              $this->transection_date = $this->NM_ajax_info['param']['transection_date'];
          }
          if (isset($this->NM_ajax_info['param']['transection_order']))
          {
              $this->transection_order = $this->NM_ajax_info['param']['transection_order'];
          }
          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->sc_conv_var = array();
      if (!empty($_FILES))
      {
          foreach ($_FILES as $nmgp_campo => $nmgp_valores)
          {
               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 (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)];
               }
               $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 (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)];
               }
               $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->nm_run_menu) && $this->nm_run_menu == 1)
      { 
          $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['nm_run_menu'] = 1;
      } 
      if (isset($_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['embutida_parms']))
      { 
          $this->nmgp_parms = $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['embutida_parms'];
          unset($_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['embutida_parms']);
      } 
      if (isset($this->nmgp_parms) && !empty($this->nmgp_parms)) 
      { 
          if (isset($_SESSION['nm_aba_bg_color'])) 
          { 
              unset($_SESSION['nm_aba_bg_color']);
          }   
          $nmgp_parms = NM_decode_input($nmgp_parms);
          $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_accountants_acountants_mob($cadapar[1]);
                 if ($cadapar[1] == "@ ") {$cadapar[1] = trim($cadapar[1]); }
                 $Tmp_par = $cadapar[0];
                 $this->$Tmp_par = $cadapar[1];
             }
             $ix++;
          }
          if (isset($this->NM_where_filter_form))
          {
              $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['where_filter_form'] = $this->NM_where_filter_form;
              unset($_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['total']);
          }
          if (isset($this->sc_redir_atualiz))
          {
              $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['sc_redir_atualiz'] = $this->sc_redir_atualiz;
          }
          if (isset($this->sc_redir_insert))
          {
              $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['sc_redir_insert'] = $this->sc_redir_insert;
          }
      } 
      elseif (isset($script_case_init) && !empty($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['parms']))
      {
          if ((!isset($this->nmgp_opcao) || ($this->nmgp_opcao != "incluir" && $this->nmgp_opcao != "alterar" && $this->nmgp_opcao != "excluir" && $this->nmgp_opcao != "novo" && $this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")) && (!isset($this->NM_ajax_opcao) || $this->NM_ajax_opcao == ""))
          {
              $todox = str_replace("?#?@?@?", "?#?@ ?@?", $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['parms']);
              $todo  = explode("?@?", $todox);
              $ix = 0;
              while (!empty($todo[$ix]))
              {
                 $cadapar = explode("?#?", $todo[$ix]);
                 if (substr($cadapar[0], 0, 11) == "SC_glo_par_")
                 {
                     $cadapar[0] = substr($cadapar[0], 11);
                     $cadapar[1] = $_SESSION[$cadapar[1]];
                 }
                 if ($cadapar[1] == "@ ") {$cadapar[1] = trim($cadapar[1]); }
                 $Tmp_par = $cadapar[0];
                 $this->$Tmp_par = $cadapar[1];
                 $ix++;
              }
          }
      } 

      if (!$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_accountants_acountants_mob']['lig_edit_lookup']     = true;
          $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['lig_edit_lookup_cb']  = $this->nm_evt_ret_edit;
          $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['lig_edit_lookup_row'] = isset($this->nm_evt_ret_row) ? $this->nm_evt_ret_row : '';
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['lig_edit_lookup']) && $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['lig_edit_lookup'])
      {
          $this->lig_edit_lookup     = true;
          $this->lig_edit_lookup_cb  = $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['lig_edit_lookup_cb'];
          $this->lig_edit_lookup_row = $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['lig_edit_lookup_row'];
      }
      if (!$this->Ini)
      { 
          $this->Ini = new form_accountants_acountants_mob_ini(); 
          $this->Ini->init();
          $this->nm_data = new nm_data("ar");
          $this->app_is_initializing = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['initialize'];
          if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants']))
          {
              foreach ($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants'] as $I_conf => $Conf_opt)
              {
                  $_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob'][$I_conf]  = $Conf_opt;
              }
          }
      } 
      else 
      { 
         $this->nm_data = new nm_data("ar");
      } 
      $_SESSION['sc_session'][$script_case_init]['form_accountants_acountants_mob']['upload_field_info'] = array();

      unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['masterValue']);
      $this->Change_Menu = false;
      $run_iframe = (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe']) && ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "R")) ? true : false;
      if (!$run_iframe && isset($_SESSION['scriptcase']['menu_atual']) && !$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['embutida_call'] && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['sc_outra_jan']) || !$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['sc_outra_jan']))
      {
          $this->sc_init_menu = "x";
          if (isset($_SESSION['scriptcase'][$_SESSION['scriptcase']['menu_atual']]['sc_init']['form_accountants_acountants_mob']))
          {
              $this->sc_init_menu = $_SESSION['scriptcase'][$_SESSION['scriptcase']['menu_atual']]['sc_init']['form_accountants_acountants_mob'];
          }
          elseif (isset($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']]))
          {
              foreach ($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']] as $init => $resto)
              {
                  if ($this->Ini->sc_page == $init)
                  {
                      $this->sc_init_menu = $init;
                      break;
                  }
              }
          }
          if ($this->Ini->sc_page == $this->sc_init_menu && !isset($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['form_accountants_acountants_mob']))
          {
               $_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['form_accountants_acountants_mob']['link'] = $this->Ini->sc_protocolo . $this->Ini->server . $this->Ini->path_link . "" . SC_dir_app_name('form_accountants_acountants_mob') . "/";
               $_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu]['form_accountants_acountants_mob']['label'] = "" . $this->Ini->Nm_lang['lang_othr_frmu_titl'] . " - accountants_acountants";
               $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_accountants_acountants_mob")
                  {
                      $achou = true;
                  }
                  elseif ($achou)
                  {
                      unset($_SESSION['scriptcase']['menu_apls'][$_SESSION['scriptcase']['menu_atual']][$this->sc_init_menu][$apl]);
                      $this->Change_Menu = true;
                  }
              }
          }
      }
      if (!function_exists("nmButtonOutput"))
      {
          include_once($this->Ini->path_lib_php . "nm_gp_config_btn.php");
      }
      include("../_lib/css/" . $this->Ini->str_schema_all . "_form.php");
      $this->Ini->Str_btn_form    = trim($str_button);
      include($this->Ini->path_btn . $this->Ini->Str_btn_form . '/' . $this->Ini->Str_btn_form . $_SESSION['scriptcase']['reg_conf']['css_dir'] . '.php');
      $this->Db = $this->Ini->Db; 
      $this->Ini->Img_sep_form    = "/" . trim($str_toolbar_separator);
      $this->Ini->Color_bg_ajax   = "" == trim($str_ajax_bg)         ? "#000" : $str_ajax_bg;
      $this->Ini->Border_c_ajax   = "" == trim($str_ajax_border_c)   ? ""     : $str_ajax_border_c;
      $this->Ini->Border_s_ajax   = "" == trim($str_ajax_border_s)   ? ""     : $str_ajax_border_s;
      $this->Ini->Border_w_ajax   = "" == trim($str_ajax_border_w)   ? ""     : $str_ajax_border_w;
      $this->Ini->Block_img_exp   = "" == trim($str_block_exp)       ? ""     : $str_block_exp;
      $this->Ini->Block_img_col   = "" == trim($str_block_col)       ? ""     : $str_block_col;
      $this->Ini->Msg_ico_title   = "" == trim($str_msg_ico_title)   ? ""     : $str_msg_ico_title;
      $this->Ini->Msg_ico_body    = "" == trim($str_msg_ico_body)    ? ""     : $str_msg_ico_body;
      $this->Ini->Err_ico_title   = "" == trim($str_err_ico_title)   ? ""     : $str_err_ico_title;
      $this->Ini->Err_ico_body    = "" == trim($str_err_ico_body)    ? ""     : $str_err_ico_body;
      $this->Ini->Cal_ico_back    = "" == trim($str_cal_ico_back)    ? ""     : $str_cal_ico_back;
      $this->Ini->Cal_ico_for     = "" == trim($str_cal_ico_for)     ? ""     : $str_cal_ico_for;
      $this->Ini->Cal_ico_close   = "" == trim($str_cal_ico_close)   ? ""     : $str_cal_ico_close;
      $this->Ini->Tab_space       = "" == trim($str_tab_space)       ? ""     : $str_tab_space;
      $this->Ini->Bubble_tail     = "" == trim($str_bubble_tail)     ? ""     : $str_bubble_tail;
      $this->Ini->Label_sort_pos  = "" == trim($str_label_sort_pos)  ? ""     : $str_label_sort_pos;
      $this->Ini->Label_sort      = "" == trim($str_label_sort)      ? ""     : $str_label_sort;
      $this->Ini->Label_sort_asc  = "" == trim($str_label_sort_asc)  ? ""     : $str_label_sort_asc;
      $this->Ini->Label_sort_desc = "" == trim($str_label_sort_desc) ? ""     : $str_label_sort_desc;
      $this->Ini->Img_status_ok   = "" == trim($str_img_status_ok)   ? ""     : $str_img_status_ok;
      $this->Ini->Img_status_err  = "" == trim($str_img_status_err)  ? ""     : $str_img_status_err;
      $this->Ini->Css_status      = "scFormInputError";
      $this->Ini->Error_icon_span = "" == trim($str_error_icon_span) ? false  : "message" == $str_error_icon_span;
      $this->Ini->Img_qs_search        = "" == trim($img_qs_search)        ? "scriptcase__NM__qs_lupa.png"  : $img_qs_search;
      $this->Ini->Img_qs_clean         = "" == trim($img_qs_clean)         ? "scriptcase__NM__qs_close.png" : $img_qs_clean;
      $this->Ini->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->arr_buttons['group_group_2']= array(
          'value'            => "" . $this->Ini->Nm_lang['lang_btns_options'] . "",
          'hint'             => "" . $this->Ini->Nm_lang['lang_btns_options'] . "",
          'type'             => "button",
          'display'          => "text_img",
          'display_position' => "text_right",
          'image'            => "scriptcase__NM__gear.png",
          'style'            => "default",
      );


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

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

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

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

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

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

      $this->loadFieldConfig();

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

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

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

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

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

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

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

      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['field_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['field_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['field_display'] as $NM_cada_field => $NM_cada_opc)
          {
              $this->nmgp_cmp_hidden[$NM_cada_field] = $NM_cada_opc;
              $this->NM_ajax_info['fieldDisplay'][$NM_cada_field] = $NM_cada_opc;
          }
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['field_readonly']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['field_readonly']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['field_readonly'] as $NM_cada_field => $NM_cada_opc)
          {
              $this->nmgp_cmp_readonly[$NM_cada_field] = "on";
              $this->NM_ajax_info['readOnly'][$NM_cada_field] = $NM_cada_opc;
          }
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['exit']) && $_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['exit'] != '')
      {
          $_SESSION['scriptcase']['sc_url_saida'][$this->Ini->sc_page] = $_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['exit'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_form']))
      {
          $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_form'];
          if (!isset($this->creator_name)){$this->creator_name = $this->nmgp_dados_form['creator_name'];} 
          if (!isset($this->creator_date_time)){$this->creator_date_time = $this->nmgp_dados_form['creator_date_time'];} 
          if (!isset($this->update_name)){$this->update_name = $this->nmgp_dados_form['update_name'];} 
          if (!isset($this->update_date_time)){$this->update_date_time = $this->nmgp_dados_form['update_date_time'];} 
      }
      $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_accountants_acountants_mob", $apls_aba))
              {
                  $this->aba_iframe = true;
                  break;
              }
          }
      }
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['iframe_menu'] && (!isset($_SESSION['scriptcase']['menu_mobile']) || empty($_SESSION['scriptcase']['menu_mobile'])))
      {
          $this->aba_iframe = true;
      }
      $this->Ini->sc_Include($this->Ini->path_lib_php . "/nm_gp_limpa.php", "F", "nm_limpa_valor") ; 
      $this->Ini->sc_Include($this->Ini->path_libs . "/nm_gc.php", "F", "nm_gc") ; 
      $_SESSION['scriptcase']['sc_tab_meses']['int'] = array(
                                      $this->Ini->Nm_lang['lang_mnth_janu'],
                                      $this->Ini->Nm_lang['lang_mnth_febr'],
                                      $this->Ini->Nm_lang['lang_mnth_marc'],
                                      $this->Ini->Nm_lang['lang_mnth_apri'],
                                      $this->Ini->Nm_lang['lang_mnth_mayy'],
                                      $this->Ini->Nm_lang['lang_mnth_june'],
                                      $this->Ini->Nm_lang['lang_mnth_july'],
                                      $this->Ini->Nm_lang['lang_mnth_augu'],
                                      $this->Ini->Nm_lang['lang_mnth_sept'],
                                      $this->Ini->Nm_lang['lang_mnth_octo'],
                                      $this->Ini->Nm_lang['lang_mnth_nove'],
                                      $this->Ini->Nm_lang['lang_mnth_dece']);
      $_SESSION['scriptcase']['sc_tab_meses']['abr'] = array(
                                      $this->Ini->Nm_lang['lang_shrt_mnth_janu'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_febr'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_marc'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_apri'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_mayy'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_june'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_july'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_augu'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_sept'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_octo'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_nove'],
                                      $this->Ini->Nm_lang['lang_shrt_mnth_dece']);
      $_SESSION['scriptcase']['sc_tab_dias']['int'] = array(
                                      $this->Ini->Nm_lang['lang_days_sund'],
                                      $this->Ini->Nm_lang['lang_days_mond'],
                                      $this->Ini->Nm_lang['lang_days_tued'],
                                      $this->Ini->Nm_lang['lang_days_wend'],
                                      $this->Ini->Nm_lang['lang_days_thud'],
                                      $this->Ini->Nm_lang['lang_days_frid'],
                                      $this->Ini->Nm_lang['lang_days_satd']);
      $_SESSION['scriptcase']['sc_tab_dias']['abr'] = array(
                                      $this->Ini->Nm_lang['lang_shrt_days_sund'],
                                      $this->Ini->Nm_lang['lang_shrt_days_mond'],
                                      $this->Ini->Nm_lang['lang_shrt_days_tued'],
                                      $this->Ini->Nm_lang['lang_shrt_days_wend'],
                                      $this->Ini->Nm_lang['lang_shrt_days_thud'],
                                      $this->Ini->Nm_lang['lang_shrt_days_frid'],
                                      $this->Ini->Nm_lang['lang_shrt_days_satd']);
      nm_gc($this->Ini->path_libs);
      $this->Ini->Gd_missing  = true;
      if(function_exists("getProdVersion"))
      {
         $_SESSION['scriptcase']['sc_prod_Version'] = str_replace(".", "", getProdVersion($this->Ini->path_libs));
         if(function_exists("gd_info"))
         {
            $this->Ini->Gd_missing = false;
         }
      }
      $this->Ini->sc_Include($this->Ini->path_lib_php . "/nm_trata_img.php", "C", "nm_trata_img") ; 
      if (isset($_GET['nm_cal_display']))
      {
          if ($this->Embutida_proc)
          { 
              include_once($this->Ini->path_embutida . 'form_accountants_acountants/form_accountants_acountants_mob_calendar.php');
          }
          else
          { 
              include_once($this->Ini->path_aplicacao . 'form_accountants_acountants_mob_calendar.php');
          }
          exit;
      }

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

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

      if ($this->Embutida_proc)
      { 
          require_once($this->Ini->path_embutida . 'form_accountants_acountants/form_accountants_acountants_mob_erro.class.php');
      }
      else
      { 
          require_once($this->Ini->path_aplicacao . "form_accountants_acountants_mob_erro.class.php"); 
      }
      $this->Erro      = new form_accountants_acountants_mob_erro();
      $this->Erro->Ini = $this->Ini;
      $this->proc_fast_search = false;
      if ($this->nmgp_opcao == "fast_search")  
      {
          $this->SC_fast_search($this->nmgp_fast_search, $this->nmgp_cond_fast_search, $this->nmgp_arg_fast_search);
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao'] = "inicio";
          $this->nmgp_opcao = "inicio";
          $this->proc_fast_search = true;
      } 
      if ($nm_opc_lookup != "lookup" && $nm_opc_php != "formphp")
      { 
         if (empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao']))
         { 
             if ($this->sn != "")   
             { 
                 $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao'] = "igual" ;  
             }   
         }   
      } 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao']) && empty($this->nmgp_refresh_fields))
      {
          $this->nmgp_opcao = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao'];  
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao'] = "" ;  
          if ($this->nmgp_opcao == "edit_novo")  
          {
             $this->nmgp_opcao = "novo";
             $this->nm_flag_saida_novo = "S";
          }
      } 
      $this->nm_Start_new = false;
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['start']) && $_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['start'] == 'new')
      {
          $this->nmgp_opcao = "novo";
          $this->nm_Start_new = true;
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao'] = "novo";
          unset($_SESSION['scriptcase']['sc_apl_conf']['form_accountants_acountants_mob']['start']);
      }
      if ($this->nmgp_opcao == "igual")  
      {
          $this->nmgp_opc_ant = $this->nmgp_opcao;
      } 
      else
      {
          $this->nmgp_opc_ant = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opc_ant'];
      } 
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "muda_form")  
      {
          $this->nmgp_botoes = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['botoes'];
          $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['inicio'];
          $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total'] != $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['final'];
      }
      else
      {
      }
      $this->nm_flag_iframe = false;
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_form'])) 
      {
         $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_form'];
      }
      if ($this->nmgp_opcao == "edit_novo")  
      {
          $this->nmgp_opcao = "novo";
          $this->nm_flag_saida_novo = "S";
      }
//
      $this->sc_evento = $this->nmgp_opcao;
      $this->sc_insert_on = false;
      if (isset($this->sn)) { $this->nm_limpa_alfa($this->sn); }
      if (isset($this->transection_order)) { $this->nm_limpa_alfa($this->transection_order); }
      if (isset($this->approved_on_month)) { $this->nm_limpa_alfa($this->approved_on_month); }
      if (isset($this->income_outcome)) { $this->nm_limpa_alfa($this->income_outcome); }
      if (isset($this->income_outcome_type)) { $this->nm_limpa_alfa($this->income_outcome_type); }
      if (isset($this->details_from_menu)) { $this->nm_limpa_alfa($this->details_from_menu); }
      if (isset($this->description)) { $this->nm_limpa_alfa($this->description); }
      if (isset($this->appartment_shop)) { $this->nm_limpa_alfa($this->appartment_shop); }
      if (isset($this->for_month)) { $this->nm_limpa_alfa($this->for_month); }
      if (isset($this->for_year)) { $this->nm_limpa_alfa($this->for_year); }
      if (isset($this->payment_method)) { $this->nm_limpa_alfa($this->payment_method); }
      if (isset($this->check_number)) { $this->nm_limpa_alfa($this->check_number); }
      if (isset($this->payment_voucher)) { $this->nm_limpa_alfa($this->payment_voucher); }
      if (isset($this->receipt_voucher)) { $this->nm_limpa_alfa($this->receipt_voucher); }
      if (isset($this->amount)) { $this->nm_limpa_alfa($this->amount); }
      if (isset($this->depit)) { $this->nm_limpa_alfa($this->depit); }
      if (isset($this->creditor)) { $this->nm_limpa_alfa($this->creditor); }
      if (isset($this->bank_balance)) { $this->nm_limpa_alfa($this->bank_balance); }
      $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->nm_location = $this->Ini->sc_protocolo . $this->Ini->server . $dir_raiz; 
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opc_edit'] = true;  
     if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select'])) 
     {
        $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select'];
     }
   }

   function loadFieldConfig()
   {
      $this->field_config = array();
      //-- sn
      $this->field_config['sn']               = array();
      $this->field_config['sn']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['sn']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['sn']['symbol_dec'] = '';
      $this->field_config['sn']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['sn']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- transection_date
      $this->field_config['transection_date']                 = array();
      $this->field_config['transection_date']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['transection_date']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['transection_date']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'transection_date');
      //-- check_number
      $this->field_config['check_number']               = array();
      $this->field_config['check_number']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['check_number']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['check_number']['symbol_dec'] = '';
      $this->field_config['check_number']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['check_number']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- payment_voucher
      $this->field_config['payment_voucher']               = array();
      $this->field_config['payment_voucher']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['payment_voucher']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['payment_voucher']['symbol_dec'] = '';
      $this->field_config['payment_voucher']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['payment_voucher']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- receipt_voucher
      $this->field_config['receipt_voucher']               = array();
      $this->field_config['receipt_voucher']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['receipt_voucher']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['receipt_voucher']['symbol_dec'] = '';
      $this->field_config['receipt_voucher']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['receipt_voucher']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- amount
      $this->field_config['amount']               = array();
      $this->field_config['amount']['symbol_grp'] = '';
      $this->field_config['amount']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['amount']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['amount']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['amount']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- depit
      $this->field_config['depit']               = array();
      $this->field_config['depit']['symbol_grp'] = '';
      $this->field_config['depit']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['depit']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['depit']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['depit']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- creditor
      $this->field_config['creditor']               = array();
      $this->field_config['creditor']['symbol_grp'] = '';
      $this->field_config['creditor']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['creditor']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['creditor']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['creditor']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- bank_balance
      $this->field_config['bank_balance']               = array();
      $this->field_config['bank_balance']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['bank_balance']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['bank_balance']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['bank_balance']['symbol_mon'] = '';
      $this->field_config['bank_balance']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['bank_balance']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- creator_date_time
      $this->field_config['creator_date_time']                 = array();
      $this->field_config['creator_date_time']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'] . ';' . $_SESSION['scriptcase']['reg_conf']['time_format'];
      $this->field_config['creator_date_time']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['creator_date_time']['time_sep']     = $_SESSION['scriptcase']['reg_conf']['time_sep'];
      $this->field_config['creator_date_time']['date_display'] = "ddmmaaaa;hhiiss";
      $this->new_date_format('DH', 'creator_date_time');
      //-- update_date_time
      $this->field_config['update_date_time']                 = array();
      $this->field_config['update_date_time']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'] . ';' . $_SESSION['scriptcase']['reg_conf']['time_format'];
      $this->field_config['update_date_time']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['update_date_time']['time_sep']     = $_SESSION['scriptcase']['reg_conf']['time_sep'];
      $this->field_config['update_date_time']['date_display'] = "ddmmaaaa;hhiiss";
      $this->new_date_format('DH', 'update_date_time');
   }

   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_accountants_acountants_mob']['Gera_log_access'])
      {
          $this->NM_gera_log_insert("Scriptcase", "access");
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['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_sn' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'sn');
          }
          if ('validate_approved_on_month' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'approved_on_month');
          }
          if ('validate_transection_order' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'transection_order');
          }
          if ('validate_transection_date' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'transection_date');
          }
          if ('validate_income_outcome' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'income_outcome');
          }
          if ('validate_income_outcome_type' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'income_outcome_type');
          }
          if ('validate_details_from_menu' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'details_from_menu');
          }
          if ('validate_description' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'description');
          }
          if ('validate_appartment_shop' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'appartment_shop');
          }
          if ('validate_for_month' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'for_month');
          }
          if ('validate_for_year' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'for_year');
          }
          if ('validate_payment_method' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'payment_method');
          }
          if ('validate_check_number' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'check_number');
          }
          if ('validate_payment_voucher' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'payment_voucher');
          }
          if ('validate_receipt_voucher' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'receipt_voucher');
          }
          if ('validate_amount' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'amount');
          }
          if ('validate_depit' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'depit');
          }
          if ('validate_creditor' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'creditor');
          }
          if ('validate_remarks' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'remarks');
          }
          if ('validate_bank_balance' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'bank_balance');
          }
          form_accountants_acountants_mob_pack_ajax_response();
          exit;
      }
      if ($this->NM_ajax_flag && 'event_' == substr($this->NM_ajax_opcao, 0, 6))
      {
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
          if ('event_income_outcome_onchange' == $this->NM_ajax_opcao)
          {
              $this->income_outcome_onChange();
          }
          if ('event_income_outcome_type_onchange' == $this->NM_ajax_opcao)
          {
              $this->income_outcome_type_onChange();
          }
          form_accountants_acountants_mob_pack_ajax_response();
          exit;
      }
      if (isset($this->sc_inline_call) && 'Y' == $this->sc_inline_call)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['inline_form_seq'] = $this->sc_seq_row;
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
      }
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "recarga_mobile" || $this->nmgp_opcao == "muda_form") 
      {
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
          $nm_sc_sv_opcao = $this->nmgp_opcao; 
          $this->nmgp_opcao = "nada"; 
          $this->nm_acessa_banco();
          if ($this->NM_ajax_flag)
          {
              $this->ajax_return_values();
              form_accountants_acountants_mob_pack_ajax_response();
              exit;
          }
          $this->nm_formatar_campos();
          $this->nmgp_opcao = $nm_sc_sv_opcao; 
          $this->nm_gera_html();
          $this->NM_close_db(); 
          $this->nmgp_opcao = ""; 
          exit; 
      }
      if ($this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "excluir") 
      {
          $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
          if ($Campos_Crit != "") 
          {
              $Campos_Crit = $this->Ini->Nm_lang['lang_errm_flds'] . ' ' . $Campos_Crit ; 
          }
          if ($Campos_Crit != "" || !empty($Campos_Falta) || $this->Campos_Mens_erro != "")
          {
              if ($this->NM_ajax_flag)
              {
                  form_accountants_acountants_mob_pack_ajax_response();
                  exit;
              }
              $campos_erro = $this->Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros);
              $this->Campos_Mens_erro = ""; 
              $this->Erro->mensagem(__FILE__, __LINE__, "critica", $campos_erro); 
              $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_accountants_acountants_mob']['recarga'] = $this->nmgp_opcao;
          $this->nm_mens_form_upd = "تم تعديل السند بنجاح";
          $this->nm_mens_form_del = "تم حذف السند بنجاح";
          if ($this->sc_evento == "update")
          {
              $this->NM_close_db(); 
              $this->nm_tira_formatacao(); 
             $this->nm_converte_datas();
              $this->nm_gera_mensagem($this->nm_mens_form_upd, "form_accountants_acountants_mob.php", "", "sn?#?$this->sn?@?"); 
          }
          if ($this->sc_evento == "insert" || ($this->nmgp_opc_ant == "novo" && $this->nmgp_opcao == "novo" && $this->sc_evento == "novo"))
          {
              $this->NM_close_db(); 
              $this->nm_tira_formatacao(); 
             $this->nm_converte_datas();
              $this->nm_gera_mensagem($this->nm_mens_form_ins, "form_accountants_acountants_mob.php", "", "sn?#?$this->sn?@?"); 
          }
          if ($this->sc_evento == "delete")
          {
              $this->NM_close_db(); 
              $this->nm_tira_formatacao(); 
             $this->nm_converte_datas();
              $this->nm_gera_mensagem($this->nm_mens_form_del, "form_accountants_acountants_mob.php", "", "sn?#?$this->sn?@?nmgp_opcao?#?igual?@?"); 
          }
      }
      if ($this->NM_ajax_flag && 'navigate_form' == $this->NM_ajax_opcao)
      {
          $this->ajax_return_values();
          $this->ajax_add_parameters();
          form_accountants_acountants_mob_pack_ajax_response();
          exit;
      }
      $this->nm_formatar_campos();
      if ($this->NM_ajax_flag)
      {
          $this->NM_ajax_info['result'] = 'OK';
          if ('alterar' == $this->NM_ajax_info['param']['nmgp_opcao'])
          {
              $this->NM_ajax_info['msgDisplay'] = NM_charset_to_utf8($this->Ini->Nm_lang['lang_othr_ajax_frmu']);
          }
          form_accountants_acountants_mob_pack_ajax_response();
          exit;
      }
      $this->nm_gera_html();
      $this->NM_close_db(); 
      $this->nmgp_opcao = ""; 
      if ($this->Change_Menu)
      {
          $apl_menu  = $_SESSION['scriptcase']['menu_atual'];
          $Arr_rastro = array();
          if (isset($_SESSION['scriptcase']['menu_apls'][$apl_menu][$this->sc_init_menu]) && count($_SESSION['scriptcase']['menu_apls'][$apl_menu][$this->sc_init_menu]) > 1)
          {
              foreach ($_SESSION['scriptcase']['menu_apls'][$apl_menu][$this->sc_init_menu] as $menu => $apls)
              {
                 $Arr_rastro[] = "'<a href=\"" . $apls['link'] . "?script_case_init=" . $this->sc_init_menu . "&script_case_session=" . session_id() . "\" 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 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_accountants_acountants_mob']['SC_sep_date']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date']))
       {
           $delim  = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date'];
           $delim1 = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date1'];
       }
       $dt  = $delim . date('Y-m-d H:i:s') . $delim1;
       $usr = isset($_SESSION['usr_login']) ? $_SESSION['usr_login'] : "";
       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_access))
       { 
           $comando = "INSERT INTO sc_mylog (inserted_date, username, application, creator, ip_user, `action`, description) VALUES ($dt, " . $this->Db->qstr($usr) . ", 'form_accountants_acountants_mob', '$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_mylog (id, inserted_date, username, application, creator, ip_user, action, description) VALUES (NULL, $dt, " . $this->Db->qstr($usr) . ", 'form_accountants_acountants_mob', '$orig', '" . $_SERVER['REMOTE_ADDR'] . "', '$evento', " . $this->Db->qstr($texto) . ")"; 
       } 
       else
       { 
           $comando = "INSERT INTO sc_mylog (inserted_date, username, application, creator, ip_user, action, description) VALUES ($dt, " . $this->Db->qstr($usr) . ", 'form_accountants_acountants_mob', '$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_accountants_acountants_mob_pack_ajax_response();
               exit; 
           }
       }
   }
//
//--------------------------------------------------------------------------------------
   function NM_close_db()
   {
       if ($this->Db && !$this->Embutida_proc)
       { 
           $this->Db->Close(); 
       } 
   }
//
//--------------------------------------------------------------------------------------
   function Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros, $mode = 3) 
   {
       switch ($mode)
       {
           case 1:
               $campos_erro = array();
               if (!empty($Campos_Crit))
               {
                   $campos_erro[] = $Campos_Crit;
               }
               if (!empty($Campos_Falta))
               {
                   $campos_erro[] = $this->Formata_Campos_Falta($Campos_Falta);
               }
               if (!empty($this->Campos_Mens_erro))
               {
                   $campos_erro[] = $this->Campos_Mens_erro;
               }
               return implode('<br />', $campos_erro);
               break;

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

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

   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 Recupera_Nome_Campo($campo) 
   {
       switch($campo)
       {
           case 'sn':
               return "المسلسل";
               break;
           case 'approved_on_month':
               return "معتمد في شهر";
               break;
           case 'transection_order':
               return "Transection Order";
               break;
           case 'transection_date':
               return "تاريخ اجراء العملية";
               break;
           case 'income_outcome':
               return "مصروفات / ايرادات";
               break;
           case 'income_outcome_type':
               return "نوع الصرف / الايراد";
               break;
           case 'details_from_menu':
               return "تفاصيل البيان";
               break;
           case 'description':
               return "الوصف";
               break;
           case 'appartment_shop':
               return "Appartment Shop";
               break;
           case 'for_month':
               return "عن شهر";
               break;
           case 'for_year':
               return "عن سنة";
               break;
           case 'payment_method':
               return "طريقة الدفع";
               break;
           case 'check_number':
               return "رقم الشيك";
               break;
           case 'payment_voucher':
               return "رقم سند الصرف";
               break;
           case 'receipt_voucher':
               return "رقم سند القبض";
               break;
           case 'amount':
               return "المبلغ";
               break;
           case 'depit':
               return "Depit";
               break;
           case 'creditor':
               return "Creditor";
               break;
           case 'remarks':
               return "ملاحظات";
               break;
           case 'bank_balance':
               return "حركة البنك";
               break;
           case 'creator_name':
               return "Creator Name";
               break;
           case 'creator_date_time':
               return "Creator Date Time";
               break;
           case 'update_name':
               return "Update Name";
               break;
           case 'update_date_time':
               return "Update Date Time";
               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;
//---------------------------------------------------------
     $this->sc_force_zero = array();

     if ('' == $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_accountants_acountants_mob']) || !is_array($this->NM_ajax_info['errList']['geral_form_accountants_acountants_mob']))
              {
                  $this->NM_ajax_info['errList']['geral_form_accountants_acountants_mob'] = array();
              }
              $this->NM_ajax_info['errList']['geral_form_accountants_acountants_mob'][] = "CSRF: " . $this->Ini->Nm_lang['lang_errm_ajax_csrf'];
          }
     }
      if ('' == $filtro || 'sn' == $filtro)
        $this->ValidateField_sn($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'approved_on_month' == $filtro)
        $this->ValidateField_approved_on_month($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'transection_order' == $filtro)
        $this->ValidateField_transection_order($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'transection_date' == $filtro)
        $this->ValidateField_transection_date($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'income_outcome' == $filtro)
        $this->ValidateField_income_outcome($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'income_outcome_type' == $filtro)
        $this->ValidateField_income_outcome_type($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'details_from_menu' == $filtro)
        $this->ValidateField_details_from_menu($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'description' == $filtro)
        $this->ValidateField_description($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'appartment_shop' == $filtro)
        $this->ValidateField_appartment_shop($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'for_month' == $filtro)
        $this->ValidateField_for_month($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'for_year' == $filtro)
        $this->ValidateField_for_year($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'payment_method' == $filtro)
        $this->ValidateField_payment_method($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'check_number' == $filtro)
        $this->ValidateField_check_number($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'payment_voucher' == $filtro)
        $this->ValidateField_payment_voucher($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'receipt_voucher' == $filtro)
        $this->ValidateField_receipt_voucher($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'amount' == $filtro)
        $this->ValidateField_amount($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'depit' == $filtro)
        $this->ValidateField_depit($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'creditor' == $filtro)
        $this->ValidateField_creditor($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'remarks' == $filtro)
        $this->ValidateField_remarks($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'bank_balance' == $filtro)
        $this->ValidateField_bank_balance($Campos_Crit, $Campos_Falta, $Campos_Erros);
//-- converter datas   
          $this->nm_converte_datas();
//---
      if (!empty($Campos_Crit) || !empty($Campos_Falta) || !empty($this->Campos_Mens_erro))
      {
          if (!empty($this->sc_force_zero))
          {
              foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
              {
                  eval('$this->' . $sc_force_zero_field . ' = "";');
                  unset($this->sc_force_zero[$i_force_zero]);
              }
          }
      }
   }

    function ValidateField_sn(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->sn == "")  
      { 
          $this->sn = 0;
      } 
      nm_limpa_numero($this->sn, $this->field_config['sn']['symbol_grp']) ; 
      if ($this->nmgp_opcao == "incluir")
      { 
          if ($this->sn != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->sn) > $iTestSize)  
              { 
                  $Campos_Crit .= "المسلسل: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['sn']))
                  {
                      $Campos_Erros['sn'] = array();
                  }
                  $Campos_Erros['sn'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['sn']) || !is_array($this->NM_ajax_info['errList']['sn']))
                  {
                      $this->NM_ajax_info['errList']['sn'] = array();
                  }
                  $this->NM_ajax_info['errList']['sn'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->sn, 11, 0, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "المسلسل; " ; 
                  if (!isset($Campos_Erros['sn']))
                  {
                      $Campos_Erros['sn'] = array();
                  }
                  $Campos_Erros['sn'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['sn']) || !is_array($this->NM_ajax_info['errList']['sn']))
                  {
                      $this->NM_ajax_info['errList']['sn'] = array();
                  }
                  $this->NM_ajax_info['errList']['sn'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_sn

    function ValidateField_approved_on_month(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->approved_on_month == "" && $this->nmgp_opcao != "excluir")
      { 
      } 
    } // ValidateField_approved_on_month

    function ValidateField_transection_order(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->transection_order) > 20) 
          { 
              $Campos_Crit .= "Transection Order " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 20 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['transection_order']))
              {
                  $Campos_Erros['transection_order'] = array();
              }
              $Campos_Erros['transection_order'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 20 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['transection_order']) || !is_array($this->NM_ajax_info['errList']['transection_order']))
              {
                  $this->NM_ajax_info['errList']['transection_order'] = array();
              }
              $this->NM_ajax_info['errList']['transection_order'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 20 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_transection_order

    function ValidateField_transection_date(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      nm_limpa_data($this->transection_date, $this->field_config['transection_date']['date_sep']) ; 
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          $guarda_datahora = $this->field_config['transection_date']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['transection_date']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['transection_date']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['transection_date']['date_sep']) ; 
          if (trim($this->transection_date) != "")  
          { 
              if ($teste_validade->Data($this->transection_date, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $Campos_Crit .= "تاريخ اجراء العملية; " ; 
                  if (!isset($Campos_Erros['transection_date']))
                  {
                      $Campos_Erros['transection_date'] = array();
                  }
                  $Campos_Erros['transection_date'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['transection_date']) || !is_array($this->NM_ajax_info['errList']['transection_date']))
                  {
                      $this->NM_ajax_info['errList']['transection_date'] = array();
                  }
                  $this->NM_ajax_info['errList']['transection_date'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
           elseif ((!$this->NM_ajax_flag || 'validate_transection_date' != $this->NM_ajax_opcao) && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['php_cmp_required']['transection_date']) || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['php_cmp_required']['transection_date'] == "on")) 
           { 
              $Campos_Falta[] = "تاريخ اجراء العملية" ; 
              if (!isset($Campos_Erros['transection_date']))
              {
                  $Campos_Erros['transection_date'] = array();
              }
              $Campos_Erros['transection_date'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
                  if (!isset($this->NM_ajax_info['errList']['transection_date']) || !is_array($this->NM_ajax_info['errList']['transection_date']))
                  {
                      $this->NM_ajax_info['errList']['transection_date'] = array();
                  }
                  $this->NM_ajax_info['errList']['transection_date'][] = $this->Ini->Nm_lang['lang_errm_ajax_rqrd'];
           } 
          $this->field_config['transection_date']['date_format'] = $guarda_datahora; 
       } 
    } // ValidateField_transection_date

    function ValidateField_income_outcome(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->income_outcome == "" && $this->nmgp_opcao != "excluir")
      { 
      } 
    } // ValidateField_income_outcome

    function ValidateField_income_outcome_type(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
               if (!empty($this->income_outcome_type) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']) && !in_array($this->income_outcome_type, $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']))
               {
                   $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($Campos_Erros['income_outcome_type']))
                   {
                       $Campos_Erros['income_outcome_type'] = array();
                   }
                   $Campos_Erros['income_outcome_type'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($this->NM_ajax_info['errList']['income_outcome_type']) || !is_array($this->NM_ajax_info['errList']['income_outcome_type']))
                   {
                       $this->NM_ajax_info['errList']['income_outcome_type'] = array();
                   }
                   $this->NM_ajax_info['errList']['income_outcome_type'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
               }
    } // ValidateField_income_outcome_type

    function ValidateField_details_from_menu(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
               if (!empty($this->details_from_menu) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']) && !in_array($this->details_from_menu, $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']))
               {
                   $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($Campos_Erros['details_from_menu']))
                   {
                       $Campos_Erros['details_from_menu'] = array();
                   }
                   $Campos_Erros['details_from_menu'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($this->NM_ajax_info['errList']['details_from_menu']) || !is_array($this->NM_ajax_info['errList']['details_from_menu']))
                   {
                       $this->NM_ajax_info['errList']['details_from_menu'] = array();
                   }
                   $this->NM_ajax_info['errList']['details_from_menu'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
               }
    } // ValidateField_details_from_menu

    function ValidateField_description(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->description) > 200) 
          { 
              $Campos_Crit .= "الوصف " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 200 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['description']))
              {
                  $Campos_Erros['description'] = array();
              }
              $Campos_Erros['description'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 200 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['description']) || !is_array($this->NM_ajax_info['errList']['description']))
              {
                  $this->NM_ajax_info['errList']['description'] = array();
              }
              $this->NM_ajax_info['errList']['description'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 200 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_description

    function ValidateField_appartment_shop(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
               if (!empty($this->appartment_shop) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']) && !in_array($this->appartment_shop, $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']))
               {
                   $Campos_Crit .= $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($Campos_Erros['appartment_shop']))
                   {
                       $Campos_Erros['appartment_shop'] = array();
                   }
                   $Campos_Erros['appartment_shop'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
                   if (!isset($this->NM_ajax_info['errList']['appartment_shop']) || !is_array($this->NM_ajax_info['errList']['appartment_shop']))
                   {
                       $this->NM_ajax_info['errList']['appartment_shop'] = array();
                   }
                   $this->NM_ajax_info['errList']['appartment_shop'][] = $this->Ini->Nm_lang['lang_errm_ajax_data'];
               }
    } // ValidateField_appartment_shop

    function ValidateField_for_month(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->for_month == "" && $this->nmgp_opcao != "excluir")
      { 
      } 
    } // ValidateField_for_month

    function ValidateField_for_year(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->for_year == "" && $this->nmgp_opcao != "excluir")
      { 
      } 
      if ($this->for_year == "")  
      { 
          $this->for_year = 0;
          $this->sc_force_zero[] = 'for_year';
      } 
    } // ValidateField_for_year

    function ValidateField_payment_method(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->payment_method == "" && $this->nmgp_opcao != "excluir")
      { 
      } 
    } // ValidateField_payment_method

    function ValidateField_check_number(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->check_number == "")  
      { 
          $this->check_number = 0;
          $this->sc_force_zero[] = 'check_number';
      } 
      $this->nm_tira_mask($this->check_number, "999999999", "(){}[].,;:-+/ "); 
      nm_limpa_numero($this->check_number, $this->field_config['check_number']['symbol_grp']) ; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->check_number != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->check_number) > $iTestSize)  
              { 
                  $Campos_Crit .= "رقم الشيك: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['check_number']))
                  {
                      $Campos_Erros['check_number'] = array();
                  }
                  $Campos_Erros['check_number'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['check_number']) || !is_array($this->NM_ajax_info['errList']['check_number']))
                  {
                      $this->NM_ajax_info['errList']['check_number'] = array();
                  }
                  $this->NM_ajax_info['errList']['check_number'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->check_number, 11, 0, -0, 99999999999, "N") == false)  
              { 
                  $Campos_Crit .= "رقم الشيك; " ; 
                  if (!isset($Campos_Erros['check_number']))
                  {
                      $Campos_Erros['check_number'] = array();
                  }
                  $Campos_Erros['check_number'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['check_number']) || !is_array($this->NM_ajax_info['errList']['check_number']))
                  {
                      $this->NM_ajax_info['errList']['check_number'] = array();
                  }
                  $this->NM_ajax_info['errList']['check_number'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_check_number

    function ValidateField_payment_voucher(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->payment_voucher == "")  
      { 
          $this->payment_voucher = 0;
          $this->sc_force_zero[] = 'payment_voucher';
      } 
      $this->nm_tira_mask($this->payment_voucher, "999999999", "(){}[].,;:-+/ "); 
      nm_limpa_numero($this->payment_voucher, $this->field_config['payment_voucher']['symbol_grp']) ; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->payment_voucher != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->payment_voucher) > $iTestSize)  
              { 
                  $Campos_Crit .= "رقم سند الصرف: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['payment_voucher']))
                  {
                      $Campos_Erros['payment_voucher'] = array();
                  }
                  $Campos_Erros['payment_voucher'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['payment_voucher']) || !is_array($this->NM_ajax_info['errList']['payment_voucher']))
                  {
                      $this->NM_ajax_info['errList']['payment_voucher'] = array();
                  }
                  $this->NM_ajax_info['errList']['payment_voucher'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->payment_voucher, 11, 0, -0, 99999999999, "N") == false)  
              { 
                  $Campos_Crit .= "رقم سند الصرف; " ; 
                  if (!isset($Campos_Erros['payment_voucher']))
                  {
                      $Campos_Erros['payment_voucher'] = array();
                  }
                  $Campos_Erros['payment_voucher'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['payment_voucher']) || !is_array($this->NM_ajax_info['errList']['payment_voucher']))
                  {
                      $this->NM_ajax_info['errList']['payment_voucher'] = array();
                  }
                  $this->NM_ajax_info['errList']['payment_voucher'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_payment_voucher

    function ValidateField_receipt_voucher(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->receipt_voucher == "")  
      { 
          $this->receipt_voucher = 0;
          $this->sc_force_zero[] = 'receipt_voucher';
      } 
      $this->nm_tira_mask($this->receipt_voucher, "999999999", "(){}[].,;:-+/ "); 
      nm_limpa_numero($this->receipt_voucher, $this->field_config['receipt_voucher']['symbol_grp']) ; 
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->receipt_voucher != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->receipt_voucher) > $iTestSize)  
              { 
                  $Campos_Crit .= "رقم سند القبض: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['receipt_voucher']))
                  {
                      $Campos_Erros['receipt_voucher'] = array();
                  }
                  $Campos_Erros['receipt_voucher'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['receipt_voucher']) || !is_array($this->NM_ajax_info['errList']['receipt_voucher']))
                  {
                      $this->NM_ajax_info['errList']['receipt_voucher'] = array();
                  }
                  $this->NM_ajax_info['errList']['receipt_voucher'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->receipt_voucher, 11, 0, -0, 99999999999, "N") == false)  
              { 
                  $Campos_Crit .= "رقم سند القبض; " ; 
                  if (!isset($Campos_Erros['receipt_voucher']))
                  {
                      $Campos_Erros['receipt_voucher'] = array();
                  }
                  $Campos_Erros['receipt_voucher'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['receipt_voucher']) || !is_array($this->NM_ajax_info['errList']['receipt_voucher']))
                  {
                      $this->NM_ajax_info['errList']['receipt_voucher'] = array();
                  }
                  $this->NM_ajax_info['errList']['receipt_voucher'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_receipt_voucher

    function ValidateField_amount(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->amount == "")  
      { 
          $this->amount = 0;
          $this->sc_force_zero[] = 'amount';
      } 
      if (!empty($this->field_config['amount']['symbol_dec']))
      {
          nm_limpa_valor($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp']) ; 
          if ('.' == substr($this->amount, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->amount, 1)))
              {
                  $this->amount = '';
              }
              else
              {
                  $this->amount = '0' . $this->amount;
              }
          }
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->amount != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->amount) > $iTestSize)  
              { 
                  $Campos_Crit .= "المبلغ: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['amount']))
                  {
                      $Campos_Erros['amount'] = array();
                  }
                  $Campos_Erros['amount'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['amount']) || !is_array($this->NM_ajax_info['errList']['amount']))
                  {
                      $this->NM_ajax_info['errList']['amount'] = array();
                  }
                  $this->NM_ajax_info['errList']['amount'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->amount, 7, 3, -0, 9999999999, "N") == false)  
              { 
                  $Campos_Crit .= "المبلغ; " ; 
                  if (!isset($Campos_Erros['amount']))
                  {
                      $Campos_Erros['amount'] = array();
                  }
                  $Campos_Erros['amount'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['amount']) || !is_array($this->NM_ajax_info['errList']['amount']))
                  {
                      $this->NM_ajax_info['errList']['amount'] = array();
                  }
                  $this->NM_ajax_info['errList']['amount'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_amount

    function ValidateField_depit(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->depit == "")  
      { 
          $this->depit = 0;
          $this->sc_force_zero[] = 'depit';
      } 
      if (!empty($this->field_config['depit']['symbol_dec']))
      {
          nm_limpa_valor($this->depit, $this->field_config['depit']['symbol_dec'], $this->field_config['depit']['symbol_grp']) ; 
          if ('.' == substr($this->depit, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->depit, 1)))
              {
                  $this->depit = '';
              }
              else
              {
                  $this->depit = '0' . $this->depit;
              }
          }
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->depit != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->depit) > $iTestSize)  
              { 
                  $Campos_Crit .= "Depit: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['depit']))
                  {
                      $Campos_Erros['depit'] = array();
                  }
                  $Campos_Erros['depit'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['depit']) || !is_array($this->NM_ajax_info['errList']['depit']))
                  {
                      $this->NM_ajax_info['errList']['depit'] = array();
                  }
                  $this->NM_ajax_info['errList']['depit'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->depit, 7, 3, -0, 9999999999, "N") == false)  
              { 
                  $Campos_Crit .= "Depit; " ; 
                  if (!isset($Campos_Erros['depit']))
                  {
                      $Campos_Erros['depit'] = array();
                  }
                  $Campos_Erros['depit'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['depit']) || !is_array($this->NM_ajax_info['errList']['depit']))
                  {
                      $this->NM_ajax_info['errList']['depit'] = array();
                  }
                  $this->NM_ajax_info['errList']['depit'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_depit

    function ValidateField_creditor(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->creditor == "")  
      { 
          $this->creditor = 0;
          $this->sc_force_zero[] = 'creditor';
      } 
      if (!empty($this->field_config['creditor']['symbol_dec']))
      {
          nm_limpa_valor($this->creditor, $this->field_config['creditor']['symbol_dec'], $this->field_config['creditor']['symbol_grp']) ; 
          if ('.' == substr($this->creditor, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->creditor, 1)))
              {
                  $this->creditor = '';
              }
              else
              {
                  $this->creditor = '0' . $this->creditor;
              }
          }
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->creditor != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->creditor) > $iTestSize)  
              { 
                  $Campos_Crit .= "Creditor: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['creditor']))
                  {
                      $Campos_Erros['creditor'] = array();
                  }
                  $Campos_Erros['creditor'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['creditor']) || !is_array($this->NM_ajax_info['errList']['creditor']))
                  {
                      $this->NM_ajax_info['errList']['creditor'] = array();
                  }
                  $this->NM_ajax_info['errList']['creditor'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->creditor, 7, 3, -0, 9999999999, "N") == false)  
              { 
                  $Campos_Crit .= "Creditor; " ; 
                  if (!isset($Campos_Erros['creditor']))
                  {
                      $Campos_Erros['creditor'] = array();
                  }
                  $Campos_Erros['creditor'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['creditor']) || !is_array($this->NM_ajax_info['errList']['creditor']))
                  {
                      $this->NM_ajax_info['errList']['creditor'] = array();
                  }
                  $this->NM_ajax_info['errList']['creditor'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_creditor

    function ValidateField_remarks(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->remarks) > 32767) 
          { 
              $Campos_Crit .= "ملاحظات " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['remarks']))
              {
                  $Campos_Erros['remarks'] = array();
              }
              $Campos_Erros['remarks'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['remarks']) || !is_array($this->NM_ajax_info['errList']['remarks']))
              {
                  $this->NM_ajax_info['errList']['remarks'] = array();
              }
              $this->NM_ajax_info['errList']['remarks'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 32767 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_remarks

    function ValidateField_bank_balance(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->bank_balance == "")  
      { 
          $this->bank_balance = 0;
          $this->sc_force_zero[] = 'bank_balance';
      } 
      if (!empty($this->field_config['bank_balance']['symbol_dec']))
      {
          $this->sc_remove_currency($this->bank_balance, $this->field_config['bank_balance']['symbol_dec'], $this->field_config['bank_balance']['symbol_grp'], $this->field_config['bank_balance']['symbol_mon']); 
          nm_limpa_valor($this->bank_balance, $this->field_config['bank_balance']['symbol_dec'], $this->field_config['bank_balance']['symbol_grp']) ; 
          if ('.' == substr($this->bank_balance, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->bank_balance, 1)))
              {
                  $this->bank_balance = '';
              }
              else
              {
                  $this->bank_balance = '0' . $this->bank_balance;
              }
          }
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->bank_balance != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->bank_balance) > $iTestSize)  
              { 
                  $Campos_Crit .= "حركة البنك: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['bank_balance']))
                  {
                      $Campos_Erros['bank_balance'] = array();
                  }
                  $Campos_Erros['bank_balance'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['bank_balance']) || !is_array($this->NM_ajax_info['errList']['bank_balance']))
                  {
                      $this->NM_ajax_info['errList']['bank_balance'] = array();
                  }
                  $this->NM_ajax_info['errList']['bank_balance'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->bank_balance, 7, 3, -0, 9999999999, "N") == false)  
              { 
                  $Campos_Crit .= "حركة البنك; " ; 
                  if (!isset($Campos_Erros['bank_balance']))
                  {
                      $Campos_Erros['bank_balance'] = array();
                  }
                  $Campos_Erros['bank_balance'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['bank_balance']) || !is_array($this->NM_ajax_info['errList']['bank_balance']))
                  {
                      $this->NM_ajax_info['errList']['bank_balance'] = array();
                  }
                  $this->NM_ajax_info['errList']['bank_balance'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_bank_balance

    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['sn'] = $this->sn;
    $this->nmgp_dados_form['approved_on_month'] = $this->approved_on_month;
    $this->nmgp_dados_form['transection_order'] = $this->transection_order;
    $this->nmgp_dados_form['transection_date'] = (strlen(trim($this->transection_date)) > 19) ? str_replace(".", ":", $this->transection_date) : trim($this->transection_date);
    $this->nmgp_dados_form['income_outcome'] = $this->income_outcome;
    $this->nmgp_dados_form['income_outcome_type'] = $this->income_outcome_type;
    $this->nmgp_dados_form['details_from_menu'] = $this->details_from_menu;
    $this->nmgp_dados_form['description'] = $this->description;
    $this->nmgp_dados_form['appartment_shop'] = $this->appartment_shop;
    $this->nmgp_dados_form['for_month'] = $this->for_month;
    $this->nmgp_dados_form['for_year'] = $this->for_year;
    $this->nmgp_dados_form['payment_method'] = $this->payment_method;
    $this->nmgp_dados_form['check_number'] = $this->check_number;
    $this->nmgp_dados_form['payment_voucher'] = $this->payment_voucher;
    $this->nmgp_dados_form['receipt_voucher'] = $this->receipt_voucher;
    $this->nmgp_dados_form['amount'] = $this->amount;
    $this->nmgp_dados_form['depit'] = $this->depit;
    $this->nmgp_dados_form['creditor'] = $this->creditor;
    $this->nmgp_dados_form['remarks'] = $this->remarks;
    $this->nmgp_dados_form['bank_balance'] = $this->bank_balance;
    $this->nmgp_dados_form['creator_name'] = $this->creator_name;
    $this->nmgp_dados_form['creator_date_time'] = (strlen(trim($this->creator_date_time)) > 19) ? str_replace(".", ":", $this->creator_date_time) : trim($this->creator_date_time);
    $this->nmgp_dados_form['update_name'] = $this->update_name;
    $this->nmgp_dados_form['update_date_time'] = (strlen(trim($this->update_date_time)) > 19) ? str_replace(".", ":", $this->update_date_time) : trim($this->update_date_time);
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_form'] = $this->nmgp_dados_form;
   }
   function nm_tira_formatacao()
   {
      global $nm_form_submit;
         $this->formatado = false;
      nm_limpa_numero($this->sn, $this->field_config['sn']['symbol_grp']) ; 
      nm_limpa_data($this->transection_date, $this->field_config['transection_date']['date_sep']) ; 
      $this->nm_tira_mask($this->check_number, "999999999", "(){}[].,;:-+/ "); 
      nm_limpa_numero($this->check_number, $this->field_config['check_number']['symbol_grp']) ; 
      $this->nm_tira_mask($this->payment_voucher, "999999999", "(){}[].,;:-+/ "); 
      nm_limpa_numero($this->payment_voucher, $this->field_config['payment_voucher']['symbol_grp']) ; 
      $this->nm_tira_mask($this->receipt_voucher, "999999999", "(){}[].,;:-+/ "); 
      nm_limpa_numero($this->receipt_voucher, $this->field_config['receipt_voucher']['symbol_grp']) ; 
      if (!empty($this->field_config['amount']['symbol_dec']))
      {
         nm_limpa_valor($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp']);
      }
      if (!empty($this->field_config['depit']['symbol_dec']))
      {
         nm_limpa_valor($this->depit, $this->field_config['depit']['symbol_dec'], $this->field_config['depit']['symbol_grp']);
      }
      if (!empty($this->field_config['creditor']['symbol_dec']))
      {
         nm_limpa_valor($this->creditor, $this->field_config['creditor']['symbol_dec'], $this->field_config['creditor']['symbol_grp']);
      }
      if (!empty($this->field_config['bank_balance']['symbol_dec']))
      {
         $this->sc_remove_currency($this->bank_balance, $this->field_config['bank_balance']['symbol_dec'], $this->field_config['bank_balance']['symbol_grp'], $this->field_config['bank_balance']['symbol_mon']);
         nm_limpa_valor($this->bank_balance, $this->field_config['bank_balance']['symbol_dec'], $this->field_config['bank_balance']['symbol_grp']);
      }
      nm_limpa_data($this->creator_date_time, $this->field_config['creator_date_time']['date_sep']) ; 
      nm_limpa_hora($this->creator_date_time_hora, $this->field_config['creator_date_time']['time_sep']) ; 
      nm_limpa_data($this->update_date_time, $this->field_config['update_date_time']['date_sep']) ; 
      nm_limpa_hora($this->update_date_time_hora, $this->field_config['update_date_time']['time_sep']) ; 
   }
   function sc_add_currency(&$value, $symbol, $pos)
   {
       if ('' == $value)
       {
           return;
       }
       $value = (1 == $pos || 3 == $pos) ? $symbol . ' ' . $value : $value . ' ' . $symbol;
   }
   function sc_remove_currency(&$value, $symbol_dec, $symbol_tho, $symbol_mon)
   {
       $value = preg_replace('~&#x0*([0-9a-f]+);~i', '', $value);
       $sNew  = str_replace($symbol_mon, '', $value);
       if ($sNew != $value)
       {
           $value = str_replace(' ', '', $sNew);
           return;
       }
       $aTest = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', $symbol_dec, $symbol_tho);
       $sNew  = '';
       for ($i = 0; $i < strlen($value); $i++)
       {
           if ($this->sc_test_currency_char($value[$i], $aTest))
           {
               $sNew .= $value[$i];
           }
       }
       $value = $sNew;
   }
   function sc_test_currency_char($char, $test)
   {
       $found = false;
       foreach ($test as $test_char)
       {
           if ($char === $test_char)
           {
               $found = true;
           }
       }
       return $found;
   }
   function nm_clear_val($Nome_Campo)
   {
      if ($Nome_Campo == "sn")
      {
          nm_limpa_numero($this->sn, $this->field_config['sn']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "check_number")
      {
          $this->nm_tira_mask($this->check_number, "999999999", "(){}[].,;:-+/ "); 
          nm_limpa_numero($this->check_number, $this->field_config['check_number']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "payment_voucher")
      {
          $this->nm_tira_mask($this->payment_voucher, "999999999", "(){}[].,;:-+/ "); 
          nm_limpa_numero($this->payment_voucher, $this->field_config['payment_voucher']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "receipt_voucher")
      {
          $this->nm_tira_mask($this->receipt_voucher, "999999999", "(){}[].,;:-+/ "); 
          nm_limpa_numero($this->receipt_voucher, $this->field_config['receipt_voucher']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "amount")
      {
          if (!empty($this->field_config['amount']['symbol_dec']))
          {
             nm_limpa_valor($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "depit")
      {
          if (!empty($this->field_config['depit']['symbol_dec']))
          {
             nm_limpa_valor($this->depit, $this->field_config['depit']['symbol_dec'], $this->field_config['depit']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "creditor")
      {
          if (!empty($this->field_config['creditor']['symbol_dec']))
          {
             nm_limpa_valor($this->creditor, $this->field_config['creditor']['symbol_dec'], $this->field_config['creditor']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "bank_balance")
      {
          if (!empty($this->field_config['bank_balance']['symbol_dec']))
          {
             $this->sc_remove_currency($this->bank_balance, $this->field_config['bank_balance']['symbol_dec'], $this->field_config['bank_balance']['symbol_grp'], $this->field_config['bank_balance']['symbol_mon']);
             nm_limpa_valor($this->bank_balance, $this->field_config['bank_balance']['symbol_dec'], $this->field_config['bank_balance']['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->sn) || (!empty($format_fields) && isset($format_fields['sn'])))
      {
          nmgp_Form_Num_Val($this->sn, $this->field_config['sn']['symbol_grp'], $this->field_config['sn']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['sn']['symbol_fmt']) ; 
      }
      if ((!empty($this->transection_date) && 'null' != $this->transection_date) || (!empty($format_fields) && isset($format_fields['transection_date'])))
      {
          nm_volta_data($this->transection_date, $this->field_config['transection_date']['date_format']) ; 
          nmgp_Form_Datas($this->transection_date, $this->field_config['transection_date']['date_format'], $this->field_config['transection_date']['date_sep']) ;  
      }
      elseif ('null' == $this->transection_date || '' == $this->transection_date)
      {
          $this->transection_date = '';
      }
      if (!empty($this->check_number) || (!empty($format_fields) && isset($format_fields['check_number'])))
      {
          $this->nm_gera_mask($this->check_number, "999999999"); 
      }
      if (!empty($this->payment_voucher) || (!empty($format_fields) && isset($format_fields['payment_voucher'])))
      {
          $this->nm_gera_mask($this->payment_voucher, "999999999"); 
      }
      if (!empty($this->receipt_voucher) || (!empty($format_fields) && isset($format_fields['receipt_voucher'])))
      {
          $this->nm_gera_mask($this->receipt_voucher, "999999999"); 
      }
      if (!empty($this->amount) || (!empty($format_fields) && isset($format_fields['amount'])))
      {
          nmgp_Form_Num_Val($this->amount, $this->field_config['amount']['symbol_grp'], $this->field_config['amount']['symbol_dec'], "3", "S", "", "", "", "-", $this->field_config['amount']['symbol_fmt']) ; 
      }
      if (!empty($this->depit) || (!empty($format_fields) && isset($format_fields['depit'])))
      {
          nmgp_Form_Num_Val($this->depit, $this->field_config['depit']['symbol_grp'], $this->field_config['depit']['symbol_dec'], "3", "S", "", "", "", "-", $this->field_config['depit']['symbol_fmt']) ; 
      }
      if (!empty($this->creditor) || (!empty($format_fields) && isset($format_fields['creditor'])))
      {
          nmgp_Form_Num_Val($this->creditor, $this->field_config['creditor']['symbol_grp'], $this->field_config['creditor']['symbol_dec'], "3", "S", "", "", "", "-", $this->field_config['creditor']['symbol_fmt']) ; 
      }
      if (!empty($this->bank_balance) || (!empty($format_fields) && isset($format_fields['bank_balance'])))
      {
          nmgp_Form_Num_Val($this->bank_balance, $this->field_config['bank_balance']['symbol_grp'], $this->field_config['bank_balance']['symbol_dec'], "3", "S", "", "", "", "-", $this->field_config['bank_balance']['symbol_fmt']) ; 
      }
   }
   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)
   {
       if (get_magic_quotes_gpc())
       {
           if (is_array($str))
           {
               $x = 0;
               foreach ($str as $cada_str)
               {
                   $str[$x] = stripslashes($str[$x]);
                   $x++;
               }
           }
           else
           {
               $str = stripslashes($str);
           }
       }
   }
//
//-- 
   function nm_converte_datas($use_null = true, $bForce = false)
   {
      $guarda_format_hora = $this->field_config['transection_date']['date_format'];
      if ($this->transection_date != "")  
      { 
          nm_conv_data($this->transection_date, $this->field_config['transection_date']['date_format']) ; 
          $this->transection_date_hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->transection_date_hora = substr($this->transection_date_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->transection_date_hora = substr($this->transection_date_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->transection_date_hora = substr($this->transection_date_hora, 0, -4);
          }
      } 
      if ($this->transection_date == "" && $use_null)  
      { 
          $this->transection_date = "null" ; 
      } 
      $this->field_config['transection_date']['date_format'] = $guarda_format_hora;
   }
   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";
       }
       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_sn();
          $this->ajax_return_values_approved_on_month();
          $this->ajax_return_values_transection_order();
          $this->ajax_return_values_transection_date();
          $this->ajax_return_values_income_outcome();
          $this->ajax_return_values_income_outcome_type();
          $this->ajax_return_values_details_from_menu();
          $this->ajax_return_values_description();
          $this->ajax_return_values_appartment_shop();
          $this->ajax_return_values_for_month();
          $this->ajax_return_values_for_year();
          $this->ajax_return_values_payment_method();
          $this->ajax_return_values_check_number();
          $this->ajax_return_values_payment_voucher();
          $this->ajax_return_values_receipt_voucher();
          $this->ajax_return_values_amount();
          $this->ajax_return_values_depit();
          $this->ajax_return_values_creditor();
          $this->ajax_return_values_remarks();
          $this->ajax_return_values_bank_balance();
          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']['sn']['keyVal'] = form_accountants_acountants_mob_pack_protect_string($this->nmgp_dados_form['sn']);
          }
   } // ajax_return_values

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

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

$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('يناير') => form_accountants_acountants_mob_pack_protect_string("يناير"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('فبراير') => form_accountants_acountants_mob_pack_protect_string("فبراير"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('مارس') => form_accountants_acountants_mob_pack_protect_string("مارس"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('ابريل') => form_accountants_acountants_mob_pack_protect_string("ابريل"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('مايو') => form_accountants_acountants_mob_pack_protect_string("مايو"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('يونيو') => form_accountants_acountants_mob_pack_protect_string("يونيو"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('يوليو') => form_accountants_acountants_mob_pack_protect_string("يوليو"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('اغسطس') => form_accountants_acountants_mob_pack_protect_string("اغسطس"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('سبتمبر') => form_accountants_acountants_mob_pack_protect_string("سبتمبر"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('اكتوبر') => form_accountants_acountants_mob_pack_protect_string("اكتوبر"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('نوفمبر') => form_accountants_acountants_mob_pack_protect_string("نوفمبر"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('ديسمبر') => form_accountants_acountants_mob_pack_protect_string("ديسمبر"));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'يناير';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'فبراير';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'مارس';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'ابريل';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'مايو';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'يونيو';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'يوليو';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'اغسطس';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'سبتمبر';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'اكتوبر';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'نوفمبر';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_approved_on_month'][] = 'ديسمبر';
          $aLookupOrig = $aLookup;
          $sSelComp = "name=\"approved_on_month\"";
          if (isset($this->NM_ajax_info['select_html']['approved_on_month']) && !empty($this->NM_ajax_info['select_html']['approved_on_month']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['approved_on_month'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->approved_on_month == $sValue)
                  {
                      $this->_tmp_lookup_approved_on_month = $sLabel;
                  }

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

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

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

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

$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('ايرادات') => form_accountants_acountants_mob_pack_protect_string("ايرادات"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('مصروفات') => form_accountants_acountants_mob_pack_protect_string("مصروفات"));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome'][] = 'ايرادات';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome'][] = 'مصروفات';
          $aLookupOrig = $aLookup;
          $sSelComp = "name=\"income_outcome\"";
          if (isset($this->NM_ajax_info['select_html']['income_outcome']) && !empty($this->NM_ajax_info['select_html']['income_outcome']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['income_outcome'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->income_outcome == $sValue)
                  {
                      $this->_tmp_lookup_income_outcome = $sLabel;
                  }

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

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

 
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'] = 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_sn = $this->sn;
   $old_value_transection_date = $this->transection_date;
   $old_value_check_number = $this->check_number;
   $old_value_payment_voucher = $this->payment_voucher;
   $old_value_receipt_voucher = $this->receipt_voucher;
   $old_value_amount = $this->amount;
   $old_value_depit = $this->depit;
   $old_value_creditor = $this->creditor;
   $old_value_bank_balance = $this->bank_balance;
   $this->nm_tira_formatacao();
   $this->nm_converte_datas(false);


   $unformatted_value_sn = $this->sn;
   $unformatted_value_transection_date = $this->transection_date;
   $unformatted_value_check_number = $this->check_number;
   $unformatted_value_payment_voucher = $this->payment_voucher;
   $unformatted_value_receipt_voucher = $this->receipt_voucher;
   $unformatted_value_amount = $this->amount;
   $unformatted_value_depit = $this->depit;
   $unformatted_value_creditor = $this->creditor;
   $unformatted_value_bank_balance = $this->bank_balance;

   $nm_comando = "SELECT income_outcome_type FROM accountants_income_outcome WHERE income_outcome = '$this->income_outcome'";

   $this->sn = $old_value_sn;
   $this->transection_date = $old_value_transection_date;
   $this->check_number = $old_value_check_number;
   $this->payment_voucher = $old_value_payment_voucher;
   $this->receipt_voucher = $old_value_receipt_voucher;
   $this->amount = $old_value_amount;
   $this->depit = $old_value_depit;
   $this->creditor = $old_value_creditor;
   $this->bank_balance = $old_value_bank_balance;

   $_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_accountants_acountants_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[0])) => form_accountants_acountants_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[0])));
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'][] = $rs->fields[0];
              $nmgp_def_dados .= $rs->fields[0] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $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=\"income_outcome_type\"";
          if (isset($this->NM_ajax_info['select_html']['income_outcome_type']) && !empty($this->NM_ajax_info['select_html']['income_outcome_type']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['income_outcome_type'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->income_outcome_type == $sValue)
                  {
                      $this->_tmp_lookup_income_outcome_type = $sLabel;
                  }

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

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

 
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'] = 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_sn = $this->sn;
   $old_value_transection_date = $this->transection_date;
   $old_value_check_number = $this->check_number;
   $old_value_payment_voucher = $this->payment_voucher;
   $old_value_receipt_voucher = $this->receipt_voucher;
   $old_value_amount = $this->amount;
   $old_value_depit = $this->depit;
   $old_value_creditor = $this->creditor;
   $old_value_bank_balance = $this->bank_balance;
   $this->nm_tira_formatacao();
   $this->nm_converte_datas(false);


   $unformatted_value_sn = $this->sn;
   $unformatted_value_transection_date = $this->transection_date;
   $unformatted_value_check_number = $this->check_number;
   $unformatted_value_payment_voucher = $this->payment_voucher;
   $unformatted_value_receipt_voucher = $this->receipt_voucher;
   $unformatted_value_amount = $this->amount;
   $unformatted_value_depit = $this->depit;
   $unformatted_value_creditor = $this->creditor;
   $unformatted_value_bank_balance = $this->bank_balance;

   $nm_comando = "SELECT details_from_menu FROM accountants_income_outcome_type WHERE income_outcome_type = '$this->income_outcome_type'";

   $this->sn = $old_value_sn;
   $this->transection_date = $old_value_transection_date;
   $this->check_number = $old_value_check_number;
   $this->payment_voucher = $old_value_payment_voucher;
   $this->receipt_voucher = $old_value_receipt_voucher;
   $this->amount = $old_value_amount;
   $this->depit = $old_value_depit;
   $this->creditor = $old_value_creditor;
   $this->bank_balance = $old_value_bank_balance;

   $_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_accountants_acountants_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[0])) => form_accountants_acountants_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[0])));
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'][] = $rs->fields[0];
              $nmgp_def_dados .= $rs->fields[0] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $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=\"details_from_menu\"";
          if (isset($this->NM_ajax_info['select_html']['details_from_menu']) && !empty($this->NM_ajax_info['select_html']['details_from_menu']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['details_from_menu'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->details_from_menu == $sValue)
                  {
                      $this->_tmp_lookup_details_from_menu = $sLabel;
                  }

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

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

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

 
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'] = array(); 
}
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('') => form_accountants_acountants_mob_pack_protect_string('الرجاء اختيار الشقة او المحل ان وجد'));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'][] = '';
   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_sn = $this->sn;
   $old_value_transection_date = $this->transection_date;
   $old_value_check_number = $this->check_number;
   $old_value_payment_voucher = $this->payment_voucher;
   $old_value_receipt_voucher = $this->receipt_voucher;
   $old_value_amount = $this->amount;
   $old_value_depit = $this->depit;
   $old_value_creditor = $this->creditor;
   $old_value_bank_balance = $this->bank_balance;
   $this->nm_tira_formatacao();
   $this->nm_converte_datas(false);


   $unformatted_value_sn = $this->sn;
   $unformatted_value_transection_date = $this->transection_date;
   $unformatted_value_check_number = $this->check_number;
   $unformatted_value_payment_voucher = $this->payment_voucher;
   $unformatted_value_receipt_voucher = $this->receipt_voucher;
   $unformatted_value_amount = $this->amount;
   $unformatted_value_depit = $this->depit;
   $unformatted_value_creditor = $this->creditor;
   $unformatted_value_bank_balance = $this->bank_balance;

   $nm_comando = "SELECT appartments_shops_name, appartments_shops_name  FROM accountant_appartments_shops  ORDER BY appartments_shops_name";

   $this->sn = $old_value_sn;
   $this->transection_date = $old_value_transection_date;
   $this->check_number = $old_value_check_number;
   $this->payment_voucher = $old_value_payment_voucher;
   $this->receipt_voucher = $old_value_receipt_voucher;
   $this->amount = $old_value_amount;
   $this->depit = $old_value_depit;
   $this->creditor = $old_value_creditor;
   $this->bank_balance = $old_value_bank_balance;

   $_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_accountants_acountants_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[0])) => form_accountants_acountants_mob_pack_protect_string(NM_charset_to_utf8($rs->fields[1])));
              $nmgp_def_dados .= $rs->fields[1] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'][] = $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=\"appartment_shop\"";
          if (isset($this->NM_ajax_info['select_html']['appartment_shop']) && !empty($this->NM_ajax_info['select_html']['appartment_shop']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['appartment_shop'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->appartment_shop == $sValue)
                  {
                      $this->_tmp_lookup_appartment_shop = $sLabel;
                  }

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

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

$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('يناير') => form_accountants_acountants_mob_pack_protect_string("يناير"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('فبراير') => form_accountants_acountants_mob_pack_protect_string("فبراير"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('مارس') => form_accountants_acountants_mob_pack_protect_string("مارس"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('ابريل') => form_accountants_acountants_mob_pack_protect_string("ابريل"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('مايو') => form_accountants_acountants_mob_pack_protect_string("مايو"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('يونيو') => form_accountants_acountants_mob_pack_protect_string("يونيو"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('يوليو') => form_accountants_acountants_mob_pack_protect_string("يوليو"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('اغسطس') => form_accountants_acountants_mob_pack_protect_string("اغسطس"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('سبتمبر') => form_accountants_acountants_mob_pack_protect_string("سبتمبر"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('اكتوبر') => form_accountants_acountants_mob_pack_protect_string("اكتوبر"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('نوفمبر') => form_accountants_acountants_mob_pack_protect_string("نوفمبر"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('ديسمبر') => form_accountants_acountants_mob_pack_protect_string("ديسمبر"));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'يناير';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'فبراير';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'مارس';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'ابريل';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'مايو';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'يونيو';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'يوليو';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'اغسطس';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'سبتمبر';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'اكتوبر';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'نوفمبر';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_month'][] = 'ديسمبر';
          $aLookupOrig = $aLookup;
          $sSelComp = "name=\"for_month\"";
          if (isset($this->NM_ajax_info['select_html']['for_month']) && !empty($this->NM_ajax_info['select_html']['for_month']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['for_month'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->for_month == $sValue)
                  {
                      $this->_tmp_lookup_for_month = $sLabel;
                  }

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

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

$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('2017') => form_accountants_acountants_mob_pack_protect_string("2017"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('2016') => form_accountants_acountants_mob_pack_protect_string("2016"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('2018') => form_accountants_acountants_mob_pack_protect_string("2018"));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_year'][] = '2017';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_year'][] = '2016';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_for_year'][] = '2018';
          $aLookupOrig = $aLookup;
          $sSelComp = "name=\"for_year\"";
          if (isset($this->NM_ajax_info['select_html']['for_year']) && !empty($this->NM_ajax_info['select_html']['for_year']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['for_year'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->for_year == $sValue)
                  {
                      $this->_tmp_lookup_for_year = $sLabel;
                  }

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

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

$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('شيك') => form_accountants_acountants_mob_pack_protect_string("شيك"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('نقدا') => form_accountants_acountants_mob_pack_protect_string("نقدا"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('تحويلات بنكية') => form_accountants_acountants_mob_pack_protect_string("تحويلات بنكية"));
$aLookup[] = array(form_accountants_acountants_mob_pack_protect_string('ايداع بنكي') => form_accountants_acountants_mob_pack_protect_string("ايداع بنكي"));
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_payment_method'][] = 'شيك';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_payment_method'][] = 'نقدا';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_payment_method'][] = 'تحويلات بنكية';
$_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_payment_method'][] = 'ايداع بنكي';
          $aLookupOrig = $aLookup;
          $sSelComp = "name=\"payment_method\"";
          if (isset($this->NM_ajax_info['select_html']['payment_method']) && !empty($this->NM_ajax_info['select_html']['payment_method']))
          {
              $sSelComp = $this->NM_ajax_info['select_html']['payment_method'];
          }
          $sLookup = '';
          if (empty($aLookup))
          {
              $aLookup[] = array('' => '');
          }
          foreach ($aLookup as $aOption)
          {
              foreach ($aOption as $sValue => $sLabel)
              {

                  if ($this->payment_method == $sValue)
                  {
                      $this->_tmp_lookup_payment_method = $sLabel;
                  }

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

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

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

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

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

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

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

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

          //----- bank_balance
   function ajax_return_values_bank_balance($bForce = false)
   {
          if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("bank_balance", $this->nmgp_refresh_fields)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->bank_balance);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['bank_balance'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($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_accountants_acountants_mob']['upload_dir'][$fieldName]))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['upload_dir'][$fieldName] = array();
            $resDir = @opendir($uploadDir);
            if (!$resDir)
            {
                return $originalName;
            }
            while (false !== ($fileName = @readdir($resDir)))
            {
                if (@is_file($uploadDir . $fileName))
                {
                    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['upload_dir'][$fieldName][] = $fileName;
                }
            }
            @closedir($resDir);
        }
        if (!in_array($originalName, $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['upload_dir'][$fieldName]))
        {
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['upload_dir'][$fieldName][] = $originalName;
            return $originalName;
        }
        else
        {
            $newName = $this->fetchFileNextName($originalName, $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['upload_dir'][$fieldName]);
            $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['upload_dir'][$fieldName][] = $newName;
            return $newName;
        }
    } // fetchUniqueUploadName

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

   function ajax_add_parameters()
   {
   } // ajax_add_parameters
  function nm_proc_onload($bFormat = true)
  {
      $this->nm_guardar_campos();
      if ($bFormat) $this->nm_formatar_campos();
  }
//
//----------------------------------------------------
//-----> 
//----------------------------------------------------
//
   function nm_troca_decimal($sc_parm1, $sc_parm2) 
   { 
      $this->amount = str_replace($sc_parm1, $sc_parm2, $this->amount); 
      $this->depit = str_replace($sc_parm1, $sc_parm2, $this->depit); 
      $this->creditor = str_replace($sc_parm1, $sc_parm2, $this->creditor); 
      $this->bank_balance = str_replace($sc_parm1, $sc_parm2, $this->bank_balance); 
   } 
   function nm_poe_aspas_decimal() 
   { 
      $this->amount = "'" . $this->amount . "'";
      $this->depit = "'" . $this->depit . "'";
      $this->creditor = "'" . $this->creditor . "'";
      $this->bank_balance = "'" . $this->bank_balance . "'";
   } 
   function nm_tira_aspas_decimal() 
   { 
      $this->amount = str_replace("'", "", $this->amount); 
      $this->depit = str_replace("'", "", $this->depit); 
      $this->creditor = str_replace("'", "", $this->creditor); 
      $this->bank_balance = str_replace("'", "", $this->bank_balance); 
   } 
//----------- 


   function temRegistros($sWhere)
   {
       if ('' == $sWhere)
       {
           return false;
       }
       $nmgp_sel_count = 'SELECT COUNT(*) 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 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();
      $SC_tem_cmp_update = true; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $salva_opcao = $this->nmgp_opcao; 
      if ($this->sc_evento != "novo" && $this->sc_evento != "incluir") 
      { 
          $this->sc_evento = ""; 
      } 
      if (!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->Db->BeginTrans(); 
          $this->Ini->sc_tem_trans_banco = true; 
      } 
      if ('incluir' == $this->nmgp_opcao) { $this->creator_name = $_SERVER['REMOTE_ADDR']; } 
      if ('incluir' == $this->nmgp_opcao) { $this->update_name = $_SERVER['REMOTE_ADDR']; } 
      if ('alterar' == $this->nmgp_opcao || 'igual' == $this->nmgp_opcao) { $this->update_name = $_SERVER['REMOTE_ADDR']; } 
      $NM_val_form['sn'] = $this->sn;
      $NM_val_form['approved_on_month'] = $this->approved_on_month;
      $NM_val_form['transection_order'] = $this->transection_order;
      $NM_val_form['transection_date'] = $this->transection_date;
      $NM_val_form['income_outcome'] = $this->income_outcome;
      $NM_val_form['income_outcome_type'] = $this->income_outcome_type;
      $NM_val_form['details_from_menu'] = $this->details_from_menu;
      $NM_val_form['description'] = $this->description;
      $NM_val_form['appartment_shop'] = $this->appartment_shop;
      $NM_val_form['for_month'] = $this->for_month;
      $NM_val_form['for_year'] = $this->for_year;
      $NM_val_form['payment_method'] = $this->payment_method;
      $NM_val_form['check_number'] = $this->check_number;
      $NM_val_form['payment_voucher'] = $this->payment_voucher;
      $NM_val_form['receipt_voucher'] = $this->receipt_voucher;
      $NM_val_form['amount'] = $this->amount;
      $NM_val_form['depit'] = $this->depit;
      $NM_val_form['creditor'] = $this->creditor;
      $NM_val_form['remarks'] = $this->remarks;
      $NM_val_form['bank_balance'] = $this->bank_balance;
      $NM_val_form['creator_name'] = $this->creator_name;
      $NM_val_form['creator_date_time'] = $this->creator_date_time;
      $NM_val_form['update_name'] = $this->update_name;
      $NM_val_form['update_date_time'] = $this->update_date_time;
      if ($this->sn == "")  
      { 
          $this->sn = 0;
      } 
      if ($this->for_year == "")  
      { 
          $this->for_year = 0;
          $this->sc_force_zero[] = 'for_year';
      } 
      if ($this->check_number == "")  
      { 
          $this->check_number = 0;
          $this->sc_force_zero[] = 'check_number';
      } 
      if ($this->payment_voucher == "")  
      { 
          $this->payment_voucher = 0;
          $this->sc_force_zero[] = 'payment_voucher';
      } 
      if ($this->receipt_voucher == "")  
      { 
          $this->receipt_voucher = 0;
          $this->sc_force_zero[] = 'receipt_voucher';
      } 
      if ($this->amount == "")  
      { 
          $this->amount = 0;
          $this->sc_force_zero[] = 'amount';
      } 
      if ($this->depit == "")  
      { 
          $this->depit = 0;
          $this->sc_force_zero[] = 'depit';
      } 
      if ($this->creditor == "")  
      { 
          $this->creditor = 0;
          $this->sc_force_zero[] = 'creditor';
      } 
      if ($this->bank_balance == "")  
      { 
          $this->bank_balance = 0;
          $this->sc_force_zero[] = 'bank_balance';
      } 
      $nm_bases_lob_geral = array_merge($this->Ini->nm_bases_ibase, $this->Ini->nm_bases_mysql);
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['decimal_db'] == ",") 
      {
          $this->nm_troca_decimal(".", ",");
      }
      if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir") 
      {
          $this->transection_order_before_qstr = $this->transection_order;
          $this->transection_order = substr($this->Db->qstr($this->transection_order), 1, -1); 
          if ($this->transection_order == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->transection_order = "null"; 
              $NM_val_null[] = "transection_order";
          } 
          $this->approved_on_month_before_qstr = $this->approved_on_month;
          $this->approved_on_month = substr($this->Db->qstr($this->approved_on_month), 1, -1); 
          if ($this->approved_on_month == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->approved_on_month = "null"; 
              $NM_val_null[] = "approved_on_month";
          } 
          if ($this->transection_date == "")  
          { 
              $this->transection_date = "null"; 
              $NM_val_null[] = "transection_date";
          } 
          $this->income_outcome_before_qstr = $this->income_outcome;
          $this->income_outcome = substr($this->Db->qstr($this->income_outcome), 1, -1); 
          if ($this->income_outcome == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->income_outcome = "null"; 
              $NM_val_null[] = "income_outcome";
          } 
          $this->income_outcome_type_before_qstr = $this->income_outcome_type;
          $this->income_outcome_type = substr($this->Db->qstr($this->income_outcome_type), 1, -1); 
          if ($this->income_outcome_type == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->income_outcome_type = "null"; 
              $NM_val_null[] = "income_outcome_type";
          } 
          $this->details_from_menu_before_qstr = $this->details_from_menu;
          $this->details_from_menu = substr($this->Db->qstr($this->details_from_menu), 1, -1); 
          if ($this->details_from_menu == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->details_from_menu = "null"; 
              $NM_val_null[] = "details_from_menu";
          } 
          $this->description_before_qstr = $this->description;
          $this->description = substr($this->Db->qstr($this->description), 1, -1); 
          if ($this->description == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->description = "null"; 
              $NM_val_null[] = "description";
          } 
          $this->appartment_shop_before_qstr = $this->appartment_shop;
          $this->appartment_shop = substr($this->Db->qstr($this->appartment_shop), 1, -1); 
          if ($this->appartment_shop == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->appartment_shop = "null"; 
              $NM_val_null[] = "appartment_shop";
          } 
          $this->for_month_before_qstr = $this->for_month;
          $this->for_month = substr($this->Db->qstr($this->for_month), 1, -1); 
          if ($this->for_month == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->for_month = "null"; 
              $NM_val_null[] = "for_month";
          } 
          $this->payment_method_before_qstr = $this->payment_method;
          $this->payment_method = substr($this->Db->qstr($this->payment_method), 1, -1); 
          if ($this->payment_method == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->payment_method = "null"; 
              $NM_val_null[] = "payment_method";
          } 
          $this->remarks_before_qstr = $this->remarks;
          $this->remarks = substr($this->Db->qstr($this->remarks), 1, -1); 
          if ($this->remarks == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->remarks = "null"; 
              $NM_val_null[] = "remarks";
          } 
          $this->creator_name_before_qstr = $this->creator_name;
          $this->creator_name = substr($this->Db->qstr($this->creator_name), 1, -1); 
          if ($this->creator_name == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->creator_name = "null"; 
              $NM_val_null[] = "creator_name";
          } 
          if ($this->creator_date_time == "")  
          { 
              $this->creator_date_time = "null"; 
              $NM_val_null[] = "creator_date_time";
          } 
          $this->update_name_before_qstr = $this->update_name;
          $this->update_name = substr($this->Db->qstr($this->update_name), 1, -1); 
          if ($this->update_name == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->update_name = "null"; 
              $NM_val_null[] = "update_name";
          } 
          if ($this->update_date_time == "")  
          { 
              $this->update_date_time = "null"; 
              $NM_val_null[] = "update_date_time";
          } 
      }
      if ($this->nmgp_opcao == "alterar") 
      {
          $SC_ex_update = true; 
          $SC_ex_upd_or = true; 
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['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_accountants_acountants_mob']['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(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn "); 
          }  
          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_accountants_acountants_mob_pack_ajax_response();
              }
              exit; 
          }  
          $bUpdateOk = true;
          $tmp_result = (int) $rs1->fields[0]; 
          if ($tmp_result != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_nfnd']); 
              $this->nmgp_opcao = "nada"; 
              $bUpdateOk = false;
              $this->sc_evento = 'update';
          } 
          $aUpdateOk = array();
          $bUpdateOk = $bUpdateOk && empty($aUpdateOk);
          if ($bUpdateOk)
          { 
              $rs1->Close(); 
              $this->update_date_time =  date('Y') . "-" . date('m')  . "-" . date('d') . " " . date('H') . ":" . date('i') . ":" . date('s');
              $this->update_date_time_hora =  date('Y') . "-" . date('m')  . "-" . date('d') . " " . date('H') . ":" . date('i') . ":" . date('s');
              $NM_val_form['update_date_time'] = $this->update_date_time;
              $this->NM_ajax_changed['update_date_time'] = true;
              $comando_oracle = "";  
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET Transection_Order = '$this->transection_order', approved_on_month = '$this->approved_on_month', transection_date = #$this->transection_date#, income_outcome = '$this->income_outcome', income_outcome_type = '$this->income_outcome_type', details_from_menu = '$this->details_from_menu', description = '$this->description', appartment_shop = '$this->appartment_shop', for_month = '$this->for_month', for_year = $this->for_year, payment_method = '$this->payment_method', check_number = $this->check_number, payment_voucher = $this->payment_voucher, receipt_voucher = $this->receipt_voucher, amount = $this->amount, depit = $this->depit, creditor = $this->creditor, remarks = '$this->remarks', bank_balance = $this->bank_balance";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET Transection_Order = '$this->transection_order', approved_on_month = '$this->approved_on_month', transection_date = " . $this->Ini->date_delim . $this->transection_date . $this->Ini->date_delim1 . ", income_outcome = '$this->income_outcome', income_outcome_type = '$this->income_outcome_type', details_from_menu = '$this->details_from_menu', description = '$this->description', appartment_shop = '$this->appartment_shop', for_month = '$this->for_month', for_year = $this->for_year, payment_method = '$this->payment_method', check_number = $this->check_number, payment_voucher = $this->payment_voucher, receipt_voucher = $this->receipt_voucher, amount = $this->amount, depit = $this->depit, creditor = $this->creditor, remarks = '$this->remarks', bank_balance = $this->bank_balance";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET Transection_Order = '$this->transection_order', approved_on_month = '$this->approved_on_month', transection_date = " . $this->Ini->date_delim . $this->transection_date . $this->Ini->date_delim1 . ", income_outcome = '$this->income_outcome', income_outcome_type = '$this->income_outcome_type', details_from_menu = '$this->details_from_menu', description = '$this->description', appartment_shop = '$this->appartment_shop', for_month = '$this->for_month', for_year = $this->for_year, payment_method = '$this->payment_method', check_number = $this->check_number, payment_voucher = $this->payment_voucher, receipt_voucher = $this->receipt_voucher, amount = $this->amount, depit = $this->depit, creditor = $this->creditor, remarks = '$this->remarks', bank_balance = $this->bank_balance";  
              } 
              else 
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET Transection_Order = '$this->transection_order', approved_on_month = '$this->approved_on_month', transection_date = " . $this->Ini->date_delim . $this->transection_date . $this->Ini->date_delim1 . ", income_outcome = '$this->income_outcome', income_outcome_type = '$this->income_outcome_type', details_from_menu = '$this->details_from_menu', description = '$this->description', appartment_shop = '$this->appartment_shop', for_month = '$this->for_month', for_year = $this->for_year, payment_method = '$this->payment_method', check_number = $this->check_number, payment_voucher = $this->payment_voucher, receipt_voucher = $this->receipt_voucher, amount = $this->amount, depit = $this->depit, creditor = $this->creditor, remarks = '$this->remarks', bank_balance = $this->bank_balance";  
              } 
              if (isset($NM_val_form['creator_name']) && $NM_val_form['creator_name'] != $this->nmgp_dados_select['creator_name']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " creator_name = '$this->creator_name'"; 
                  $comando_oracle        .= " creator_name = '$this->creator_name'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['creator_date_time']) && $NM_val_form['creator_date_time'] != $this->nmgp_dados_select['creator_date_time']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $comando        .= " creator_date_time = #$this->creator_date_time#"; 
                  } 
                  else 
                  { 
                      $comando        .= " creator_date_time = " . $this->Ini->date_delim . $this->creator_date_time . $this->Ini->date_delim1 . ""; 
                  } 
                  $comando_oracle        .= " creator_date_time = " . $this->Ini->date_delim . $this->creator_date_time . $this->Ini->date_delim1 . ""; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['update_name']) && $NM_val_form['update_name'] != $this->nmgp_dados_select['update_name']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " update_name = '$this->update_name'"; 
                  $comando_oracle        .= " update_name = '$this->update_name'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['update_date_time']) && $NM_val_form['update_date_time'] != $this->nmgp_dados_select['update_date_time']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
                  { 
                      $comando        .= " update_date_time = #$this->update_date_time#"; 
                  } 
                  else 
                  { 
                      $comando        .= " update_date_time = " . $this->Ini->date_delim . $this->update_date_time . $this->Ini->date_delim1 . ""; 
                  } 
                  $comando_oracle        .= " update_date_time = " . $this->Ini->date_delim . $this->update_date_time . $this->Ini->date_delim1 . ""; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              $aDoNotUpdate = array();
              if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
              { 
                  $comando = $comando_oracle;  
                  $SC_ex_update = $SC_ex_upd_or;
              }   
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $comando .= " WHERE sn = $this->sn ";  
              }  
              else  
              {
                  $comando .= " WHERE sn = $this->sn ";  
              }  
              $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 ($SC_ex_update || $SC_tem_cmp_update)
              { 
                  $_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"))
                      {
                          $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_updt'], $this->Db->ErrorMsg(), true); 
                          if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler']) 
                          { 
                              $this->sc_erro_update = $this->Db->ErrorMsg();  
                              $this->NM_rollback_db(); 
                              if ($this->NM_ajax_flag)
                              {
                                  form_accountants_acountants_mob_pack_ajax_response();
                              }
                              exit;  
                          }   
                      }   
                  }   
              }   
              if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
              { 
              }   
          $this->transection_order = $this->transection_order_before_qstr;
          $this->approved_on_month = $this->approved_on_month_before_qstr;
          $this->income_outcome = $this->income_outcome_before_qstr;
          $this->income_outcome_type = $this->income_outcome_type_before_qstr;
          $this->details_from_menu = $this->details_from_menu_before_qstr;
          $this->description = $this->description_before_qstr;
          $this->appartment_shop = $this->appartment_shop_before_qstr;
          $this->for_month = $this->for_month_before_qstr;
          $this->payment_method = $this->payment_method_before_qstr;
          $this->remarks = $this->remarks_before_qstr;
          $this->creator_name = $this->creator_name_before_qstr;
          $this->update_name = $this->update_name_before_qstr;
              $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_accountants_acountants_mob']['db_changed'] = true;


              if     (isset($NM_val_form) && isset($NM_val_form['sn'])) { $this->sn = $NM_val_form['sn']; }
              elseif (isset($this->sn)) { $this->nm_limpa_alfa($this->sn); }
              if     (isset($NM_val_form) && isset($NM_val_form['transection_order'])) { $this->transection_order = $NM_val_form['transection_order']; }
              elseif (isset($this->transection_order)) { $this->nm_limpa_alfa($this->transection_order); }
              if     (isset($NM_val_form) && isset($NM_val_form['approved_on_month'])) { $this->approved_on_month = $NM_val_form['approved_on_month']; }
              elseif (isset($this->approved_on_month)) { $this->nm_limpa_alfa($this->approved_on_month); }
              if     (isset($NM_val_form) && isset($NM_val_form['income_outcome'])) { $this->income_outcome = $NM_val_form['income_outcome']; }
              elseif (isset($this->income_outcome)) { $this->nm_limpa_alfa($this->income_outcome); }
              if     (isset($NM_val_form) && isset($NM_val_form['income_outcome_type'])) { $this->income_outcome_type = $NM_val_form['income_outcome_type']; }
              elseif (isset($this->income_outcome_type)) { $this->nm_limpa_alfa($this->income_outcome_type); }
              if     (isset($NM_val_form) && isset($NM_val_form['details_from_menu'])) { $this->details_from_menu = $NM_val_form['details_from_menu']; }
              elseif (isset($this->details_from_menu)) { $this->nm_limpa_alfa($this->details_from_menu); }
              if     (isset($NM_val_form) && isset($NM_val_form['description'])) { $this->description = $NM_val_form['description']; }
              elseif (isset($this->description)) { $this->nm_limpa_alfa($this->description); }
              if     (isset($NM_val_form) && isset($NM_val_form['appartment_shop'])) { $this->appartment_shop = $NM_val_form['appartment_shop']; }
              elseif (isset($this->appartment_shop)) { $this->nm_limpa_alfa($this->appartment_shop); }
              if     (isset($NM_val_form) && isset($NM_val_form['for_month'])) { $this->for_month = $NM_val_form['for_month']; }
              elseif (isset($this->for_month)) { $this->nm_limpa_alfa($this->for_month); }
              if     (isset($NM_val_form) && isset($NM_val_form['for_year'])) { $this->for_year = $NM_val_form['for_year']; }
              elseif (isset($this->for_year)) { $this->nm_limpa_alfa($this->for_year); }
              if     (isset($NM_val_form) && isset($NM_val_form['payment_method'])) { $this->payment_method = $NM_val_form['payment_method']; }
              elseif (isset($this->payment_method)) { $this->nm_limpa_alfa($this->payment_method); }
              if     (isset($NM_val_form) && isset($NM_val_form['check_number'])) { $this->check_number = $NM_val_form['check_number']; }
              elseif (isset($this->check_number)) { $this->nm_limpa_alfa($this->check_number); }
              if     (isset($NM_val_form) && isset($NM_val_form['payment_voucher'])) { $this->payment_voucher = $NM_val_form['payment_voucher']; }
              elseif (isset($this->payment_voucher)) { $this->nm_limpa_alfa($this->payment_voucher); }
              if     (isset($NM_val_form) && isset($NM_val_form['receipt_voucher'])) { $this->receipt_voucher = $NM_val_form['receipt_voucher']; }
              elseif (isset($this->receipt_voucher)) { $this->nm_limpa_alfa($this->receipt_voucher); }
              if     (isset($NM_val_form) && isset($NM_val_form['amount'])) { $this->amount = $NM_val_form['amount']; }
              elseif (isset($this->amount)) { $this->nm_limpa_alfa($this->amount); }
              if     (isset($NM_val_form) && isset($NM_val_form['depit'])) { $this->depit = $NM_val_form['depit']; }
              elseif (isset($this->depit)) { $this->nm_limpa_alfa($this->depit); }
              if     (isset($NM_val_form) && isset($NM_val_form['creditor'])) { $this->creditor = $NM_val_form['creditor']; }
              elseif (isset($this->creditor)) { $this->nm_limpa_alfa($this->creditor); }
              if     (isset($NM_val_form) && isset($NM_val_form['bank_balance'])) { $this->bank_balance = $NM_val_form['bank_balance']; }
              elseif (isset($this->bank_balance)) { $this->nm_limpa_alfa($this->bank_balance); }

              $this->nm_formatar_campos();

              $aOldRefresh               = $this->nmgp_refresh_fields;
              $this->nmgp_refresh_fields = array_diff(array('sn', 'approved_on_month', 'transection_order', 'transection_date', 'income_outcome', 'income_outcome_type', 'details_from_menu', 'description', 'appartment_shop', 'for_month', 'for_year', 'payment_method', 'check_number', 'payment_voucher', 'receipt_voucher', 'amount', 'depit', 'creditor', 'remarks', 'bank_balance'), $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_accountants_acountants_mob']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['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_accountants_acountants_mob']['decimal_db'] == ",") 
          {
              $this->nm_poe_aspas_decimal();
          }
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sqlite))
          { 
              $NM_seq_auto = "NULL, ";
              $NM_cmp_auto = "sn, ";
          } 
              $this->creator_date_time =  date('Y') . "-" . date('m')  . "-" . date('d') . " " . date('H') . ":" . date('i') . ":" . date('s');
              $this->creator_date_time_hora =  date('Y') . "-" . date('m')  . "-" . date('d') . " " . date('H') . ":" . date('i') . ":" . date('s');
              $this->update_date_time =  date('Y') . "-" . date('m')  . "-" . date('d') . " " . date('H') . ":" . date('i') . ":" . date('s');
              $this->update_date_time_hora =  date('Y') . "-" . date('m')  . "-" . date('d') . " " . date('H') . ":" . date('i') . ":" . date('s');
          $bInsertOk = true;
          $aInsertOk = array(); 
          $bInsertOk = $bInsertOk && empty($aInsertOk);
          if (!isset($_POST['nmgp_ins_valid']) || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['insert_validation'] != $_POST['nmgp_ins_valid'])
          {
              $bInsertOk = false;
              $this->Erro->mensagem(__FILE__, __LINE__, 'security', $this->Ini->Nm_lang['lang_errm_inst_vald']);
              if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler'])
              {
                  $this->nmgp_opcao = 'refresh_insert';
                  if ($this->NM_ajax_flag)
                  {
                      form_accountants_acountants_mob_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 . " (Transection_Order, approved_on_month, transection_date, income_outcome, income_outcome_type, details_from_menu, description, appartment_shop, for_month, for_year, payment_method, check_number, payment_voucher, receipt_voucher, amount, depit, creditor, remarks, bank_balance, creator_name, creator_date_time, update_name, update_date_time) VALUES ('$this->transection_order', '$this->approved_on_month', #$this->transection_date#, '$this->income_outcome', '$this->income_outcome_type', '$this->details_from_menu', '$this->description', '$this->appartment_shop', '$this->for_month', $this->for_year, '$this->payment_method', $this->check_number, $this->payment_voucher, $this->receipt_voucher, $this->amount, $this->depit, $this->creditor, '$this->remarks', $this->bank_balance, '$this->creator_name', #$this->creator_date_time#, '$this->update_name', #$this->update_date_time#)"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "Transection_Order, approved_on_month, transection_date, income_outcome, income_outcome_type, details_from_menu, description, appartment_shop, for_month, for_year, payment_method, check_number, payment_voucher, receipt_voucher, amount, depit, creditor, remarks, bank_balance, creator_name, creator_date_time, update_name, update_date_time) VALUES (" . $NM_seq_auto . "'$this->transection_order', '$this->approved_on_month', " . $this->Ini->date_delim . $this->transection_date . $this->Ini->date_delim1 . ", '$this->income_outcome', '$this->income_outcome_type', '$this->details_from_menu', '$this->description', '$this->appartment_shop', '$this->for_month', $this->for_year, '$this->payment_method', $this->check_number, $this->payment_voucher, $this->receipt_voucher, $this->amount, $this->depit, $this->creditor, '$this->remarks', $this->bank_balance, '$this->creator_name', " . $this->Ini->date_delim . $this->creator_date_time . $this->Ini->date_delim1 . ", '$this->update_name', " . $this->Ini->date_delim . $this->update_date_time . $this->Ini->date_delim1 . ")"; 
              }
              else
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "Transection_Order, approved_on_month, transection_date, income_outcome, income_outcome_type, details_from_menu, description, appartment_shop, for_month, for_year, payment_method, check_number, payment_voucher, receipt_voucher, amount, depit, creditor, remarks, bank_balance, creator_name, creator_date_time, update_name, update_date_time) VALUES (" . $NM_seq_auto . "'$this->transection_order', '$this->approved_on_month', " . $this->Ini->date_delim . $this->transection_date . $this->Ini->date_delim1 . ", '$this->income_outcome', '$this->income_outcome_type', '$this->details_from_menu', '$this->description', '$this->appartment_shop', '$this->for_month', $this->for_year, '$this->payment_method', $this->check_number, $this->payment_voucher, $this->receipt_voucher, $this->amount, $this->depit, $this->creditor, '$this->remarks', $this->bank_balance, '$this->creator_name', " . $this->Ini->date_delim . $this->creator_date_time . $this->Ini->date_delim1 . ", '$this->update_name', " . $this->Ini->date_delim . $this->update_date_time . $this->Ini->date_delim1 . ")"; 
              }
              $comando = str_replace("N'null'", "null", $comando) ; 
              $comando = str_replace("'null'", "null", $comando) ; 
              $comando = str_replace("#null#", "null", $comando) ; 
              $comando = str_replace($this->Ini->date_delim . "null" . $this->Ini->date_delim1, "null", $comando) ; 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $comando; 
              $rs = $this->Db->Execute($comando); 
              if ($rs === false)  
              { 
                  if (FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "MAIL SENT") && FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "WARNING"))
                  {
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_inst'], $this->Db->ErrorMsg(), true); 
                      if (isset($_SESSION['scriptcase']['erro_handler']) && $_SESSION['scriptcase']['erro_handler']) 
                      { 
                          $this->sc_erro_insert = $this->Db->ErrorMsg();  
                          $this->nmgp_opcao     = 'refresh_insert';
                          $this->NM_rollback_db(); 
                          if ($this->NM_ajax_flag)
                          {
                              form_accountants_acountants_mob_pack_ajax_response();
                              exit; 
                          }
                      }  
                  }  
              }  
              if ('refresh_insert' != $this->nmgp_opcao)
              {
              if (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_accountants_acountants_mob_pack_ajax_response();
                      }
                      exit; 
                  } 
                  $this->sn =  $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->sn = $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('')"; 
                  $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->sn = $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(, 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->sn = $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->sn = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              }

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

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

              $this->sc_evento = "insert"; 
              $this->sc_insert_on = 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_accountants_acountants_mob']['sc_redir_insert']) || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['sc_redir_insert'] != "S"))
              {
              $this->nmgp_opcao = "novo"; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "R")
              { 
                   $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['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_accountants_acountants_mob']['decimal_db'] == ",") 
      {
          $this->nm_tira_aspas_decimal();
      }
      if ($this->nmgp_opcao == "excluir") 
      { 
          $this->sn = substr($this->Db->qstr($this->sn), 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(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where sn = $this->sn "); 
          }  
          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; 
          }  
          $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 sn = $this->sn "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where sn = $this->sn "); 
              }  
              else  
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where sn = $this->sn "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where sn = $this->sn "); 
              }  
              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_accountants_acountants_mob_pack_ajax_response();
                          exit; 
                      }
                  } 
              } 
              $this->sc_evento = "delete"; 
              $this->nmgp_opcao = "avanca"; 
              $this->nm_flag_iframe = true;
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']--; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] < 0)
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = 0; 
              }

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

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

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

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

      }  
      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 ("insert" == $this->sc_evento && $this->nmgp_opcao != "nada") {
        if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['decimal_db'] == ",")
        {
            $this->nm_troca_decimal(",", ".");
        }
        $_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_amount = $this->amount;
    $original_appartment_shop = $this->appartment_shop;
    $original_approved_on_month = $this->approved_on_month;
    $original_check_number = $this->check_number;
    $original_description = $this->description;
    $original_details_from_menu = $this->details_from_menu;
    $original_for_month = $this->for_month;
    $original_for_year = $this->for_year;
    $original_income_outcome = $this->income_outcome;
    $original_income_outcome_type = $this->income_outcome_type;
    $original_payment_method = $this->payment_method;
    $original_receipt_voucher = $this->receipt_voucher;
    $original_transection_date = $this->transection_date;
}
                           

if ($this->payment_method =="شيك" or $this->payment_method =="تحويلات بنكية")

	{

$insert_table  = 'accountant_check_transfare';      
$insert_fields = array(   
 	'details' => "'$this->description'",

	'check_no' => "'$this->check_number'",

	 'check_date' => "'$this->transection_date'",

     'amount' => "'$this->amount'",

	'payment_method' => "'$this->payment_method'",

	 'finalaize' => "'لا'",

 );



$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_accountants_acountants_mob_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      ;

	

	}











$appli_email = 'aljufili@hotmail.com';

if ($this->income_outcome  == "مصروفات" ){

$acc_income_outcome = $this->income_outcome ;

$acc_approved_month = $this->approved_on_month ;

$acc_income_outcome_type = $this->income_outcome_type ;

$acc_details_from_menu = $this->details_from_menu ;

$acc_description = $this->description ;

$acc_appartment_shop = $this->appartment_shop ;

$acc_for_month = $this->for_month ;

$acc_for_year = $this->for_year ;

$acc_payment_method = $this->payment_method ;

$acc_check_number = $this->check_number ;

$acc_amount = $this->amount ;

}else{

$acc_income_outcome= $this->income_outcome ;

$acc_approved_month = $this->approved_on_month ;

$acc_income_outcome_type = $this->income_outcome_type ;

$acc_details_from_menu = $this->details_from_menu ;

$acc_description = $this->description ;

$acc_appartment_shop = $this->appartment_shop ;

$acc_for_month = $this->for_month ;

$acc_for_year = $this->for_year ;

$acc_payment_method = $this->payment_method ;

$acc_check_number = $this->receipt_voucher ;

$acc_amount = $this->amount ;

}	



$appli_massege =  ' تم تسجيل طلب جديد في قاعدة بيانات النادي وفق التفاصيل ادناه :     ' . '<br>' 

	. 'outcome Or Income: ' . $acc_income_outcome .'<br>'

	. 'Approved On Month: ' . $acc_approved_month . '<br>'

	. $acc_income_outcome_type . '<br>'

	. $acc_details_from_menu . '<br>'

	. $acc_description . '<br>'

	. $acc_appartment_shop . '<br>'

	. $acc_for_month . '<br>' 

	. $acc_for_year . '<br>' 

	. $acc_payment_method . '<br>'

	. $acc_check_number . '<br>'

	. $acc_amount;

$appli_Subject = "تسجيل بيانات في قاعدة بيانات نادي الاتفاق";



$mail_smtp_server    = 'mail.theprivatschools.com';        
$mail_smtp_user      = 'admin@theprivatschools.com';                   
$mail_smtp_pass      = 'Asmaamer@2010';                
$mail_from           = 'admin@theprivatschools.com';          
$mail_to             = $appli_email;         
$mail_subject        = $appli_Subject;            
$mail_message        = $appli_massege; 
$mail_format         = 'H';                       
$mail_copies         = '';                        
$mail_tp_copies      = '';                        
$mail_port           = '26';                     
$mail_tp_connection  = 'N';                       


    include_once($this->Ini->path_third . "/swift/swift_required.php");
    $sc_mail_port     = "$mail_port";
    $sc_mail_tp_port  = "$mail_tp_connection";
    $sc_mail_tp_mens  = "$mail_format";
    $sc_mail_tp_copy  = "$mail_tp_copies";
    $this->sc_mail_count = 0;
    $this->sc_mail_erro  = "";
    $this->sc_mail_ok    = true;
    if ($sc_mail_tp_port == "S" || $sc_mail_tp_port == "Y")
    {
        $sc_mail_port = (!empty($sc_mail_port)) ? $sc_mail_port : 465;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port, 'ssl');
    }
    elseif ($sc_mail_tp_port == "T")
    {
        $sc_mail_port = !empty($sc_mail_port) ? $sc_mail_port : 587;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port, 'tls');
    }
    else
    {
        $sc_mail_port = (!empty($sc_mail_port)) ? $sc_mail_port : 25;
        $Con_Mail = Swift_SmtpTransport::newInstance($mail_smtp_server, $sc_mail_port);
    }
    $Con_Mail->setUsername($mail_smtp_user);
    $Con_Mail->setpassword($mail_smtp_pass);
    $Send_Mail = Swift_Mailer::newInstance($Con_Mail);
    if ($sc_mail_tp_mens == "H")
    {
        $Mens_Mail = Swift_Message::newInstance($mail_subject);
        $Mens_Mail->setBody(SC_Mail_Image($mail_message, $Mens_Mail))->setContentType("text/html");
    }
    else
    {
        $Mens_Mail = Swift_Message::newInstance($mail_subject)->setBody($mail_message);
    }
    if (!empty($_SESSION['scriptcase']['charset']))
    {
        $Mens_Mail->setCharset($_SESSION['scriptcase']['charset']);
    }
    $Temp_mail = $mail_to;
    if (!is_array($Temp_mail))
    {
        $Temp_mail = explode(";", $mail_to);
    }
    foreach ($Temp_mail as $NM_dest)
    {
        if (!empty($NM_dest))
        {
            $Arr_addr = SC_Mail_Address($NM_dest);
            $Mens_Mail->addTo($Arr_addr[0], $Arr_addr[1]);
        }
    }
    $Temp_mail = $mail_copies;
    if (!is_array($Temp_mail))
    {
        $Temp_mail = explode(";", $mail_copies);
    }
    foreach ($Temp_mail as $NM_dest)
    {
        if (!empty($NM_dest))
        {
            $Arr_addr = SC_Mail_Address($NM_dest);
            if (strtoupper(substr($sc_mail_tp_copy, 0, 2)) == "CC")
            {
                $Mens_Mail->addCc($Arr_addr[0], $Arr_addr[1]);
            }
            else
            {
                $Mens_Mail->addBcc($Arr_addr[0], $Arr_addr[1]);
            }
        }
    }
    $Arr_addr = SC_Mail_Address($mail_from);
    $this->sc_mail_count = $Send_Mail->send($Mens_Mail->setFrom($Arr_addr[0], $Arr_addr[1]), $Err_mail);
    if (!empty($Err_mail))
    {
        $this->sc_mail_erro = $Err_mail;
        $this->sc_mail_ok   = false;
    }
;
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_amount != $this->amount || (isset($bFlagRead_amount) && $bFlagRead_amount)))
    {
        $this->ajax_return_values_amount(true);
    }
    if (($original_appartment_shop != $this->appartment_shop || (isset($bFlagRead_appartment_shop) && $bFlagRead_appartment_shop)))
    {
        $this->ajax_return_values_appartment_shop(true);
    }
    if (($original_approved_on_month != $this->approved_on_month || (isset($bFlagRead_approved_on_month) && $bFlagRead_approved_on_month)))
    {
        $this->ajax_return_values_approved_on_month(true);
    }
    if (($original_check_number != $this->check_number || (isset($bFlagRead_check_number) && $bFlagRead_check_number)))
    {
        $this->ajax_return_values_check_number(true);
    }
    if (($original_description != $this->description || (isset($bFlagRead_description) && $bFlagRead_description)))
    {
        $this->ajax_return_values_description(true);
    }
    if (($original_details_from_menu != $this->details_from_menu || (isset($bFlagRead_details_from_menu) && $bFlagRead_details_from_menu)))
    {
        $this->ajax_return_values_details_from_menu(true);
    }
    if (($original_for_month != $this->for_month || (isset($bFlagRead_for_month) && $bFlagRead_for_month)))
    {
        $this->ajax_return_values_for_month(true);
    }
    if (($original_for_year != $this->for_year || (isset($bFlagRead_for_year) && $bFlagRead_for_year)))
    {
        $this->ajax_return_values_for_year(true);
    }
    if (($original_income_outcome != $this->income_outcome || (isset($bFlagRead_income_outcome) && $bFlagRead_income_outcome)))
    {
        $this->ajax_return_values_income_outcome(true);
    }
    if (($original_income_outcome_type != $this->income_outcome_type || (isset($bFlagRead_income_outcome_type) && $bFlagRead_income_outcome_type)))
    {
        $this->ajax_return_values_income_outcome_type(true);
    }
    if (($original_payment_method != $this->payment_method || (isset($bFlagRead_payment_method) && $bFlagRead_payment_method)))
    {
        $this->ajax_return_values_payment_method(true);
    }
    if (($original_receipt_voucher != $this->receipt_voucher || (isset($bFlagRead_receipt_voucher) && $bFlagRead_receipt_voucher)))
    {
        $this->ajax_return_values_receipt_voucher(true);
    }
    if (($original_transection_date != $this->transection_date || (isset($bFlagRead_transection_date) && $bFlagRead_transection_date)))
    {
        $this->ajax_return_values_transection_date(true);
    }
}
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off'; 
    }
    if ("update" == $this->sc_evento && $this->nmgp_opcao != "nada") {
        $_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_amount = $this->amount;
    $original_appartment_shop = $this->appartment_shop;
    $original_approved_on_month = $this->approved_on_month;
    $original_check_number = $this->check_number;
    $original_description = $this->description;
    $original_details_from_menu = $this->details_from_menu;
    $original_for_month = $this->for_month;
    $original_for_year = $this->for_year;
    $original_income_outcome = $this->income_outcome;
    $original_income_outcome_type = $this->income_outcome_type;
    $original_payment_method = $this->payment_method;
}
                           $username = 'aljufaili';

$password = 'Asmaamer@2010';

$msisdn = '96895724466';



$acc_income_outcome = $this->income_outcome ;

$acc_approved_month = $this->approved_on_month ;

$acc_income_outcome_type = $this->income_outcome_type ;

$acc_details_from_menu = $this->details_from_menu ;

$acc_description = $this->description ;

$acc_appartment_shop = $this->appartment_shop ;

$acc_for_month = $this->for_month ;

$acc_for_year = $this->for_year ;

$acc_payment_method = $this->payment_method ;

$acc_check_number = $this->check_number ;

$acc_amount = $this->amount ;

$appli_massege = ' تم تحديث طلب في قاعدة بيانات النادي وفق التفاصيل ادناه : '  . $this->income_outcome   . ' ' .  $this->approved_on_month ;









$url = 'https://bulksms.vsms.net/eapi/submission/send_sms/2/2.0';

$seven_bit_msg = "Test message from non unicode 7 bit";

$unicode_msg =  $appli_massege;

$eight_bit_msg = $appli_massege;



$transient_errors = array(

40 => 1 # Temporarily unavailable

);











$post_body =$this->unicode_sms( $username, $password, $unicode_msg, $msisdn );

$result =$this->send_message( $post_body, $url );

if( $result['success'] ) {

 $this->print_ln($this->formatted_server_response( $result ) );

}

else {

 $this->print_ln($this->formatted_server_response( $result ) );

}





$post_body =$this->eight_bit_sms( $username, $password, $eight_bit_msg, $msisdn );

$result =$this->send_message( $post_body, $url );

if( $result['success'] ) {

 $this->print_ln($this->formatted_server_response( $result ) );

}

else {

 $this->print_ln($this->formatted_server_response( $result ) );

}







$this->print_ln("Script ran to completion");



































/*

* Unique ID to eliminate duplicates in case of network timeouts - see

* EAPI documentation for more. You may want to use a database primary

* key. Warning: sending two different messages with the same

* ID will result in the second being ignored!

*

* Don't use a timestamp - for instance, your application may be able

* to generate multiple messages with the same ID within a second, or

* part thereof.

*

* You can't simply use an incrementing counter, if there's a chance that

* the counter will be reset.

*/













if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_amount != $this->amount || (isset($bFlagRead_amount) && $bFlagRead_amount)))
    {
        $this->ajax_return_values_amount(true);
    }
    if (($original_appartment_shop != $this->appartment_shop || (isset($bFlagRead_appartment_shop) && $bFlagRead_appartment_shop)))
    {
        $this->ajax_return_values_appartment_shop(true);
    }
    if (($original_approved_on_month != $this->approved_on_month || (isset($bFlagRead_approved_on_month) && $bFlagRead_approved_on_month)))
    {
        $this->ajax_return_values_approved_on_month(true);
    }
    if (($original_check_number != $this->check_number || (isset($bFlagRead_check_number) && $bFlagRead_check_number)))
    {
        $this->ajax_return_values_check_number(true);
    }
    if (($original_description != $this->description || (isset($bFlagRead_description) && $bFlagRead_description)))
    {
        $this->ajax_return_values_description(true);
    }
    if (($original_details_from_menu != $this->details_from_menu || (isset($bFlagRead_details_from_menu) && $bFlagRead_details_from_menu)))
    {
        $this->ajax_return_values_details_from_menu(true);
    }
    if (($original_for_month != $this->for_month || (isset($bFlagRead_for_month) && $bFlagRead_for_month)))
    {
        $this->ajax_return_values_for_month(true);
    }
    if (($original_for_year != $this->for_year || (isset($bFlagRead_for_year) && $bFlagRead_for_year)))
    {
        $this->ajax_return_values_for_year(true);
    }
    if (($original_income_outcome != $this->income_outcome || (isset($bFlagRead_income_outcome) && $bFlagRead_income_outcome)))
    {
        $this->ajax_return_values_income_outcome(true);
    }
    if (($original_income_outcome_type != $this->income_outcome_type || (isset($bFlagRead_income_outcome_type) && $bFlagRead_income_outcome_type)))
    {
        $this->ajax_return_values_income_outcome_type(true);
    }
    if (($original_payment_method != $this->payment_method || (isset($bFlagRead_payment_method) && $bFlagRead_payment_method)))
    {
        $this->ajax_return_values_payment_method(true);
    }
}
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off'; 
    }
      if (!empty($this->Campos_Mens_erro)) 
      {
          $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro); 
          $this->Campos_Mens_erro = ""; 
          $this->nmgp_opc_ant = $salva_opcao ; 
          if ($salva_opcao == "incluir") 
          { 
              $GLOBALS["erro_incl"] = 1; 
          }
          if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "excluir") 
          {
              $this->nmgp_opcao = "nada"; 
          } 
          $this->sc_evento = ""; 
          $this->NM_rollback_db(); 
          return; 
      }
   if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['decimal_db'] == ",")
   {
       $this->nm_troca_decimal(".", ",");
   }
      if ($salva_opcao == "incluir" && $GLOBALS["erro_incl"] != 1) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['parms'] = "sn?#?$this->sn?@?"; 
      }
      $this->NM_commit_db(); 
      if ($this->sc_evento != "insert" && $this->sc_evento != "update" && $this->sc_evento != "delete")
      { 
          $this->sn = substr($this->Db->qstr($this->sn), 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_accountants_acountants_mob']['where_filter'] = trim($this->NM_where_filter);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total']))
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total']);
          }
      }
      $sc_where_filter = '';
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter_form'])
      {
          $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter_form'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter'])
      {
          if (empty($sc_where_filter))
          {
              $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter'];
          }
          else
          {
              $sc_where_filter .= " and (" . $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter'] . ")";
          }
      }
//------------ 
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "R")
      {
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['iframe_evento'] == "insert") 
          { 
               $this->nmgp_opcao = "novo"; 
               $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['select'] = "";
          } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['iframe_evento'] = $this->sc_evento; 
      } 
      if (!isset($this->nmgp_opcao) || empty($this->nmgp_opcao)) 
      { 
          if (empty($this->sn)) 
          { 
              $this->nmgp_opcao = "inicio"; 
          } 
          else 
          { 
              $this->nmgp_opcao = "igual"; 
          } 
      } 
      if (isset($_POST['master_nav']) && 'on' == $_POST['master_nav']) 
      { 
          $this->nmgp_opcao = "inicio";
      } 
      if ($this->nmgp_opcao != "nada" && (trim($this->sn) == "")) 
      { 
          if ($this->nmgp_opcao == "avanca")  
          { 
              $this->nmgp_opcao = "final"; 
          } 
          elseif ($this->nmgp_opcao != "novo")
          { 
              $this->nmgp_opcao = "inicio"; 
          } 
      } 
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
      { 
          $GLOBALS["NM_ERRO_IBASE"] = 1;  
      } 
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F" && $this->sc_evento == "insert")
      {
          $this->nmgp_opcao = "final";
      }
      $sc_where = trim("");
      if (substr(strtolower($sc_where), 0, 5) == "where")
      {
          $sc_where  = substr($sc_where , 5);
      }
      if (!empty($sc_where))
      {
          $sc_where = " where " . $sc_where . " ";
      }
      if ('' != $sc_where_filter)
      {
          $sc_where = ('' != $sc_where) ? $sc_where . ' and (' . $sc_where_filter . ')' : ' where ' . $sc_where_filter;
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total']))
      { 
          $nmgp_select = "SELECT count(*) 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_accountants_acountants_mob = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total'] = $qt_geral_reg_form_accountants_acountants_mob;
          $rt->Close(); 
          if ($this->nmgp_opcao == "igual" && isset($this->NM_btn_navega) && 'S' == $this->NM_btn_navega && !empty($this->sn))
          {
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $Key_Where = "sn < $this->sn "; 
              }  
              else  
              {
                  $Key_Where = "sn < $this->sn "; 
              }
              $Where_Start = (empty($sc_where)) ? " where " . $Key_Where :  $sc_where . " and (" . $Key_Where . ")";
              $nmgp_select = "SELECT count(*) from " . $this->Ini->nm_tabela . $Where_Start; 
              $_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 ; 
              }  
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = $rt->fields[0];
              $rt->Close(); 
          }
      } 
      else 
      { 
          $qt_geral_reg_form_accountants_acountants_mob = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total'];
      } 
      if ($this->nmgp_opcao == "inicio") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = 0; 
      } 
      if ($this->nmgp_opcao == "avanca")  
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']++; 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] > $qt_geral_reg_form_accountants_acountants_mob)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = $qt_geral_reg_form_accountants_acountants_mob; 
          }
      } 
      if ($this->nmgp_opcao == "retorna") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']--; 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] < 0)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = 0; 
          }
      } 
      if ($this->nmgp_opcao == "final") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = $qt_geral_reg_form_accountants_acountants_mob; 
      } 
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']) || empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']))
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] = 0;
      }
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] + 1;
      $this->NM_ajax_info['navSummary']['reg_ini'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] + 1; 
      $this->NM_ajax_info['navSummary']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_qtd']; 
      $this->NM_ajax_info['navSummary']['reg_tot'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total'] + 1; 
      $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_accountants_acountants_mob']['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 sn, Transection_Order, approved_on_month, str_replace (convert(char(10),transection_date,102), '.', '-') + ' ' + convert(char(8),transection_date,20), income_outcome, income_outcome_type, details_from_menu, description, appartment_shop, for_month, for_year, payment_method, check_number, payment_voucher, receipt_voucher, amount, depit, creditor, remarks, bank_balance, creator_name, str_replace (convert(char(10),creator_date_time,102), '.', '-') + ' ' + convert(char(8),creator_date_time,20), update_name, str_replace (convert(char(10),update_date_time,102), '.', '-') + ' ' + convert(char(8),update_date_time,20) from " . $this->Ini->nm_tabela ; 
          } 
          else 
          { 
              $nmgp_select = "SELECT sn, Transection_Order, approved_on_month, transection_date, income_outcome, income_outcome_type, details_from_menu, description, appartment_shop, for_month, for_year, payment_method, check_number, payment_voucher, receipt_voucher, amount, depit, creditor, remarks, bank_balance, creator_name, creator_date_time, update_name, update_date_time from " . $this->Ini->nm_tabela ; 
          } 
          $aWhere = array();
          $aWhere[] = $sc_where_filter;
          if ($this->nmgp_opcao == "igual" || (($_SESSION['sc_session'][$this->Ini->sc_page]['form_adm_clientes']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_adm_clientes']['run_iframe'] == "R") && ($this->sc_evento == "insert" || $this->sc_evento == "update")) )
          { 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $aWhere[] = "sn = $this->sn"; 
              }  
              else  
              {
                  $aWhere[] = "sn = $this->sn"; 
              }  
              if (!empty($sc_where_filter))  
              {
                  $teste_select = $nmgp_select . $this->returnWhere($aWhere);
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = $teste_select; 
                  $rs = $this->Db->Execute($teste_select); 
                  if ($rs->EOF)
                  {
                     $aWhere = array($sc_where_filter);
                  }  
                  $rs->Close(); 
              }  
          } 
          $nmgp_select .= $this->returnWhere($aWhere) . ' ';
          $sc_order_by = "";
          $sc_order_by = "sn";
          $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_accountants_acountants_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "R")
          {
              if ($this->sc_evento == "update")
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['select'] = $nmgp_select;
                  $this->nm_gera_html();
              } 
              elseif (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['select']))
              { 
                  $nmgp_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['select'];
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['select'] = ""; 
              } 
          } 
          if ($this->nmgp_opcao == "igual") 
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
              $rs = $this->Db->Execute($nmgp_select) ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']) ; 
          } 
          else  
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
              $rs = $this->Db->Execute($nmgp_select) ; 
              if (!$rs === false && !$rs->EOF) 
              { 
                  $rs->Move($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start']) ;  
              } 
          } 
          if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
              exit ; 
          }  
          if ($rs === false && $GLOBALS["NM_ERRO_IBASE"] == 1) 
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_nfnd_extr'], $this->Db->ErrorMsg()); 
              exit ; 
          }  
          if ($rs->EOF) 
          { 
              if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter']))
              {
                  $this->nmgp_form_empty        = true;
                  $this->NM_ajax_info['buttonDisplay']['first']   = $this->nmgp_botoes['first']   = "off";
                  $this->NM_ajax_info['buttonDisplay']['back']    = $this->nmgp_botoes['back']    = "off";
                  $this->NM_ajax_info['buttonDisplay']['forward'] = $this->nmgp_botoes['forward'] = "off";
                  $this->NM_ajax_info['buttonDisplay']['last']    = $this->nmgp_botoes['last']    = "off";
                  $this->NM_ajax_info['buttonDisplay']['update']  = $this->nmgp_botoes['update']  = "off";
                  $this->NM_ajax_info['buttonDisplay']['delete']  = $this->nmgp_botoes['delete']  = "off";
                  $this->NM_ajax_info['buttonDisplay']['first']   = $this->nmgp_botoes['insert']  = "off";
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter'] = true;
                  return; 
              }
              if ($this->nmgp_botoes['insert'] != "on")
              {
                  $this->nmgp_form_empty        = true;
                  $this->NM_ajax_info['buttonDisplay']['first']   = $this->nmgp_botoes['first']   = "off";
                  $this->NM_ajax_info['buttonDisplay']['back']    = $this->nmgp_botoes['back']    = "off";
                  $this->NM_ajax_info['buttonDisplay']['forward'] = $this->nmgp_botoes['forward'] = "off";
                  $this->NM_ajax_info['buttonDisplay']['last']    = $this->nmgp_botoes['last']    = "off";
              }
              $this->nmgp_opcao = "novo"; 
              $this->nm_flag_saida_novo = "S"; 
              $rs->Close(); 
              if ($this->aba_iframe)
              {
                  $this->NM_ajax_info['buttonDisplay']['exit'] = $this->nmgp_botoes['exit'] = 'off';
              }
          } 
          if ($rs === false && $GLOBALS["NM_ERRO_IBASE"] == 1) 
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_nfnd_extr']); 
              $this->nmgp_opcao = "novo"; 
          }  
          if ($this->nmgp_opcao != "novo") 
          { 
              $this->sn = $rs->fields[0] ; 
              $this->nmgp_dados_select['sn'] = $this->sn;
              $this->transection_order = $rs->fields[1] ; 
              $this->nmgp_dados_select['transection_order'] = $this->transection_order;
              $this->approved_on_month = $rs->fields[2] ; 
              $this->nmgp_dados_select['approved_on_month'] = $this->approved_on_month;
              $this->transection_date = $rs->fields[3] ; 
              $this->nmgp_dados_select['transection_date'] = $this->transection_date;
              $this->income_outcome = $rs->fields[4] ; 
              $this->nmgp_dados_select['income_outcome'] = $this->income_outcome;
              $this->income_outcome_type = $rs->fields[5] ; 
              $this->nmgp_dados_select['income_outcome_type'] = $this->income_outcome_type;
              $this->details_from_menu = $rs->fields[6] ; 
              $this->nmgp_dados_select['details_from_menu'] = $this->details_from_menu;
              $this->description = $rs->fields[7] ; 
              $this->nmgp_dados_select['description'] = $this->description;
              $this->appartment_shop = $rs->fields[8] ; 
              $this->nmgp_dados_select['appartment_shop'] = $this->appartment_shop;
              $this->for_month = $rs->fields[9] ; 
              $this->nmgp_dados_select['for_month'] = $this->for_month;
              $this->for_year = $rs->fields[10] ; 
              $this->nmgp_dados_select['for_year'] = $this->for_year;
              $this->payment_method = $rs->fields[11] ; 
              $this->nmgp_dados_select['payment_method'] = $this->payment_method;
              $this->check_number = $rs->fields[12] ; 
              $this->nmgp_dados_select['check_number'] = $this->check_number;
              $this->payment_voucher = $rs->fields[13] ; 
              $this->nmgp_dados_select['payment_voucher'] = $this->payment_voucher;
              $this->receipt_voucher = $rs->fields[14] ; 
              $this->nmgp_dados_select['receipt_voucher'] = $this->receipt_voucher;
              $this->amount = $rs->fields[15] ; 
              $this->nmgp_dados_select['amount'] = $this->amount;
              $this->depit = $rs->fields[16] ; 
              $this->nmgp_dados_select['depit'] = $this->depit;
              $this->creditor = $rs->fields[17] ; 
              $this->nmgp_dados_select['creditor'] = $this->creditor;
              $this->remarks = $rs->fields[18] ; 
              $this->nmgp_dados_select['remarks'] = $this->remarks;
              $this->bank_balance = $rs->fields[19] ; 
              $this->nmgp_dados_select['bank_balance'] = $this->bank_balance;
              $this->creator_name = $rs->fields[20] ; 
              $this->nmgp_dados_select['creator_name'] = $this->creator_name;
              $this->creator_date_time = $rs->fields[21] ; 
              if (substr($this->creator_date_time, 10, 1) == "-") 
              { 
                 $this->creator_date_time = substr($this->creator_date_time, 0, 10) . " " . substr($this->creator_date_time, 11);
              } 
              if (substr($this->creator_date_time, 13, 1) == ".") 
              { 
                 $this->creator_date_time = substr($this->creator_date_time, 0, 13) . ":" . substr($this->creator_date_time, 14, 2) . ":" . substr($this->creator_date_time, 17);
              } 
              $this->nmgp_dados_select['creator_date_time'] = $this->creator_date_time;
              $this->update_name = $rs->fields[22] ; 
              $this->nmgp_dados_select['update_name'] = $this->update_name;
              $this->update_date_time = $rs->fields[23] ; 
              if (substr($this->update_date_time, 10, 1) == "-") 
              { 
                 $this->update_date_time = substr($this->update_date_time, 0, 10) . " " . substr($this->update_date_time, 11);
              } 
              if (substr($this->update_date_time, 13, 1) == ".") 
              { 
                 $this->update_date_time = substr($this->update_date_time, 0, 13) . ":" . substr($this->update_date_time, 14, 2) . ":" . substr($this->update_date_time, 17);
              } 
              $this->nmgp_dados_select['update_date_time'] = $this->update_date_time;
          $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->nm_troca_decimal(",", ".");
              $this->sn = (string)$this->sn; 
              $this->for_year = (string)$this->for_year; 
              $this->check_number = (string)$this->check_number; 
              $this->payment_voucher = (string)$this->payment_voucher; 
              $this->receipt_voucher = (string)$this->receipt_voucher; 
              $this->amount = (string)$this->amount; 
              $this->depit = (string)$this->depit; 
              $this->creditor = (string)$this->creditor; 
              $this->bank_balance = (string)$this->bank_balance; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['parms'] = "sn?#?$this->sn?@?";
          } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select'] = $this->nmgp_dados_select;
          if (!$this->NM_ajax_flag || 'backup_line' != $this->NM_ajax_opcao)
          {
              $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'];
              $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['reg_start'] < $qt_geral_reg_form_accountants_acountants_mob;
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opcao']   = '';
          }
      } 
      if ($this->nmgp_opcao == "novo" || $this->nmgp_opcao == "refresh_insert") 
      { 
          $this->sc_evento_old = $this->sc_evento;
          $this->sc_evento = "novo";
          if ('refresh_insert' == $this->nmgp_opcao)
          {
              $this->nmgp_opcao = 'novo';
          }
          else
          {
              $this->nm_formatar_campos();
              $this->nm_mens_form_ins = "تم اضافة السند إلى قاعدة البيانات بنجاح";
              $this->sn = "";  
              $this->transection_order = "";  
              $this->approved_on_month = "";  
              $this->transection_date = "";  
              $this->transection_date_hora = "" ;  
              $this->income_outcome = "";  
              $this->income_outcome_type = "";  
              $this->details_from_menu = "";  
              $this->description = "";  
              $this->appartment_shop = "";  
              $this->for_month = "";  
              $this->for_year = "";  
              $this->payment_method = "";  
              $this->check_number = "";  
              $this->payment_voucher = "";  
              $this->receipt_voucher = "";  
              $this->amount = "";  
              $this->depit = "";  
              $this->creditor = "";  
              $this->remarks = "";  
              $this->bank_balance = "";  
              $this->creator_name = "";  
              $this->creator_date_time = "";  
              $this->creator_date_time_hora = "" ;  
              $this->update_name = "";  
              $this->update_date_time = "";  
              $this->update_date_time_hora = "" ;  
              $this->formatado = false;
              if ($this->nmgp_clone != "S")
              {
              }
              if ($this->nmgp_clone == "S" && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select']))
              {
                  $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select'];
                  $this->transection_order = $this->nmgp_dados_select['transection_order'];  
                  $this->approved_on_month = $this->nmgp_dados_select['approved_on_month'];  
                  $this->transection_date = $this->nmgp_dados_select['transection_date'];  
                  $this->income_outcome = $this->nmgp_dados_select['income_outcome'];  
                  $this->income_outcome_type = $this->nmgp_dados_select['income_outcome_type'];  
                  $this->details_from_menu = $this->nmgp_dados_select['details_from_menu'];  
                  $this->description = $this->nmgp_dados_select['description'];  
                  $this->appartment_shop = $this->nmgp_dados_select['appartment_shop'];  
                  $this->for_month = $this->nmgp_dados_select['for_month'];  
                  $this->for_year = $this->nmgp_dados_select['for_year'];  
                  $this->payment_method = $this->nmgp_dados_select['payment_method'];  
                  $this->check_number = $this->nmgp_dados_select['check_number'];  
                  $this->payment_voucher = $this->nmgp_dados_select['payment_voucher'];  
                  $this->receipt_voucher = $this->nmgp_dados_select['receipt_voucher'];  
                  $this->amount = $this->nmgp_dados_select['amount'];  
                  $this->depit = $this->nmgp_dados_select['depit'];  
                  $this->creditor = $this->nmgp_dados_select['creditor'];  
                  $this->remarks = $this->nmgp_dados_select['remarks'];  
                  $this->bank_balance = $this->nmgp_dados_select['bank_balance'];  
                  $this->creator_name = $this->nmgp_dados_select['creator_name'];  
                  $this->creator_date_time = $this->nmgp_dados_select['creator_date_time'];  
                  $this->update_name = $this->nmgp_dados_select['update_name'];  
                  $this->update_date_time = $this->nmgp_dados_select['update_date_time'];  
              }
          }
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
      }  
//
//
//-- 
      if ($this->nmgp_opcao != "novo") 
      {
      }
      if (!isset($this->nmgp_refresh_fields)) 
      { 
          $this->nm_proc_onload();
      }
  }
// 
//-- 
   function nm_db_retorna($str_where_param = '') 
   {  
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $str_where_filter = ('' != $str_where_param) ? ' and ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(sn) from " . $this->Ini->nm_tabela . " where sn < $this->sn" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(sn) from " . $this->Ini->nm_tabela . " where sn < $this->sn" . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(sn) from " . $this->Ini->nm_tabela . " where sn < $this->sn" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(sn) from " . $this->Ini->nm_tabela . " where sn < $this->sn" . $str_where_filter); 
     }  
     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 (isset($rs->fields[0]) && $rs->fields[0] != "") 
     { 
         $this->sn = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
         $rs->Close();  
         $this->nmgp_opcao = "igual";  
         return ;  
     } 
     else 
     { 
        $this->nmgp_opcao = "inicio";  
        $rs->Close();  
        return ; 
     } 
   } 
// 
//-- 
   function nm_db_avanca($str_where_param = '') 
   {  
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $str_where_filter = ('' != $str_where_param) ? ' and ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(sn) from " . $this->Ini->nm_tabela . " where sn > $this->sn" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(sn) from " . $this->Ini->nm_tabela . " where sn > $this->sn" . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(sn) from " . $this->Ini->nm_tabela . " where sn > $this->sn" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(sn) from " . $this->Ini->nm_tabela . " where sn > $this->sn" . $str_where_filter); 
     }  
     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 (isset($rs->fields[0]) && $rs->fields[0] != "") 
     { 
         $this->sn = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
         $rs->Close();  
         $this->nmgp_opcao = "igual";  
         return ;  
     } 
     else 
     { 
        $this->nmgp_opcao = "final";  
        $rs->Close();  
        return ; 
     } 
   } 
// 
//-- 
   function nm_db_inicio($str_where_param = '') 
   {   
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela; 
     $rs = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela);
     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->fields[0] == 0) 
     { 
         $this->nmgp_opcao = "novo"; 
         $this->nm_flag_saida_novo = "S"; 
         $rs->Close(); 
         if ($this->aba_iframe)
         {
             $this->nmgp_botoes['exit'] = 'off';
         }
         return;
     }
     $str_where_filter = ('' != $str_where_param) ? ' where ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     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 (!isset($rs->fields[0]) || $rs->EOF) 
     { 
         $this->nm_flag_saida_novo = "S"; 
         $this->nmgp_opcao = "novo";  
         $rs->Close();  
         if ($this->aba_iframe)
         {
             $this->nmgp_botoes['exit'] = 'off';
         }
         return ; 
     } 
     $this->sn = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
     $rs->Close();  
     $this->nmgp_opcao = "igual";  
     return ;  
   } 
// 
//-- 
   function nm_db_final($str_where_param = '') 
   { 
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $str_where_filter = ('' != $str_where_param) ? ' where ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(sn) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     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 (!isset($rs->fields[0]) || $rs->EOF) 
     { 
         $this->nm_flag_saida_novo = "S"; 
         $this->nmgp_opcao = "novo";  
         $rs->Close();  
         if ($this->aba_iframe)
         {
             $this->nmgp_botoes['exit'] = 'off';
         }
         return ; 
     } 
     $this->sn = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
     $rs->Close();  
     $this->nmgp_opcao = "igual";  
     return ;  
   } 
// 
   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']['sn'] =  $this->sn;
   }
// 
   function NM_gera_log_old() 
   {
       if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select']))
       {
           $nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dados_select'];
           $this->SC_log_arr['fields']['Transection_Order']['0'] =  $nmgp_dados_select['transection_order'];
           $this->SC_log_arr['fields']['approved_on_month']['0'] =  $nmgp_dados_select['approved_on_month'];
           $this->SC_log_arr['fields']['transection_date']['0'] =  $nmgp_dados_select['transection_date'];
           $this->SC_log_arr['fields']['income_outcome']['0'] =  $nmgp_dados_select['income_outcome'];
           $this->SC_log_arr['fields']['income_outcome_type']['0'] =  $nmgp_dados_select['income_outcome_type'];
           $this->SC_log_arr['fields']['details_from_menu']['0'] =  $nmgp_dados_select['details_from_menu'];
           $this->SC_log_arr['fields']['description']['0'] =  $nmgp_dados_select['description'];
           $this->SC_log_arr['fields']['appartment_shop']['0'] =  $nmgp_dados_select['appartment_shop'];
           $this->SC_log_arr['fields']['for_month']['0'] =  $nmgp_dados_select['for_month'];
           $this->SC_log_arr['fields']['for_year']['0'] =  $nmgp_dados_select['for_year'];
           $this->SC_log_arr['fields']['payment_method']['0'] =  $nmgp_dados_select['payment_method'];
           $this->SC_log_arr['fields']['check_number']['0'] =  $nmgp_dados_select['check_number'];
           $this->SC_log_arr['fields']['payment_voucher']['0'] =  $nmgp_dados_select['payment_voucher'];
           $this->SC_log_arr['fields']['receipt_voucher']['0'] =  $nmgp_dados_select['receipt_voucher'];
           $this->SC_log_arr['fields']['amount']['0'] =  $nmgp_dados_select['amount'];
           $this->SC_log_arr['fields']['depit']['0'] =  $nmgp_dados_select['depit'];
           $this->SC_log_arr['fields']['creditor']['0'] =  $nmgp_dados_select['creditor'];
           $this->SC_log_arr['fields']['remarks']['0'] =  $nmgp_dados_select['remarks'];
           $this->SC_log_arr['fields']['bank_balance']['0'] =  $nmgp_dados_select['bank_balance'];
           $this->SC_log_arr['fields']['creator_name']['0'] =  $nmgp_dados_select['creator_name'];
           $this->SC_log_arr['fields']['creator_date_time']['0'] =  $nmgp_dados_select['creator_date_time'];
           $this->SC_log_arr['fields']['update_name']['0'] =  $nmgp_dados_select['update_name'];
           $this->SC_log_arr['fields']['update_date_time']['0'] =  $nmgp_dados_select['update_date_time'];
       }
   }
// 
   function NM_gera_log_new() 
   {
       $this->SC_log_arr['fields']['Transection_Order']['1'] =  $this->transection_order;
       $this->SC_log_arr['fields']['approved_on_month']['1'] =  $this->approved_on_month;
       $this->SC_log_arr['fields']['transection_date']['1'] =  $this->transection_date;
       $this->SC_log_arr['fields']['income_outcome']['1'] =  $this->income_outcome;
       $this->SC_log_arr['fields']['income_outcome_type']['1'] =  $this->income_outcome_type;
       $this->SC_log_arr['fields']['details_from_menu']['1'] =  $this->details_from_menu;
       $this->SC_log_arr['fields']['description']['1'] =  $this->description;
       $this->SC_log_arr['fields']['appartment_shop']['1'] =  $this->appartment_shop;
       $this->SC_log_arr['fields']['for_month']['1'] =  $this->for_month;
       $this->SC_log_arr['fields']['for_year']['1'] =  $this->for_year;
       $this->SC_log_arr['fields']['payment_method']['1'] =  $this->payment_method;
       $this->SC_log_arr['fields']['check_number']['1'] =  $this->check_number;
       $this->SC_log_arr['fields']['payment_voucher']['1'] =  $this->payment_voucher;
       $this->SC_log_arr['fields']['receipt_voucher']['1'] =  $this->receipt_voucher;
       $this->SC_log_arr['fields']['amount']['1'] =  $this->amount;
       $this->SC_log_arr['fields']['depit']['1'] =  $this->depit;
       $this->SC_log_arr['fields']['creditor']['1'] =  $this->creditor;
       $this->SC_log_arr['fields']['remarks']['1'] =  $this->remarks;
       $this->SC_log_arr['fields']['bank_balance']['1'] =  $this->bank_balance;
       $this->SC_log_arr['fields']['creator_name']['1'] =  $this->creator_name;
       $this->SC_log_arr['fields']['creator_date_time']['1'] =  $this->creator_date_time;
       $this->SC_log_arr['fields']['update_name']['1'] =  $this->update_name;
       $this->SC_log_arr['fields']['update_date_time']['1'] =  $this->update_date_time;
   }
// 
   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 = "";
       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  = "||";
                   }
               }
           }
       }
       $this->NM_gera_log_insert("Scriptcase", $this->SC_log_evt, $Log_output);
   }
        function initializeRecordState() {
                $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants']['record_state'] = array();
        }

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

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

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

//
function income_outcome_onChange()
{
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           
$original_income_outcome = $this->income_outcome;
$original_income_outcome_type = $this->income_outcome_type;
$original_details_from_menu = $this->details_from_menu;





$check_sql = "SELECT income_outcome, income_outcome_type"

   . " FROM accountants_income_outcome"

   . " WHERE income_outcome = '" . $this->income_outcome  . "'";

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



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

   

   

	$this->income_outcome_type  = $this->rs[0][1];

}

		else     
{

	$this->income_outcome_type  = '';

   $this->details_from_menu  = '';

}


$modificado_income_outcome = $this->income_outcome;
$modificado_income_outcome_type = $this->income_outcome_type;
$modificado_details_from_menu = $this->details_from_menu;
$this->nm_formatar_campos('income_outcome', 'income_outcome_type', 'details_from_menu');
if ($original_income_outcome !== $modificado_income_outcome || isset($this->nmgp_cmp_readonly['income_outcome']) || (isset($bFlagRead_income_outcome) && $bFlagRead_income_outcome))
{
    $this->ajax_return_values_income_outcome(true);
}
if ($original_income_outcome_type !== $modificado_income_outcome_type || isset($this->nmgp_cmp_readonly['income_outcome_type']) || (isset($bFlagRead_income_outcome_type) && $bFlagRead_income_outcome_type))
{
    $this->ajax_return_values_income_outcome_type(true);
}
if ($original_details_from_menu !== $modificado_details_from_menu || isset($this->nmgp_cmp_readonly['details_from_menu']) || (isset($bFlagRead_details_from_menu) && $bFlagRead_details_from_menu))
{
    $this->ajax_return_values_details_from_menu(true);
}
form_accountants_acountants_mob_pack_ajax_response();
exit;
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function income_outcome_type_onChange()
{
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           
$original_income_outcome_type = $this->income_outcome_type;
$original_details_from_menu = $this->details_from_menu;





$check_sql = "SELECT details_from_menu, income_outcome_type"

   . " FROM accountants_income_outcome_type"

   . " WHERE income_outcome_type = '" . $this->income_outcome_type  . "'";

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



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

   

   

	$this->details_from_menu  = $this->rs[0][1];

}

		else     
{

	$this->details_from_menu  = '';

   

}


$modificado_income_outcome_type = $this->income_outcome_type;
$modificado_details_from_menu = $this->details_from_menu;
$this->nm_formatar_campos('income_outcome_type', 'details_from_menu');
if ($original_income_outcome_type !== $modificado_income_outcome_type || isset($this->nmgp_cmp_readonly['income_outcome_type']) || (isset($bFlagRead_income_outcome_type) && $bFlagRead_income_outcome_type))
{
    $this->ajax_return_values_income_outcome_type(true);
}
if ($original_details_from_menu !== $modificado_details_from_menu || isset($this->nmgp_cmp_readonly['details_from_menu']) || (isset($bFlagRead_details_from_menu) && $bFlagRead_details_from_menu))
{
    $this->ajax_return_values_details_from_menu(true);
}
form_accountants_acountants_mob_pack_ajax_response();
exit;
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function print_ln($content) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  if (isset($_SERVER["SERVER_NAME"])) {

    print $content."<br />";

  }

  else {

    print $content."\n";

  }


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function formatted_server_response( $result ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  $this_result = "";



  if ($result['success']) {

    $this_result .= "Success: batch ID " .$result['api_batch_id']. "API message: ".$result['api_message']. "\nFull details " .$result['details'];

  }

  else {

    $this_result .= "Fatal error: HTTP status " .$result['http_status_code']. ", API status " .$result['api_status_code']. " API message " .$result['api_message']. " full details " .$result['details'];



    if ($result['transient_error']) {

      $this_result .=  "This is a transient error - you should retry it in a production environment";

    }

  }

  return $this_result;


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function send_message ( $post_body, $url ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  



  $ch = curl_init( );

  curl_setopt ( $ch, CURLOPT_URL, $url );

  curl_setopt ( $ch, CURLOPT_POST, 1 );

  curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );

  curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_body );

  curl_setopt ( $ch, CURLOPT_TIMEOUT, 20 );

  curl_setopt ( $ch, CURLOPT_CONNECTTIMEOUT, 20 );



  $response_string = curl_exec( $ch );

  $curl_info = curl_getinfo( $ch );



  $sms_result = array();

  $sms_result['success'] = 0;

  $sms_result['details'] = '';

  $sms_result['transient_error'] = 0;

  $sms_result['http_status_code'] = $curl_info['http_code'];

  $sms_result['api_status_code'] = '';

  $sms_result['api_message'] = '';

  $sms_result['api_batch_id'] = '';



  if ( $response_string == FALSE ) {

    $sms_result['details'] .= "cURL error: " . curl_error( $ch ) . "\n";

  } elseif ( $curl_info[ 'http_code' ] != 200 ) {

    $sms_result['transient_error'] = 1;

    $sms_result['details'] .= "Error: non-200 HTTP status code: " . $curl_info[ 'http_code' ] . "\n";

  }

  else {

    $sms_result['details'] .= "Response from server: $response_string\n";

    $api_result = explode( '|', $response_string );

    $status_code = $api_result[0];

    $sms_result['api_status_code'] = $status_code;

    $sms_result['api_message'] = $api_result[1];

    if ( count( $api_result ) != 3 ) {

      $sms_result['details'] .= "Error: could not parse valid return data from server.\n" . count( $api_result );

    } else {

      if ($status_code == '0') {

        $sms_result['success'] = 1;

        $sms_result['api_batch_id'] = $api_result[2];

        $sms_result['details'] .= "Message sent - batch ID $api_result[2]\n";

      }

      else if ($status_code == '1') {

        # Success: scheduled for later sending.

        $sms_result['success'] = 1;

        $sms_result['api_batch_id'] = $api_result[2];

      }

      else {

        $sms_result['details'] .= "Error sending: status code [$api_result[0]] description [$api_result[1]]\n";

      }











    }

  }

  curl_close( $ch );



  return $sms_result;


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function seven_bit_sms ( $username, $password, $message, $msisdn ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  $post_fields = array (

  'username' => $username,

  'password' => $password,

  'message'  =>$this->character_resolve( $message ),

  'msisdn'   => $msisdn,

  'allow_concat_text_sms' => 0, # Change to 1 to enable long messages

  'concat_text_sms_max_parts' => 2

  );



  return$this->make_post_body($post_fields);


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function unicode_sms ( $username, $password, $message, $msisdn ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  $post_fields = array (

  'username' => $username,

  'password' => $password,

  'message'  =>$this->string_to_utf16_hex( $message ),

  'msisdn'   => $msisdn,

  'dca'      => '16bit'

  );



  return$this->make_post_body($post_fields);


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function eight_bit_sms( $username, $password, $message, $msisdn ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  $post_fields = array (

  'username' => $username,

  'password' => $password,

  'message'  => $message,

  'msisdn'   => $msisdn,

  'dca'      => '8bit'

  );



  return$this->make_post_body($post_fields);




$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function make_post_body($post_fields) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  $stop_dup_id =$this->make_stop_dup_id();

  if ($stop_dup_id > 0) {

    $post_fields['stop_dup_id'] =$this->make_stop_dup_id();

  }

  $post_body = '';

  foreach( $post_fields as $key => $value ) {

    $post_body .= urlencode( $key ).'='.urlencode( $value ).'&';

  }

  $post_body = rtrim( $post_body,'&' );



  return $post_body;


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function character_resolve($body) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  $special_chrs = array(

  'Δ'=>'0xD0', 'Φ'=>'0xDE', 'Γ'=>'0xAC', 'Λ'=>'0xC2', 'Ω'=>'0xDB',

  'Π'=>'0xBA', 'Ψ'=>'0xDD', 'Σ'=>'0xCA', 'Θ'=>'0xD4', 'Ξ'=>'0xB1',

  '¡'=>'0xA1', '£'=>'0xA3', '¤'=>'0xA4', '¥'=>'0xA5', '§'=>'0xA7',

  '¿'=>'0xBF', 'Ä'=>'0xC4', 'Å'=>'0xC5', 'Æ'=>'0xC6', 'Ç'=>'0xC7',

  'É'=>'0xC9', 'Ñ'=>'0xD1', 'Ö'=>'0xD6', 'Ø'=>'0xD8', 'Ü'=>'0xDC',

  'ß'=>'0xDF', 'à'=>'0xE0', 'ä'=>'0xE4', 'å'=>'0xE5', 'æ'=>'0xE6',

  'è'=>'0xE8', 'é'=>'0xE9', 'ì'=>'0xEC', 'ñ'=>'0xF1', 'ò'=>'0xF2',

  'ö'=>'0xF6', 'ø'=>'0xF8', 'ù'=>'0xF9', 'ü'=>'0xFC',

  );



  $ret_msg = '';

  if( mb_detect_encoding($body, 'UTF-8') != 'UTF-8' ) {

    $body = utf8_encode($body);

  }

  for ( $i = 0; $i < mb_strlen( $body, 'UTF-8' ); $i++ ) {

    $c = mb_substr( $body, $i, 1, 'UTF-8' );

    if( isset( $special_chrs[ $c ] ) ) {

      $ret_msg .= chr( $special_chrs[ $c ] );

    }

    else {

      $ret_msg .= $c;

    }

  }

  return $ret_msg;


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

  return 0;


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function string_to_utf16_hex( $string ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           

  return bin2hex(mb_convert_encoding($string, "UTF-16", "UTF-8"));


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
function xml_to_wbxml( $msg_body ) {
$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'on';
                           



  $wbxmlfile = 'xml2wbxml_'.md5(uniqid(time())).'.wbxml';

  $xmlfile = 'xml2wbxml_'.md5(uniqid(time())).'.xml';



  $fp = fopen($xmlfile, 'w+');



  fwrite($fp, $msg_body);

  fclose($fp);



  exec(xml2wbxml.' -v 1.2 -o '.$wbxmlfile.' '.$xmlfile.' 2>/dev/null');

  if(!file_exists($wbxmlfile)) {

   $this->print_ln('Fatal error: xml2wbxml conversion failed');

    return false;

  }



  $wbxml = trim(file_get_contents($wbxmlfile));



  unlink($xmlfile);

  unlink($wbxmlfile);

  return $wbxml;


$_SESSION['scriptcase']['form_accountants_acountants_mob']['contr_erro'] = 'off';
}
//
 function nm_gera_html()
 {
    global
           $nm_url_saida, $nmgp_url_saida, $nm_saida_global, $nm_apl_dependente, $glo_subst, $sc_check_excl, $sc_check_incl, $nmgp_num_form, $NM_run_iframe;
     if ($this->Embutida_proc)
     {
         return;
     }
     if ($this->nmgp_form_show == 'off')
     {
         exit;
     }
      if (isset($NM_run_iframe) && $NM_run_iframe == 1)
      {
          $this->nmgp_botoes['exit'] = "off";
      }
     $HTTP_REFERER = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ""; 
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['botoes'] = $this->nmgp_botoes;
     if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")
     {
         $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opc_ant'] = $this->nmgp_opcao;
     }
     else
     {
         $this->nmgp_opcao = $this->nmgp_opc_ant;
     }
     if (!empty($this->Campos_Mens_erro)) 
     {
         $this->Erro->mensagem(__FILE__, __LINE__, "critica", $this->Campos_Mens_erro); 
         $this->Campos_Mens_erro = "";
     }
     if (($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "R") && $this->nm_flag_iframe && empty($this->nm_todas_criticas))
     {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe_ajax']))
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'] = array("edit", "");
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'] .= "&nmgp_opcao=edit";
          }
          if ($this->sc_evento == "insert" && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F")
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe_ajax']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'] = array("edit", "fim");
              }
              else
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'] .= "&rec=fim";
              }
          }
          $this->NM_close_db(); 
          if ($this->sc_evento == "insert")
          {
              $this->nm_gera_mensagem("تم اضافة السند إلى قاعدة البيانات بنجاح", $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'], "parent"); 
          }
          if ($this->sc_evento == "update")
          {
              $this->nm_gera_mensagem("تم تعديل السند بنجاح", $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'], "parent"); 
          }
          if ($this->sc_evento == "delete")
          {
              $this->nm_gera_mensagem("تم حذف السند بنجاح", $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'], "parent"); 
          }
          $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_accountants_acountants_mob']['run_iframe_ajax']))
              {
                  $this->NM_ajax_info['ajaxJavascript'][] = array("parent.ajax_navigate", $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit']);
              }
              else
              {
                  $sJsParent .= 'parent';
                  $this->NM_ajax_info['redir']['metodo'] = 'location';
                  $this->NM_ajax_info['redir']['action'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'];
                  $this->NM_ajax_info['redir']['target'] = $sJsParent;
              }
              form_accountants_acountants_mob_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_accountants_acountants_mob']['run_iframe_ajax']))
    {
        $opc = ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe'] == "F" && $this->sc_evento == "insert") ? "fim" : "";
        echo "parent.ajax_navigate('edit', '" .$opc . "');";
    }
    else
    {
        echo $sJsParent . "parent.location = '" . $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'] . "';";
    }
?>
         </script>
         </body></html>
<?php
         exit;
     }
        $this->initFormPages();
    include_once("form_accountants_acountants_mob_form0.php");
        $this->hideFormPages();
 }

        function initFormPages() {
        } // initFormPages

        function hideFormPages() {
        } // hideFormPages

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

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

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

       return $sFormat;
   } // jqueryCalendarDtFormat

   function jqueryCalendarTimeStart($sFormat)
   {
       $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)
   {
       if ('calendar' == $sModule)
       {
           if (isset($this->arr_buttons['bcalendario']) && isset($this->arr_buttons['bcalendario']['type']) && 'image' == $this->arr_buttons['bcalendario']['type'])
           {
               $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'])
           {
               $sImage = $this->arr_buttons['bcalculadora']['image'];
           }
       }

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


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

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

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

        $sRandom = '';

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

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

        return $sRandom;
    }

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

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

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

     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 .= $date_sep;
         }
         elseif (':' == $char)
         {
             $new_date_format .= $time_sep;
         }
         else
         {
             $new_date_format .= $char;
         }
     }

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

   function Form_lookup_approved_on_month()
   {
       $nmgp_def_dados  = "";
       $nmgp_def_dados .= "يناير?#?يناير?#?N?@?";
       $nmgp_def_dados .= "فبراير?#?فبراير?#?N?@?";
       $nmgp_def_dados .= "مارس?#?مارس?#?N?@?";
       $nmgp_def_dados .= "ابريل?#?ابريل?#?N?@?";
       $nmgp_def_dados .= "مايو?#?مايو?#?N?@?";
       $nmgp_def_dados .= "يونيو?#?يونيو?#?N?@?";
       $nmgp_def_dados .= "يوليو?#?يوليو?#?N?@?";
       $nmgp_def_dados .= "اغسطس?#?اغسطس?#?N?@?";
       $nmgp_def_dados .= "سبتمبر?#?سبتمبر?#?N?@?";
       $nmgp_def_dados .= "اكتوبر?#?اكتوبر?#?N?@?";
       $nmgp_def_dados .= "نوفمبر?#?نوفمبر?#?N?@?";
       $nmgp_def_dados .= "ديسمبر?#?ديسمبر?#?N?@?";
       $todo = explode("?@?", $nmgp_def_dados);
       return $todo;

   }
   function Form_lookup_income_outcome()
   {
       $nmgp_def_dados  = "";
       $nmgp_def_dados .= "ايرادات?#?ايرادات?#?N?@?";
       $nmgp_def_dados .= "مصروفات?#?مصروفات?#?N?@?";
       $todo = explode("?@?", $nmgp_def_dados);
       return $todo;

   }
   function Form_lookup_income_outcome_type()
   {
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'] = 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_accountants_acountants_mob']['Lookup_income_outcome_type']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type']); 
   }
   else
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'] = array(); 
    }

   $old_value_sn = $this->sn;
   $old_value_transection_date = $this->transection_date;
   $old_value_check_number = $this->check_number;
   $old_value_payment_voucher = $this->payment_voucher;
   $old_value_receipt_voucher = $this->receipt_voucher;
   $old_value_amount = $this->amount;
   $old_value_depit = $this->depit;
   $old_value_creditor = $this->creditor;
   $old_value_bank_balance = $this->bank_balance;
   $this->nm_tira_formatacao();
   $this->nm_converte_datas(false);


   $unformatted_value_sn = $this->sn;
   $unformatted_value_transection_date = $this->transection_date;
   $unformatted_value_check_number = $this->check_number;
   $unformatted_value_payment_voucher = $this->payment_voucher;
   $unformatted_value_receipt_voucher = $this->receipt_voucher;
   $unformatted_value_amount = $this->amount;
   $unformatted_value_depit = $this->depit;
   $unformatted_value_creditor = $this->creditor;
   $unformatted_value_bank_balance = $this->bank_balance;

   $nm_comando = "SELECT income_outcome_type FROM accountants_income_outcome WHERE income_outcome = '$this->income_outcome'";

   $this->sn = $old_value_sn;
   $this->transection_date = $old_value_transection_date;
   $this->check_number = $old_value_check_number;
   $this->payment_voucher = $old_value_payment_voucher;
   $this->receipt_voucher = $old_value_receipt_voucher;
   $this->amount = $old_value_amount;
   $this->depit = $old_value_depit;
   $this->creditor = $old_value_creditor;
   $this->bank_balance = $old_value_bank_balance;

   $_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) 
       { 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_income_outcome_type'][] = $rs->fields[0];
              $nmgp_def_dados .= $rs->fields[0] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $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_details_from_menu()
   {
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'] = 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_accountants_acountants_mob']['Lookup_details_from_menu']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu']); 
   }
   else
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'] = array(); 
    }

   $old_value_sn = $this->sn;
   $old_value_transection_date = $this->transection_date;
   $old_value_check_number = $this->check_number;
   $old_value_payment_voucher = $this->payment_voucher;
   $old_value_receipt_voucher = $this->receipt_voucher;
   $old_value_amount = $this->amount;
   $old_value_depit = $this->depit;
   $old_value_creditor = $this->creditor;
   $old_value_bank_balance = $this->bank_balance;
   $this->nm_tira_formatacao();
   $this->nm_converte_datas(false);


   $unformatted_value_sn = $this->sn;
   $unformatted_value_transection_date = $this->transection_date;
   $unformatted_value_check_number = $this->check_number;
   $unformatted_value_payment_voucher = $this->payment_voucher;
   $unformatted_value_receipt_voucher = $this->receipt_voucher;
   $unformatted_value_amount = $this->amount;
   $unformatted_value_depit = $this->depit;
   $unformatted_value_creditor = $this->creditor;
   $unformatted_value_bank_balance = $this->bank_balance;

   $nm_comando = "SELECT details_from_menu FROM accountants_income_outcome_type WHERE income_outcome_type = '$this->income_outcome_type'";

   $this->sn = $old_value_sn;
   $this->transection_date = $old_value_transection_date;
   $this->check_number = $old_value_check_number;
   $this->payment_voucher = $old_value_payment_voucher;
   $this->receipt_voucher = $old_value_receipt_voucher;
   $this->amount = $old_value_amount;
   $this->depit = $old_value_depit;
   $this->creditor = $old_value_creditor;
   $this->bank_balance = $old_value_bank_balance;

   $_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) 
       { 
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_details_from_menu'][] = $rs->fields[0];
              $nmgp_def_dados .= $rs->fields[0] . "?#?" ; 
              $nmgp_def_dados .= $rs->fields[0] . "?#?N?@?" ; 
              $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_appartment_shop()
   {
$nmgp_def_dados = "" ; 
if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']))
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']); 
}
else
{
    $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'] = 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_accountants_acountants_mob']['Lookup_appartment_shop']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'] = array_unique($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop']); 
   }
   else
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['Lookup_appartment_shop'] = array(); 
    }

   $old_value_sn = $this->sn;
   $old_value_transection_date = $this->transection_date;
   $old_value_check_number = $this->check_number;
   $old_value_payment_voucher = $this->payment_voucher;
   $old_value_receipt_voucher = $this->receipt_voucher;
   $old_value_amount = $this->amount;
   $old_value_depit = $this->depit;
   $old_value_creditor = $this->creditor;
   $old_value_bank_balance = $this->bank_balance;
   $this->nm_tira_formatacao();
   $this->nm_converte_datas(false);


   $unformatted_value_sn = $this->sn;
   $unformatted_value_transection_date = $this->transection_date;
   $unformatted_value_check_number = $this->check_number;
   $unformatted_value_payment_voucher = $this->payment_voucher;
   $unformatted_value_receipt_voucher = $this->receipt_voucher;
   $unformatted_value_amount = $this->amount;
   $unformatted_value_depit = $this->depit;
   $unformatted_value_creditor = $this->creditor;
   $unformatted_value_bank_balance = $this->bank_balance;

   $nm_comando = "SELECT appartments_shops_name, appartments_shops_name  FROM accountant_appartments_shops  ORDER BY appartments_shops_name";

   $this->sn = $old_value_sn;
   $this->transection_date = $old_value_transection_date;
   $this->check_number = $old_value_check_number;
   $this->payment_voucher = $old_value_payment_voucher;
   $this->receipt_voucher = $old_value_receipt_voucher;
   $this->amount = $old_value_amount;
   $this->depit = $old_value_depit;
   $this->creditor = $old_value_creditor;
   $this->bank_balance = $old_value_bank_balance;

   $_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_accountants_acountants_mob']['Lookup_appartment_shop'][] = $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_for_month()
   {
       $nmgp_def_dados  = "";
       $nmgp_def_dados .= "يناير?#?يناير?#?N?@?";
       $nmgp_def_dados .= "فبراير?#?فبراير?#?N?@?";
       $nmgp_def_dados .= "مارس?#?مارس?#?N?@?";
       $nmgp_def_dados .= "ابريل?#?ابريل?#?N?@?";
       $nmgp_def_dados .= "مايو?#?مايو?#?N?@?";
       $nmgp_def_dados .= "يونيو?#?يونيو?#?N?@?";
       $nmgp_def_dados .= "يوليو?#?يوليو?#?N?@?";
       $nmgp_def_dados .= "اغسطس?#?اغسطس?#?N?@?";
       $nmgp_def_dados .= "سبتمبر?#?سبتمبر?#?N?@?";
       $nmgp_def_dados .= "اكتوبر?#?اكتوبر?#?N?@?";
       $nmgp_def_dados .= "نوفمبر?#?نوفمبر?#?N?@?";
       $nmgp_def_dados .= "ديسمبر?#?ديسمبر?#?N?@?";
       $todo = explode("?@?", $nmgp_def_dados);
       return $todo;

   }
   function Form_lookup_for_year()
   {
       $nmgp_def_dados  = "";
       $nmgp_def_dados .= "2017?#?2017?#?S?@?";
       $nmgp_def_dados .= "2016?#?2016?#?N?@?";
       $nmgp_def_dados .= "2018?#?2018?#?N?@?";
       $todo = explode("?@?", $nmgp_def_dados);
       return $todo;

   }
   function Form_lookup_payment_method()
   {
       $nmgp_def_dados  = "";
       $nmgp_def_dados .= "شيك?#?شيك?#?N?@?";
       $nmgp_def_dados .= "نقدا?#?نقدا?#?N?@?";
       $nmgp_def_dados .= "تحويلات بنكية?#?تحويلات بنكية?#?N?@?";
       $nmgp_def_dados .= "ايداع بنكي?#?ايداع بنكي?#?N?@?";
       $todo = explode("?@?", $nmgp_def_dados);
       return $todo;

   }
   function SC_fast_search($field, $arg_search, $data_search)
   {
      if (empty($data_search)) 
      {
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['fast_search']);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_detal'])) 
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter'] = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_detal'];
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter'])
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter']);
              $this->NM_ajax_info['empty_filter'] = 'ok';
              form_accountants_acountants_mob_pack_ajax_response();
              exit;
          }
          return;
      }
      $comando = "";
      if ($_SESSION['scriptcase']['charset'] != "UTF-8" && NM_is_utf8($data_search))
      {
          $data_search = NM_conv_charset($data_search, $_SESSION['scriptcase']['charset'], "UTF-8");
      }
      $sv_data = $data_search;
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "sn", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_approved_on_month($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "approved_on_month", $arg_search, $data_lookup);
          }
      }
      {
          $this->SC_monta_condicao($comando, "transection_date", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_income_outcome($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "income_outcome", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_income_outcome_type($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "income_outcome_type", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_details_from_menu($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "details_from_menu", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "description", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_appartment_shop($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "appartment_shop", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_for_month($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "for_month", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_for_year($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "for_year", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_payment_method($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "payment_method", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "check_number", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "payment_voucher", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "receipt_voucher", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "amount", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "depit", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "creditor", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "remarks", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "bank_balance", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "creator_name", $arg_search, $data_search);
      }
      {
          $this->SC_monta_condicao($comando, "creator_date_time", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "update_name", $arg_search, $data_search);
      }
      {
          $this->SC_monta_condicao($comando, "update_date_time", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "sn", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_approved_on_month($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "approved_on_month", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "Transection_Order", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_income_outcome($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "income_outcome", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_income_outcome_type($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "income_outcome_type", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_details_from_menu($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "details_from_menu", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "description", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_appartment_shop($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "appartment_shop", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_for_month($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "for_month", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_for_year($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "for_year", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $data_lookup = $this->SC_lookup_payment_method($arg_search, $data_search);
          if (is_array($data_lookup) && !empty($data_lookup)) 
          {
              $this->SC_monta_condicao($comando, "payment_method", $arg_search, $data_lookup);
          }
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "check_number", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "payment_voucher", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "receipt_voucher", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "amount", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "depit", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "creditor", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "remarks", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "bank_balance", $arg_search, $data_search);
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_detal']) && !empty($comando)) 
      {
          $comando = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_detal'] . " and (" .  $comando . ")";
      }
      if (empty($comando)) 
      {
          $comando = " 1 <> 1 "; 
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter_form'])
      {
          $sc_where = " where " . $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter_form'] . " and (" . $comando . ")";
      }
      else
      {
         $sc_where = " where " . $comando;
      }
      $nmgp_select = "SELECT count(*) 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_accountants_acountants_mob = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['total'] = $qt_geral_reg_form_accountants_acountants_mob;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['where_filter'] = $comando;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['fast_search'][0] = $field;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['fast_search'][1] = $arg_search;
      $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['fast_search'][2] = $sv_data;
      $rt->Close(); 
      if (isset($rt->fields[0]) && $rt->fields[0] > 0 &&  isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter'])
      {
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter']);
          $this->NM_ajax_info['empty_filter'] = 'ok';
          form_accountants_acountants_mob_pack_ajax_response();
          exit;
      }
      elseif (!isset($rt->fields[0]) || $rt->fields[0] == 0)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['empty_filter'] = true;
          $this->NM_ajax_info['empty_filter'] = 'ok';
          form_accountants_acountants_mob_pack_ajax_response();
          exit;
      }
   }
   function SC_monta_condicao(&$comando, $nome, $condicao, $campo, $tp_campo="")
   {
      $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_numeric[] = "sn";$nm_numeric[] = "for_year";$nm_numeric[] = "check_number";$nm_numeric[] = "payment_voucher";$nm_numeric[] = "receipt_voucher";$nm_numeric[] = "amount";$nm_numeric[] = "depit";$nm_numeric[] = "creditor";$nm_numeric[] = "bank_balance";
      if (in_array($campo_join, $nm_numeric))
      {
         if ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['decimal_db'] == ".")
         {
             $nm_aspas  = "";
             $nm_aspas1 = "";
         }
         if (is_array($campo))
         {
             foreach ($campo as $Ind => $Cmp)
             {
                if (!is_numeric($Cmp))
                {
                    return;
                }
                if ($Cmp == "")
                {
                    $campo[$Ind] = 0;
                }
             }
         }
         else
         {
             if (!is_numeric($campo))
             {
                 return;
             }
             if ($campo == "")
             {
                $campo = 0;
             }
         }
      }
         if (in_array($campo_join, $nm_numeric) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) && (strtoupper($condicao) == "II" || strtoupper($condicao) == "QP" || strtoupper($condicao) == "NP"))
         {
             $nome      = "CAST ($nome AS TEXT)";
             $nm_aspas  = "'";
             $nm_aspas1 = "'";
         }
         if (in_array($campo_join, $nm_esp_postgres) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
         {
             $nome      = "CAST ($nome AS TEXT)";
             $nm_aspas  = "'";
             $nm_aspas1 = "'";
         }
      $Nm_datas['transection_date'] = "date";$Nm_datas['creator_date_time'] = "datetime";$Nm_datas['update_date_time'] = "datetime";
         if (isset($Nm_datas[$campo_join]))
         {
             for ($x = 0; $x < strlen($campo); $x++)
             {
                 $tst = substr($campo, $x, 1);
                 if (!is_numeric($tst) && ($tst != "-" && $tst != ":" && $tst != " "))
                 {
                     return;
                 }
             }
         }
          if (isset($Nm_datas[$campo_join]))
          {
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
             $nm_aspas  = "#";
             $nm_aspas1 = "#";
          }
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date']))
              {
                  $nm_aspas  = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date'];
                  $nm_aspas1 = $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['SC_sep_date1'];
              }
          }
      if (isset($Nm_datas[$campo_join]) && (strtoupper($condicao) == "II" || strtoupper($condicao) == "QP" || strtoupper($condicao) == "NP" || strtoupper($condicao) == "DF"))
      {
          if (strtoupper($condicao) == "DF")
          {
              $condicao = "NP";
          }
          if (($Nm_datas[$campo_join] == "datetime" || $Nm_datas[$campo_join] == "timestamp") && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $nome = "to_char (" . $nome . ", 'YYYY-MM-DD hh24:mi:ss')";
          }
          elseif ($Nm_datas[$campo_join] == "date" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $nome = "to_char (" . $nome . ", 'YYYY-MM-DD')";
          }
          elseif ($Nm_datas[$campo_join] == "time" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $nome = "to_char (" . $nome . ", 'hh24:mi:ss')";
          }
          elseif (substr($Nm_datas[$campo_join], 0, 4) == "date" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
          {
              $nome = "str_replace (convert(char(10)," . $nome . ",102), '.', '-') + ' ' + convert(char(8)," . $nome . ",20)";
          }
      }
         $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_aspas . $Cmp . $nm_aspas1;
             }
             $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);
         switch (strtoupper($condicao))
         {
            case "EQ":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " = " . $nm_aspas . $campo . $nm_aspas1;
            break;
            case "II":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " like '" . $campo . "%'";
            break;
            case "QP":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower ." like '%" . $campo . "%'";
            break;
            case "NP":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower ." not like '%" . $campo . "%'";
            break;
            case "DF":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " <> " . $nm_aspas . $campo . $nm_aspas1;
            break;
            case "GT":     // 
               $comando        .= " $nome > " . $nm_aspas . $campo . $nm_aspas1;
            break;
            case "GE":     // 
               $comando        .= " $nome >= " . $nm_aspas . $campo . $nm_aspas1;
            break;
            case "LT":     // 
               $comando        .= " $nome < " . $nm_aspas . $campo . $nm_aspas1;
            break;
            case "LE":     // 
               $comando        .= " $nome <= " . $nm_aspas . $campo . $nm_aspas1;
            break;
         }
   }
   function SC_lookup_approved_on_month($condicao, $campo)
   {
       $data_look = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $data_look['يناير'] = "يناير";
       $data_look['فبراير'] = "فبراير";
       $data_look['مارس'] = "مارس";
       $data_look['ابريل'] = "ابريل";
       $data_look['مايو'] = "مايو";
       $data_look['يونيو'] = "يونيو";
       $data_look['يوليو'] = "يوليو";
       $data_look['اغسطس'] = "اغسطس";
       $data_look['سبتمبر'] = "سبتمبر";
       $data_look['اكتوبر'] = "اكتوبر";
       $data_look['نوفمبر'] = "نوفمبر";
       $data_look['ديسمبر'] = "ديسمبر";
       $result = array();
       foreach ($data_look as $chave => $label) 
       {
           if ($condicao == "eq" && $campo == $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
           {
               $result[] = $chave;
           }
           if ($condicao == "qp" && strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "np" && !strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "df" && $campo != $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "gt" && $label > $campo )
           {
               $result[] = $chave;
           }
           if ($condicao == "ge" && $label >= $campo)
            {
               $result[] = $chave;
           }
           if ($condicao == "lt" && $label < $campo)
           {
               $result[] = $chave;
           }
           if ($condicao == "le" && $label <= $campo)
           {
               $result[] = $chave;
           }
          
       }
       return $result;
   }
   function SC_lookup_income_outcome($condicao, $campo)
   {
       $data_look = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $data_look['ايرادات'] = "ايرادات";
       $data_look['مصروفات'] = "مصروفات";
       $result = array();
       foreach ($data_look as $chave => $label) 
       {
           if ($condicao == "eq" && $campo == $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
           {
               $result[] = $chave;
           }
           if ($condicao == "qp" && strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "np" && !strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "df" && $campo != $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "gt" && $label > $campo )
           {
               $result[] = $chave;
           }
           if ($condicao == "ge" && $label >= $campo)
            {
               $result[] = $chave;
           }
           if ($condicao == "lt" && $label < $campo)
           {
               $result[] = $chave;
           }
           if ($condicao == "le" && $label <= $campo)
           {
               $result[] = $chave;
           }
          
       }
       return $result;
   }
   function SC_lookup_income_outcome_type($condicao, $campo)
   {
       $result = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $nm_comando = "SELECT income_outcome_type FROM accountants_income_outcome WHERE (income_outcome_type LIKE '%$campo%')" ; 
       if ($condicao == "ii")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "LIKE '$campo%'", $nm_comando);
       }
       if ($condicao == "df" || $condicao == "np")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "NOT LIKE '%$campo%'", $nm_comando);
       }
       if ($condicao == "gt")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "> '$campo'", $nm_comando);
       }
       if ($condicao == "ge")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", ">= '$campo'", $nm_comando);
       }
       if ($condicao == "lt")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "< '$campo'", $nm_comando);
       }
       if ($condicao == "le")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "<= '$campo'", $nm_comando);
       }
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
       if ($rx = $this->Db->Execute($nm_comando)) 
       { 
           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_details_from_menu($condicao, $campo)
   {
       $result = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $nm_comando = "SELECT details_from_menu FROM accountants_income_outcome_type WHERE (details_from_menu LIKE '%$campo%')" ; 
       if ($condicao == "ii")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "LIKE '$campo%'", $nm_comando);
       }
       if ($condicao == "df" || $condicao == "np")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "NOT LIKE '%$campo%'", $nm_comando);
       }
       if ($condicao == "gt")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "> '$campo'", $nm_comando);
       }
       if ($condicao == "ge")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", ">= '$campo'", $nm_comando);
       }
       if ($condicao == "lt")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "< '$campo'", $nm_comando);
       }
       if ($condicao == "le")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "<= '$campo'", $nm_comando);
       }
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
       if ($rx = $this->Db->Execute($nm_comando)) 
       { 
           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_appartment_shop($condicao, $campo)
   {
       $result = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $nm_comando = "SELECT appartments_shops_name, appartments_shops_name FROM accountant_appartments_shops WHERE (appartments_shops_name LIKE '%$campo%')" ; 
       if ($condicao == "ii")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "LIKE '$campo%'", $nm_comando);
       }
       if ($condicao == "df" || $condicao == "np")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "NOT LIKE '%$campo%'", $nm_comando);
       }
       if ($condicao == "gt")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "> '$campo'", $nm_comando);
       }
       if ($condicao == "ge")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", ">= '$campo'", $nm_comando);
       }
       if ($condicao == "lt")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "< '$campo'", $nm_comando);
       }
       if ($condicao == "le")
       {
           $nm_comando = str_replace("LIKE '%$campo%'", "<= '$campo'", $nm_comando);
       }
       $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_comando; 
       $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
       if ($rx = $this->Db->Execute($nm_comando)) 
       { 
           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_for_month($condicao, $campo)
   {
       $data_look = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $data_look['يناير'] = "يناير";
       $data_look['فبراير'] = "فبراير";
       $data_look['مارس'] = "مارس";
       $data_look['ابريل'] = "ابريل";
       $data_look['مايو'] = "مايو";
       $data_look['يونيو'] = "يونيو";
       $data_look['يوليو'] = "يوليو";
       $data_look['اغسطس'] = "اغسطس";
       $data_look['سبتمبر'] = "سبتمبر";
       $data_look['اكتوبر'] = "اكتوبر";
       $data_look['نوفمبر'] = "نوفمبر";
       $data_look['ديسمبر'] = "ديسمبر";
       $result = array();
       foreach ($data_look as $chave => $label) 
       {
           if ($condicao == "eq" && $campo == $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
           {
               $result[] = $chave;
           }
           if ($condicao == "qp" && strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "np" && !strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "df" && $campo != $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "gt" && $label > $campo )
           {
               $result[] = $chave;
           }
           if ($condicao == "ge" && $label >= $campo)
            {
               $result[] = $chave;
           }
           if ($condicao == "lt" && $label < $campo)
           {
               $result[] = $chave;
           }
           if ($condicao == "le" && $label <= $campo)
           {
               $result[] = $chave;
           }
          
       }
       return $result;
   }
   function SC_lookup_for_year($condicao, $campo)
   {
       $data_look = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $data_look['2017'] = "2017";
       $data_look['2016'] = "2016";
       $data_look['2018'] = "2018";
       $result = array();
       foreach ($data_look as $chave => $label) 
       {
           if ($condicao == "eq" && $campo == $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
           {
               $result[] = $chave;
           }
           if ($condicao == "qp" && strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "np" && !strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "df" && $campo != $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "gt" && $label > $campo )
           {
               $result[] = $chave;
           }
           if ($condicao == "ge" && $label >= $campo)
            {
               $result[] = $chave;
           }
           if ($condicao == "lt" && $label < $campo)
           {
               $result[] = $chave;
           }
           if ($condicao == "le" && $label <= $campo)
           {
               $result[] = $chave;
           }
          
       }
       return $result;
   }
   function SC_lookup_payment_method($condicao, $campo)
   {
       $data_look = array();
       $campo  = substr($this->Db->qstr($campo), 1, -1);
       $data_look['شيك'] = "شيك";
       $data_look['نقدا'] = "نقدا";
       $data_look['تحويلات بنكية'] = "تحويلات بنكية";
       $data_look['ايداع بنكي'] = "ايداع بنكي";
       $result = array();
       foreach ($data_look as $chave => $label) 
       {
           if ($condicao == "eq" && $campo == $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "ii" && $campo == substr($label, 0, strlen($campo)))
           {
               $result[] = $chave;
           }
           if ($condicao == "qp" && strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "np" && !strstr($label, $campo))
           {
               $result[] = $chave;
           }
           if ($condicao == "df" && $campo != $label)
           {
               $result[] = $chave;
           }
           if ($condicao == "gt" && $label > $campo )
           {
               $result[] = $chave;
           }
           if ($condicao == "ge" && $label >= $campo)
            {
               $result[] = $chave;
           }
           if ($condicao == "lt" && $label < $campo)
           {
               $result[] = $chave;
           }
           if ($condicao == "le" && $label <= $campo)
           {
               $result[] = $chave;
           }
          
       }
       return $result;
   }
function 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_accountants_acountants_mob_fim.php";
   }
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['redir']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['redir'] == 'redir')
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']);
   }
   unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opc_ant']);
   if ($tipo == 2 && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['nm_run_menu']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['nm_run_menu'] == 1)
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['nm_run_menu'] = 2;
       $nmgp_saida_form = "form_accountants_acountants_mob_fim.php";
   }
   $diretorio = explode("/", $nmgp_saida_form);
   $cont = count($diretorio);
   $apl = $diretorio[$cont - 1];
   $apl = str_replace(".php", "", $apl);
   $pos = strpos($apl, "?");
   if ($pos !== false)
   {
       $apl = substr($apl, 0, $pos);
   }
   if ($tipo != 1 && $tipo != 2)
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page][$apl]['where_orig']);
   }
   if ($this->NM_ajax_flag)
   {
       $sTarget = '_self';
       $this->NM_ajax_info['redir']['metodo']              = 'post';
       $this->NM_ajax_info['redir']['action']              = $nmgp_saida_form;
       $this->NM_ajax_info['redir']['target']              = $sTarget;
       $this->NM_ajax_info['redir']['script_case_init']    = $this->Ini->sc_page;
       $this->NM_ajax_info['redir']['script_case_session'] = session_id();
       if (0 == $tipo)
       {
           $this->NM_ajax_info['redir']['nmgp_url_saida'] = $this->nm_location;
       }
       form_accountants_acountants_mob_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/scriptcase__NM__ico__NM__favicon.ico">
   </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); ?>"> 
     <INPUT type="hidden" name="script_case_session" value="<?php echo $this->form_encode_input(session_id()); ?>"> 
   </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_accountants_acountants_mob']['sc_modal']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['sc_modal'])
   {
?>
        parent.<?php echo $this->lig_edit_lookup_cb; ?>(<?php echo $this->lig_edit_lookup_row; ?>);
<?php
   }
   elseif ($this->lig_edit_lookup)
   {
?>
        opener.<?php echo $this->lig_edit_lookup_cb; ?>(<?php echo $this->lig_edit_lookup_row; ?>);
<?php
   }
?>
      }
      if (bLigEditLookupCall)
      {
        scLigEditLookupCall();
      }
<?php
if ($tipo == 2 && isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['masterValue']))
{
    if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dashboard_info']['under_dashboard']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dashboard_info']['under_dashboard']) {
?>
var dbParentFrame = $(parent.document).find("[name='<?php echo $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['dashboard_info']['parent_widget']; ?>']");
if (dbParentFrame && dbParentFrame[0] && dbParentFrame[0].contentWindow.scAjaxDetailValue)
{
<?php
        foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['masterValue'] as $cmp_master => $val_master)
        {
?>
    dbParentFrame[0].contentWindow.scAjaxDetailValue('<?php echo $cmp_master ?>', '<?php echo $val_master ?>');
<?php
        }
        unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['masterValue']);
?>
}
<?php
    }
    else {
?>
if (parent && parent.scAjaxDetailValue)
{
<?php
        foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['masterValue'] as $cmp_master => $val_master)
        {
?>
    parent.scAjaxDetailValue('<?php echo $cmp_master ?>', '<?php echo $val_master ?>');
<?php
        }
        unset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['masterValue']);
?>
}
<?php
    }
}
?>
      document.form_ok.submit();
   </SCRIPT>
   </BODY>
   </HTML>
<?php
  exit;
}
 function nm_gera_mensagem($nm_mensagem, $nm_apl_dest, $nm_apl_retorno="", $nm_apl_parms="")
 {
    $nm_tp_saida = "post";
    if ($nm_apl_dest == "form_accountants_acountants_mob.php")
    {
        $form_submit = 1;
        $form_opcao  = $this->nmgp_opcao;
    }
    if ("novo" == $this->nmgp_opcao || "insert" == $this->sc_evento)
    {
        $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['opc_ant'] = "";
    }
    if ($nm_apl_retorno == 'parent')
    {
        $nm_apl_retorno = "";
        $nm_tp_saida = "parent";
    }
    elseif (strtolower(substr($nm_apl_dest, 0, 5)) == "http:" || strtolower(substr($nm_apl_dest, 0, 6)) == "https:" || strtolower(substr($nm_apl_dest, 0, 3)) == "../")
    {
        $nm_tp_saida = "get";
    }
    if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['sc_outra_jan']) && $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['sc_outra_jan'] && $nm_apl_retorno == 'sc_sai')
    {
        $nm_tp_saida    = "close";
    }
    if ($nm_apl_retorno == 'sc_sai')
    {
        $nm_apl_retorno = "";
    }
    if ($this->NM_ajax_flag && isset($this->NM_ajax_info['param']['buffer_output']) && $this->NM_ajax_info['param']['buffer_output'])
    {
        $sOldBuffer = ob_get_contents();
        ob_end_clean();
        $this->NM_ajax_info['redir']['metodo'] = 'html';
        $this->NM_ajax_info['redir']['action'] = '';
        ob_start();
    }
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

<html<?php echo $_SESSION['scriptcase']['reg_conf']['html_dir'] ?>>
<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/scriptcase__NM__ico__NM__favicon.ico">
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_form.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_form<?php echo $_SESSION['scriptcase']['reg_conf']['css_dir'] ?>.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_tab.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_tab<?php echo $_SESSION['scriptcase']['reg_conf']['css_dir'] ?>.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_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_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_calendar.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_calendar<?php echo $_SESSION['scriptcase']['reg_conf']['css_dir'] ?>.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_btngrp.css" />
 <link rel="stylesheet" type="text/css" href="<?php echo $this->Ini->path_link ?>_lib/css/<?php echo $this->Ini->str_schema_all ?>_btngrp<?php echo $_SESSION['scriptcase']['reg_conf']['css_dir'] ?>.css" media="screen" />
</HEAD>
<body class="scFormPage">
<form name="Fmens" method=post 
             target="_self"> 
<input type=hidden name="nm_form_submit" value="<?php echo $this->form_encode_input($form_submit); ?>">
<input type=hidden name="nmgp_opcao" value="<?php echo $this->form_encode_input($form_opcao); ?>">
<input type="hidden" name="nmgp_parms" value="<?php echo $this->form_encode_input($nm_apl_parms); ?>"/>
<input type="hidden" name="nmgp_url_saida" value="<?php echo $this->form_encode_input($nm_apl_retorno); ?>">
<input type=hidden name="script_case_init" value="<?php echo $this->form_encode_input($this->Ini->sc_page); ?>"> 
<input type=hidden name="script_case_session" value="<?php echo $this->form_encode_input(session_id()); ?>"> 
<table align="center"> 
<tr><td> 
<TABLE  class="scFormTable">
  <TR>
    <TD  class="scFormDataOdd"><?php echo $nm_mensagem; ?></TD>
  </TR>
</TABLE></td></tr> 
<tr><td align="center">
<?php
?>
       <input type="button" name="Bmens" onclick="nm_saida_mens('<?php echo $nm_tp_saida; ?>')" class="scButton1" value="<?php echo $this->Ini->Nm_lang['lang_btns_cfrm'] ?>" align="absmiddle"> 
<?php
 
?>
</td></tr> 
</table> 
</form> 
<script type="text/javascript"> 
function nm_saida_mens(tp_saida) 
{ 
   if (tp_saida == "close") 
   { 
       window.close();  
   } 
   if (tp_saida == "parent") 
   { 
<?php
        if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['run_iframe_ajax']))
        {
            echo "parent.ajax_navigate('edit', '" . $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'][1] . "');";
        }
        else
        {
            echo "parent.location = '" . $_SESSION['sc_session'][$this->Ini->sc_page]['form_accountants_acountants_mob']['retorno_edit'] . "';"; 
        }
?>
   } 
   if (tp_saida == "post") 
   { 
       document.Fmens.target  = "_self"; 
       document.Fmens.action  = "<?php echo $nm_apl_dest; ?>";
       document.Fmens.submit(); 
   } 
   if (tp_saida == "get") 
   { 
       window.location = "<?php echo $nm_apl_dest; ?>";  
   } 
} 
<?php
if ($this->lig_edit_lookup)
{
?>
  opener.<?php echo $this->lig_edit_lookup_cb; ?>(<?php echo $this->lig_edit_lookup_row; ?>);
<?php
}
?>
</script> 
</body>
</html>
<?php
    if ($this->NM_ajax_flag && isset($this->NM_ajax_info['param']['buffer_output']) && $this->NM_ajax_info['param']['buffer_output'])
    {
        $this->NM_ajax_info['redir']['action'] = form_accountants_acountants_mob_pack_protect_string(ob_get_contents());
        ob_end_clean();
        ob_start();
        form_accountants_acountants_mob_pack_ajax_response();
    }
    exit;
 }
}
?>
