<?php
//
class dye_grpcs_edit_grid_apl
{
   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(),
                                'navPage'        => array(),
                                'redir'          => array(),
                                'blockDisplay'   => array(),
                                'fieldDisplay'   => array(),
                                'fieldLabel'     => array(),
                                'readOnly'       => array(),
                                'btnVars'        => array(),
                                'ajaxAlert'      => '',
                                'ajaxMessage'    => '',
                                'ajaxJavascript' => array(),
                                'buttonDisplay'  => array(),
                                'calendarReload' => false,
                                'quickSearchRes' => false,
                                'displayMsg'     => false,
                                'displayMsgTxt'  => '',
                               );
   var $Nav_permite_ava = true;
   var $Nav_permite_ret = true;
   var $Apl_com_erro    = false;
   var $Ini;
   var $Erro;
   var $Db;
   var $p_o_number_;
   var $old_po_;
   var $style_;
   var $invoice_;
   var $case_;
   var $piece_;
   var $racks_;
   var $lbs_recd_;
   var $lbs_used_;
   var $lbs_open_;
   var $dye_order_;
   var $cost_lb_g_;
   var $total_cost_;
   var $adate_;
   var $edate_;
   var $ddate_;
   var $shipto_;
   var $sdate_;
   var $ac_;
   var $defects_;
   var $rpd_;
   var $id2_;
   var $nm_data;
   var $nmgp_opcao;
   var $nmgp_opc_ant;
   var $sc_evento;
   var $nmgp_clone;
   var $nmgp_return_img = array();
   var $nmgp_dados_form = array();
   var $nmgp_dados_select = array();
   var $nm_location;
   var $nm_flag_iframe;
   var $nm_flag_saida_novo;
   var $nmgp_botoes = array();
   var $nmgp_url_saida;
   var $nmgp_form_show;
   var $nmgp_form_empty;
   var $nmgp_cmp_readonly = array();
   var $nmgp_cmp_hidden = array();
   var $sc_teve_incl = false;
   var $sc_teve_excl = false;
   var $sc_teve_alt  = false;
   var $sc_after_all_insert = false;
   var $sc_after_all_update = false;
   var $sc_max_reg = 10; 
   var $sc_max_reg_incl = 10; 
   var $form_vert_dye_grpcs_edit_grid = array();
   var $form_paginacao = 'parcial';
   var $lig_edit_lookup      = false;
   var $lig_edit_lookup_call = false;
   var $lig_edit_lookup_cb   = '';
   var $lig_edit_lookup_row  = '';
   var $is_calendar_app = false;
   var $Embutida_call  = false;
   var $Embutida_ronly = false;
   var $Embutida_proc  = false;
   var $Embutida_form  = true;
   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, 
               $GLOBALS, $Campos_Crit, $Campos_Falta, $Campos_Erros, $sc_seq_vert, $sc_check_incl, 
               $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']['ac_']))
          {
              $this->ac_ = $this->NM_ajax_info['param']['ac_'];
          }
          if (isset($this->NM_ajax_info['param']['adate_']))
          {
              $this->adate_ = $this->NM_ajax_info['param']['adate_'];
          }
          if (isset($this->NM_ajax_info['param']['case_']))
          {
              $this->case_ = $this->NM_ajax_info['param']['case_'];
          }
          if (isset($this->NM_ajax_info['param']['cost_lb_g_']))
          {
              $this->cost_lb_g_ = $this->NM_ajax_info['param']['cost_lb_g_'];
          }
          if (isset($this->NM_ajax_info['param']['ddate_']))
          {
              $this->ddate_ = $this->NM_ajax_info['param']['ddate_'];
          }
          if (isset($this->NM_ajax_info['param']['defects_']))
          {
              $this->defects_ = $this->NM_ajax_info['param']['defects_'];
          }
          if (isset($this->NM_ajax_info['param']['dye_order_']))
          {
              $this->dye_order_ = $this->NM_ajax_info['param']['dye_order_'];
          }
          if (isset($this->NM_ajax_info['param']['edate_']))
          {
              $this->edate_ = $this->NM_ajax_info['param']['edate_'];
          }
          if (isset($this->NM_ajax_info['param']['id2_']))
          {
              $this->id2_ = $this->NM_ajax_info['param']['id2_'];
          }
          if (isset($this->NM_ajax_info['param']['invoice_']))
          {
              $this->invoice_ = $this->NM_ajax_info['param']['invoice_'];
          }
          if (isset($this->NM_ajax_info['param']['lbs_open_']))
          {
              $this->lbs_open_ = $this->NM_ajax_info['param']['lbs_open_'];
          }
          if (isset($this->NM_ajax_info['param']['lbs_recd_']))
          {
              $this->lbs_recd_ = $this->NM_ajax_info['param']['lbs_recd_'];
          }
          if (isset($this->NM_ajax_info['param']['lbs_used_']))
          {
              $this->lbs_used_ = $this->NM_ajax_info['param']['lbs_used_'];
          }
          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_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_refresh_row']))
          {
              $this->nmgp_refresh_row = $this->NM_ajax_info['param']['nmgp_refresh_row'];
          }
          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']['p_o_number_']))
          {
              $this->p_o_number_ = $this->NM_ajax_info['param']['p_o_number_'];
          }
          if (isset($this->NM_ajax_info['param']['piece_']))
          {
              $this->piece_ = $this->NM_ajax_info['param']['piece_'];
          }
          if (isset($this->NM_ajax_info['param']['racks_']))
          {
              $this->racks_ = $this->NM_ajax_info['param']['racks_'];
          }
          if (isset($this->NM_ajax_info['param']['rpd_']))
          {
              $this->rpd_ = $this->NM_ajax_info['param']['rpd_'];
          }
          if (isset($this->NM_ajax_info['param']['sc_clone']))
          {
              $this->sc_clone = $this->NM_ajax_info['param']['sc_clone'];
          }
          if (isset($this->NM_ajax_info['param']['sc_seq_clone']))
          {
              $this->sc_seq_clone = $this->NM_ajax_info['param']['sc_seq_clone'];
          }
          if (isset($this->NM_ajax_info['param']['sc_seq_vert']))
          {
              $this->sc_seq_vert = $this->NM_ajax_info['param']['sc_seq_vert'];
          }
          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']['sdate_']))
          {
              $this->sdate_ = $this->NM_ajax_info['param']['sdate_'];
          }
          if (isset($this->NM_ajax_info['param']['shipto_']))
          {
              $this->shipto_ = $this->NM_ajax_info['param']['shipto_'];
          }
          if (isset($this->NM_ajax_info['param']['style_']))
          {
              $this->style_ = $this->NM_ajax_info['param']['style_'];
          }
          if (isset($this->NM_ajax_info['param']['total_cost_']))
          {
              $this->total_cost_ = $this->NM_ajax_info['param']['total_cost_'];
          }
          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();
      $this->sc_conv_var['p_o_number'] = "p_o_number_";
      $this->sc_conv_var['old_po'] = "old_po_";
      $this->sc_conv_var['style'] = "style_";
      $this->sc_conv_var['invoice'] = "invoice_";
      $this->sc_conv_var['case'] = "case_";
      $this->sc_conv_var['piece'] = "piece_";
      $this->sc_conv_var['racks'] = "racks_";
      $this->sc_conv_var['lbs_recd'] = "lbs_recd_";
      $this->sc_conv_var['lbs_used'] = "lbs_used_";
      $this->sc_conv_var['lbs_open'] = "lbs_open_";
      $this->sc_conv_var['dye_order'] = "dye_order_";
      $this->sc_conv_var['cost_lb_g'] = "cost_lb_g_";
      $this->sc_conv_var['total_cost'] = "total_cost_";
      $this->sc_conv_var['adate'] = "adate_";
      $this->sc_conv_var['edate'] = "edate_";
      $this->sc_conv_var['ddate'] = "ddate_";
      $this->sc_conv_var['shipto'] = "shipto_";
      $this->sc_conv_var['sdate'] = "sdate_";
      $this->sc_conv_var['ac'] = "ac_";
      $this->sc_conv_var['defects'] = "defects_";
      $this->sc_conv_var['rpd'] = "rpd_";
      $this->sc_conv_var['id2'] = "id2_";
      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'];
          }
      }
      if (!empty($_POST))
      {
          foreach ($_POST as $nmgp_var => $nmgp_val)
          {
               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 (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($this->var_id2) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['var_id2'] = $this->var_id2;
      }
      if (isset($this->var_dyeorder) && isset($this->NM_contr_var_session) && $this->NM_contr_var_session == "Yes") 
      {
          $_SESSION['var_dyeorder'] = $this->var_dyeorder;
      }
      if (isset($_POST["var_id2"])) 
      {
          $_SESSION['var_id2'] = $this->var_id2;
      }
      if (isset($_POST["var_dyeorder"])) 
      {
          $_SESSION['var_dyeorder'] = $this->var_dyeorder;
      }
      if (isset($_GET["var_id2"])) 
      {
          $_SESSION['var_id2'] = $this->var_id2;
      }
      if (isset($_GET["var_dyeorder"])) 
      {
          $_SESSION['var_dyeorder'] = $this->var_dyeorder;
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['embutida_parms']))
      { 
          $this->nmgp_parms = $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['embutida_parms'];
          unset($_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['embutida_parms']);
      } 
      if (isset($this->nmgp_parms) && !empty($this->nmgp_parms)) 
      { 
          if (isset($_SESSION['nm_aba_bg_color'])) 
          { 
              unset($_SESSION['nm_aba_bg_color']);
          }   
          $this->NM_where_filter = "";
          $tem_where_parms       = false;
          $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);
          $todo = explode("?@?", $nmgp_parms);
          $ix = 0;
          while (!empty($todo[$ix]))
          {
             $cadapar = explode("?#?", $todo[$ix]);
             if (1 < sizeof($cadapar))
             {
                 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_dye_grpcs_edit_grid($cadapar[1]);
                 $this->$cadapar[0] = $cadapar[1];
                 if ($cadapar[0] == "ID2_")
                 {
                     $this->NM_where_filter .= (empty($this->NM_where_filter)) ? "(" : " and ";
                     $this->NM_where_filter .= " = '" . $this->ID2_ . "'";
                     $tem_where_parms        = true;
                 }
                 if ($cadapar[0] == "NM_where_filter")
                 {
                     $tem_where_parms = false;
                 }
             }
             $ix++;
          }
          if ($tem_where_parms)
          {
              $this->NM_where_filter .= ")";
          }
          else
          {
              unset($this->NM_where_filter);
          }
          if (isset($this->NM_where_filter_form))
          {
              $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['where_filter_form'] = $this->NM_where_filter_form;
             unset($_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['total']);
          }
          if (isset($this->sc_redir_atualiz))
          {
              $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['sc_redir_atualiz'] = $this->sc_redir_atualiz;
          }
          if (isset($this->sc_redir_insert))
          {
              $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['sc_redir_insert'] = $this->sc_redir_insert;
          }
          if (isset($this->var_id2)) 
          {
              $_SESSION['var_id2'] = $this->var_id2;
          }
          if (isset($this->var_dyeorder)) 
          {
              $_SESSION['var_dyeorder'] = $this->var_dyeorder;
          }
      } 
      elseif (isset($script_case_init) && !empty($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['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 == ""))
          {
              $todo = explode("?@?", $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['parms']);
              $ix = 0;
              while (!empty($todo[$ix]))
              {
                 $cadapar = explode("?#?", $todo[$ix]);
                 $this->$cadapar[0] = $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]['dye_grpcs_edit_grid']['lig_edit_lookup']     = true;
          $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['lig_edit_lookup_cb']  = $this->nm_evt_ret_edit;
          $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['lig_edit_lookup_row'] = isset($this->nm_evt_ret_row) ? $this->nm_evt_ret_row : '';
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['lig_edit_lookup']) && $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['lig_edit_lookup'])
      {
          $this->lig_edit_lookup     = true;
          $this->lig_edit_lookup_cb  = $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['lig_edit_lookup_cb'];
          $this->lig_edit_lookup_row = $_SESSION['sc_session'][$script_case_init]['dye_grpcs_edit_grid']['lig_edit_lookup_row'];
      }
      if (!$this->Ini)
      { 
          $this->Ini = new dye_grpcs_edit_grid_ini(); 
          $this->Ini->init();
      } 
      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 . '.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_mult)   ? ""     : $str_img_status_ok_mult;
      $this->Ini->Img_status_err  = "" == trim($str_img_status_err_mult)  ? ""     : $str_img_status_err_mult;
      $this->Ini->Css_status      = "scFormInputErrorMult";
      $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->arr_buttons['sc_btn_0']['hint']             = "";
      $this->arr_buttons['sc_btn_0']['type']             = "button";
      $this->arr_buttons['sc_btn_0']['value']            = "Generate Primary Key";
      $this->arr_buttons['sc_btn_0']['display']          = "only_text";
      $this->arr_buttons['sc_btn_0']['display_position'] = "text_right";
      $this->arr_buttons['sc_btn_0']['style']            = "default";
      $this->arr_buttons['sc_btn_0']['image']            = "";


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

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

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

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

      $this->nmgp_botoes['exit'] = "on";
      $this->nmgp_botoes['new']  = "off";
      $this->nmgp_botoes['copy'] = "off";
      $this->nmgp_botoes['insert'] = "off";
      $this->nmgp_botoes['update'] = "off";
      $this->nmgp_botoes['delete'] = "off";
      if ('total' == $this->form_paginacao)
      {
          $this->nmgp_botoes['first']   = "off";
          $this->nmgp_botoes['back']    = "off";
          $this->nmgp_botoes['forward'] = "off";
          $this->nmgp_botoes['last']    = "off";
          $this->nmgp_botoes['navpage'] = "off";
          $this->nmgp_botoes['goto']    = "off";
          $this->nmgp_botoes['qtline']  = "off";
      }
      else
      {
      $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'] = "on";
      $this->nmgp_botoes['goto'] = "on";
      $this->nmgp_botoes['qtline'] = "on";
      }
      $this->nmgp_botoes['sc_btn_0'] = "on";
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['iframe_filtro']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['iframe_filtro'] == "S")
      {
          $this->nmgp_botoes['exit'] = "off";
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['btn_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['btn_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['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']['dye_grpcs_edit_grid']['insert']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['insert'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['insert'];
          $this->nmgp_botoes['insert'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['insert'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['new']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['new'] != '')
      {
          $this->nmgp_botoes['new']    = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['new'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['update']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['update'] != '')
      {
          $this->nmgp_botoes['update'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['update'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['delete']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['delete'] != '')
      {
          $this->nmgp_botoes['delete'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['delete'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['first']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['first'] != '')
      {
          $this->nmgp_botoes['first'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['first'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['back']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['back'] != '')
      {
          $this->nmgp_botoes['back'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['back'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['forward']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['forward'] != '')
      {
          $this->nmgp_botoes['forward'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['forward'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['last']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['last'] != '')
      {
          $this->nmgp_botoes['last'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['last'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['qsearch']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['qsearch'] != '')
      {
          $this->nmgp_botoes['qsearch'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['qsearch'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['summary']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['summary'] != '')
      {
          $this->nmgp_botoes['summary'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['summary'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['navpage']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['navpage'] != '')
      {
          $this->nmgp_botoes['navpage'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['navpage'];
      }
      if (isset($_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['goto']) && $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['goto'] != '')
      {
          $this->nmgp_botoes['goto'] = $_SESSION['scriptcase']['sc_apl_conf_lig']['dye_grpcs_edit_grid']['goto'];
      }

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

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

      if (isset($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['field_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['field_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['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']['dye_grpcs_edit_grid']['field_readonly']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['field_readonly']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['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']['dye_grpcs_edit_grid']['exit']) && $_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['exit'] != '')
      {
          $_SESSION['scriptcase']['sc_url_saida'][$this->Ini->sc_page] = $_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['exit'];
      }
      $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("dye_grpcs_edit_grid", $apls_aba))
              {
                  $this->aba_iframe = true;
                  break;
              }
          }
      }
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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") ; 
      $this->nm_data = new nm_data("en_us");
      if (isset($_GET['nm_cal_display']))
      {
          if ($this->Embutida_proc)
          { 
              include_once($this->Ini->path_embutida . 'dye_grpcs_edit_grid/dye_grpcs_edit_grid_calendar.php');
          }
          else
          { 
              include_once($this->Ini->path_aplicacao . 'dye_grpcs_edit_grid_calendar.php');
          }
          exit;
      }

      if (is_file($this->Ini->path_aplicacao . 'dye_grpcs_edit_grid_help.txt'))
      {
          $arr_link_webhelp = file($this->Ini->path_aplicacao . 'dye_grpcs_edit_grid_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 . 'dye_grpcs_edit_grid/dye_grpcs_edit_grid_erro.class.php');
      }
      else
      { 
          require_once($this->Ini->path_aplicacao . "dye_grpcs_edit_grid_erro.class.php"); 
      }
      $this->Erro      = new dye_grpcs_edit_grid_erro();
      $this->Erro->Ini = $this->Ini;
      if ($nm_opc_lookup != "lookup" && $nm_opc_php != "formphp")
      { 
         if (empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao']))
         { 
             if ($this->id2_ != "")   
             { 
                 $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao'] = "igual" ;  
             }   
         }   
      } 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao']) && empty($this->nmgp_refresh_fields))
      {
          $this->nmgp_opcao = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao'];  
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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']['dye_grpcs_edit_grid']['start']) && $_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['start'] == 'new')
      {
          $this->nmgp_opcao = "novo";
          $this->nm_Start_new = true;
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao'] = "novo";
          unset($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['opc_ant'];
      } 
      if ($this->nmgp_opcao == "novo")  
      {
          $this->nmgp_botoes['sc_btn_0'] = "off";
      }
      elseif ($this->nmgp_opcao == "incluir")  
      {
          $this->nmgp_botoes['sc_btn_0'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['botoes']['sc_btn_0'];
      }
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "muda_form")  
      {
          $this->nmgp_botoes = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['botoes'];
          $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['inicio'];
          $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] != $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['final'];
      }
      else
      {
      }
      $this->nm_flag_iframe = false;
      if ($this->nmgp_opcao == "edit_novo")  
      {
          $this->nmgp_opcao = "novo";
          $this->nm_flag_saida_novo = "S";
      }
//
      $this->sc_evento = $this->nmgp_opcao;
      if ($nm_opc_form_php == "formphp")
      { 
          if ($nm_call_php == "sc_btn_0")
          { 
              $this->sc_btn_sc_btn_0();
          } 
          $this->NM_close_db(); 
          exit;
      } 
   }

   function loadFieldConfig()
   {
      $this->field_config = array();
      //-- lbs_recd_
      $this->field_config['lbs_recd_']               = array();
      $this->field_config['lbs_recd_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs_recd_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs_recd_']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['lbs_recd_']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs_recd_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- lbs_used_
      $this->field_config['lbs_used_']               = array();
      $this->field_config['lbs_used_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs_used_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs_used_']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['lbs_used_']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs_used_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- lbs_open_
      $this->field_config['lbs_open_']               = array();
      $this->field_config['lbs_open_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs_open_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs_open_']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['lbs_open_']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs_open_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- cost_lb_g_
      $this->field_config['cost_lb_g_']               = array();
      $this->field_config['cost_lb_g_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['cost_lb_g_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['cost_lb_g_']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['cost_lb_g_']['symbol_mon'] = '';
      $this->field_config['cost_lb_g_']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['cost_lb_g_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- total_cost_
      $this->field_config['total_cost_']               = array();
      $this->field_config['total_cost_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['total_cost_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['total_cost_']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['total_cost_']['symbol_mon'] = '';
      $this->field_config['total_cost_']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['total_cost_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- adate_
      $this->field_config['adate_']                 = array();
      $this->field_config['adate_']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['adate_']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['adate_']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'adate_');
      //-- edate_
      $this->field_config['edate_']                 = array();
      $this->field_config['edate_']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['edate_']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['edate_']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'edate_');
      //-- ddate_
      $this->field_config['ddate_']                 = array();
      $this->field_config['ddate_']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['ddate_']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['ddate_']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'ddate_');
      //-- sdate_
      $this->field_config['sdate_']                 = array();
      $this->field_config['sdate_']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['sdate_']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['sdate_']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'sdate_');
      //-- defects_
      $this->field_config['defects_']               = array();
      $this->field_config['defects_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['defects_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['defects_']['symbol_dec'] = '';
      $this->field_config['defects_']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['defects_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- rpd_
      $this->field_config['rpd_']               = array();
      $this->field_config['rpd_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['rpd_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['rpd_']['symbol_dec'] = '';
      $this->field_config['rpd_']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['rpd_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- id2_
      $this->field_config['id2_']               = array();
      $this->field_config['id2_']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['id2_']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['id2_']['symbol_dec'] = '';
      $this->field_config['id2_']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['id2_']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
   }

   function controle()
   {
        global $nm_url_saida, $teste_validade, 
               $GLOBALS, $Campos_Crit, $Campos_Falta, $Campos_Erros, $sc_seq_vert, $sc_check_incl, 
               $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 ($this->nmgp_opcao == "change_qtd_line")
      {
          $this->nmgp_opcao = "igual";
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_max_reg'] = $this->nmgp_max_line;
      }
      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();
          $this->nm_converte_datas();

          $_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'] = '';
      }

      $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]['dye_grpcs_edit_grid']['opc_edit'] = true;  
      $sc_contr_vert = $GLOBALS["sc_contr_vert"];
      $sc_seq_vert   = 1; 
      $sc_opc_salva  = $this->nmgp_opcao; 
      $sc_todas_Crit = "";
      $sc_check_excl = array(); 
      $sc_check_incl = array(); 
      if (is_array($GLOBALS["sc_check_vert"])) 
      { 
          if ($this->nmgp_opcao == "incluir" || ($this->nmgp_opcao == "recarga" && $this->nmgp_opc_ant == "novo"))
          {
              $sc_check_incl = $GLOBALS["sc_check_vert"]; 
          }
          elseif ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "excluir" || $this->nmgp_opcao == "recarga")
          {
              $sc_check_excl = $GLOBALS["sc_check_vert"]; 
          }
      } 
      elseif ($this->nmgp_opcao == 'incluir' && isset($_POST['upload_file_row']) && '' != $_POST['upload_file_row'])
      {
          $sc_check_incl = array($_POST['upload_file_row']);
      }
      if (empty($this->nmgp_opcao)) 
      { 
          $this->nmgp_opcao = "inicio";
      } 
      if ($this->NM_ajax_flag && 'add_new_line' == $this->NM_ajax_opcao)
      {
         $this->nmgp_opcao = "novo";
         $this->nm_select_banco();
         $this->nm_gera_html();
         $this->NM_ajax_info['newline'] = dye_grpcs_edit_grid_pack_protect_string(NM_charset_to_utf8($this->New_Line));
         $this->NM_close_db();
         dye_grpcs_edit_grid_pack_ajax_response();
         exit;
      }
      if ($this->NM_ajax_flag && 'backup_line' == $this->NM_ajax_opcao)
      {
         $this->nmgp_opcao = "igual";
         $this->nm_tira_formatacao();
         $this->nm_converte_datas();
         $this->nm_select_banco();
         $this->ajax_return_values();
         $this->NM_close_db();
         dye_grpcs_edit_grid_pack_ajax_response();
         exit;
      }
      if ($this->NM_ajax_flag && 'submit_form' == $this->NM_ajax_opcao)
      {
         if (isset($this->p_o_number_)) { $this->nm_limpa_alfa($this->p_o_number_); }
         if (isset($this->style_)) { $this->nm_limpa_alfa($this->style_); }
         if (isset($this->invoice_)) { $this->nm_limpa_alfa($this->invoice_); }
         if (isset($this->case_)) { $this->nm_limpa_alfa($this->case_); }
         if (isset($this->piece_)) { $this->nm_limpa_alfa($this->piece_); }
         if (isset($this->racks_)) { $this->nm_limpa_alfa($this->racks_); }
         if (isset($this->lbs_recd_)) { $this->nm_limpa_alfa($this->lbs_recd_); }
         if (isset($this->lbs_used_)) { $this->nm_limpa_alfa($this->lbs_used_); }
         if (isset($this->lbs_open_)) { $this->nm_limpa_alfa($this->lbs_open_); }
         if (isset($this->dye_order_)) { $this->nm_limpa_alfa($this->dye_order_); }
         if (isset($this->cost_lb_g_)) { $this->nm_limpa_alfa($this->cost_lb_g_); }
         if (isset($this->total_cost_)) { $this->nm_limpa_alfa($this->total_cost_); }
         if (isset($this->shipto_)) { $this->nm_limpa_alfa($this->shipto_); }
         if (isset($this->ac_)) { $this->nm_limpa_alfa($this->ac_); }
         if (isset($this->defects_)) { $this->nm_limpa_alfa($this->defects_); }
         if (isset($this->rpd_)) { $this->nm_limpa_alfa($this->rpd_); }
         if (isset($this->id2_)) { $this->nm_limpa_alfa($this->id2_); }
         if (isset($this->Sc_num_lin_alt) && $this->Sc_num_lin_alt > 0) 
         {
             $sc_seq_vert = $this->Sc_num_lin_alt;
         }
         if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'][$sc_seq_vert]))
         {
             $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'][$sc_seq_vert];
             $this->old_po_ = $this->nmgp_dados_form['old_po_']; 
         }
         $this->controle_form_vert();
         if ($Campos_Crit != "" || !empty($Campos_Falta) || $this->Campos_Mens_erro != "")
         {
             $this->NM_rollback_db();
              if ($this->NM_ajax_flag)
              {
                  if (!isset($this->NM_ajax_info['errList']['geral_dye_grpcs_edit_grid']) || !is_array($this->NM_ajax_info['errList']['geral_dye_grpcs_edit_grid']))
                  {
                      $this->NM_ajax_info['errList']['geral_dye_grpcs_edit_grid'] = array();
                  }
                  if ($Campos_Crit != "")
                  {
                      $this->NM_ajax_info['errList']['geral_dye_grpcs_edit_grid'][] = $Campos_Crit;
                  }
                  if (!empty($Campos_Falta))
                  {
                      $this->NM_ajax_info['errList']['geral_dye_grpcs_edit_grid'][] = $this->Formata_Campos_Falta($Campos_Falta);
                  }
                  if ($this->Campos_Mens_erro != "")
                  {
                      $this->NM_ajax_info['errList']['geral_dye_grpcs_edit_grid'][] = $this->Campos_Mens_erro;
                  }
                  $this->NM_gera_nav_page(); 
                  $this->NM_ajax_info['navPage'] = $this->SC_nav_page; 
              }
         }
         else
         {
             $this->NM_commit_db();
         }
         if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form" && !$this->Apl_com_erro)
         {
             $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['recarga'] = $this->nmgp_opcao;
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_insert']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_insert'] == "ok")
          {
              if ($this->sc_teve_incl && empty($sc_todas_Crit))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_atualiz']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_atualiz'] == "ok")
          {
              if ($this->sc_teve_alt && empty($sc_todas_Crit))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
              if ($this->sc_teve_excl && empty($sc_todas_Crit))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
         }
         $this->NM_close_db();
         dye_grpcs_edit_grid_pack_ajax_response();
         exit;
      }
      if ($this->NM_ajax_flag && 'validate_' == substr($this->NM_ajax_opcao, 0, 9))
      {
         $Campos_Crit  = "";
         $Campos_Falta = array();
         $Campos_Erros = array();
          if ('validate_dye_order_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'dye_order_');
          }
          if ('validate_p_o_number_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'p_o_number_');
          }
          if ('validate_style_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'style_');
          }
          if ('validate_invoice_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'invoice_');
          }
          if ('validate_case_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'case_');
          }
          if ('validate_piece_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'piece_');
          }
          if ('validate_racks_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'racks_');
          }
          if ('validate_lbs_recd_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_recd_');
          }
          if ('validate_lbs_used_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_used_');
          }
          if ('validate_lbs_open_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_open_');
          }
          if ('validate_cost_lb_g_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'cost_lb_g_');
          }
          if ('validate_total_cost_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'total_cost_');
          }
          if ('validate_adate_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'adate_');
          }
          if ('validate_edate_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'edate_');
          }
          if ('validate_ddate_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'ddate_');
          }
          if ('validate_shipto_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'shipto_');
          }
          if ('validate_sdate_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'sdate_');
          }
          if ('validate_ac_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'ac_');
          }
          if ('validate_defects_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'defects_');
          }
          if ('validate_rpd_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'rpd_');
          }
          if ('validate_id2_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'id2_');
          }
          dye_grpcs_edit_grid_pack_ajax_response();
          exit;
      }
      while ($sc_contr_vert > $sc_seq_vert) 
      { 
         $Campos_Crit  = "";
         $Campos_Falta = array();
         $Campos_Erros = array();
         $this->dye_order_ = $GLOBALS["dye_order_" . $sc_seq_vert]; 
         $this->p_o_number_ = $GLOBALS["p_o_number_" . $sc_seq_vert]; 
         $this->style_ = $GLOBALS["style_" . $sc_seq_vert]; 
         $this->invoice_ = $GLOBALS["invoice_" . $sc_seq_vert]; 
         $this->case_ = $GLOBALS["case_" . $sc_seq_vert]; 
         $this->piece_ = $GLOBALS["piece_" . $sc_seq_vert]; 
         $this->racks_ = $GLOBALS["racks_" . $sc_seq_vert]; 
         $this->lbs_recd_ = $GLOBALS["lbs_recd_" . $sc_seq_vert]; 
         $this->lbs_used_ = $GLOBALS["lbs_used_" . $sc_seq_vert]; 
         $this->lbs_open_ = $GLOBALS["lbs_open_" . $sc_seq_vert]; 
         $this->cost_lb_g_ = $GLOBALS["cost_lb_g_" . $sc_seq_vert]; 
         $this->total_cost_ = $GLOBALS["total_cost_" . $sc_seq_vert]; 
         $this->adate_ = $GLOBALS["adate_" . $sc_seq_vert]; 
         $this->edate_ = $GLOBALS["edate_" . $sc_seq_vert]; 
         $this->ddate_ = $GLOBALS["ddate_" . $sc_seq_vert]; 
         $this->shipto_ = $GLOBALS["shipto_" . $sc_seq_vert]; 
         $this->sdate_ = $GLOBALS["sdate_" . $sc_seq_vert]; 
         $this->ac_ = $GLOBALS["ac_" . $sc_seq_vert]; 
         $this->defects_ = $GLOBALS["defects_" . $sc_seq_vert]; 
         $this->rpd_ = $GLOBALS["rpd_" . $sc_seq_vert]; 
         $this->id2_ = $GLOBALS["id2_" . $sc_seq_vert]; 
         if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'][$sc_seq_vert]))
         {
             $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'][$sc_seq_vert];
             $this->old_po_ = $this->nmgp_dados_form['old_po_']; 
         }
         if (isset($this->p_o_number_)) { $this->nm_limpa_alfa($this->p_o_number_); }
         if (isset($this->style_)) { $this->nm_limpa_alfa($this->style_); }
         if (isset($this->invoice_)) { $this->nm_limpa_alfa($this->invoice_); }
         if (isset($this->case_)) { $this->nm_limpa_alfa($this->case_); }
         if (isset($this->piece_)) { $this->nm_limpa_alfa($this->piece_); }
         if (isset($this->racks_)) { $this->nm_limpa_alfa($this->racks_); }
         if (isset($this->lbs_recd_)) { $this->nm_limpa_alfa($this->lbs_recd_); }
         if (isset($this->lbs_used_)) { $this->nm_limpa_alfa($this->lbs_used_); }
         if (isset($this->lbs_open_)) { $this->nm_limpa_alfa($this->lbs_open_); }
         if (isset($this->dye_order_)) { $this->nm_limpa_alfa($this->dye_order_); }
         if (isset($this->cost_lb_g_)) { $this->nm_limpa_alfa($this->cost_lb_g_); }
         if (isset($this->total_cost_)) { $this->nm_limpa_alfa($this->total_cost_); }
         if (isset($this->shipto_)) { $this->nm_limpa_alfa($this->shipto_); }
         if (isset($this->ac_)) { $this->nm_limpa_alfa($this->ac_); }
         if (isset($this->defects_)) { $this->nm_limpa_alfa($this->defects_); }
         if (isset($this->rpd_)) { $this->nm_limpa_alfa($this->rpd_); }
         if (isset($this->id2_)) { $this->nm_limpa_alfa($this->id2_); }
         if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'])) 
         {
            $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'][$sc_seq_vert];
         }
         if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'])) 
         {
            $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert];
         }
         if ($this->nmgp_opcao != "recarga" && in_array($sc_seq_vert, $sc_check_excl))
         {
             $this->nmgp_opcao = "excluir";
         }
         if ($this->nmgp_opcao == "incluir" && !in_array($sc_seq_vert, $sc_check_incl))
         { }
         else
         {
             $this->controle_form_vert(); 
             $this->nmgp_opcao = $sc_opc_salva; 
             if ($this->nmgp_opcao != "recarga"  && $this->nmgp_opcao != "muda_form" && ($Campos_Crit != "" || !empty($Campos_Falta) || $this->Campos_Mens_erro != ""))
             {
                 $sc_todas_Crit .= (!empty($sc_todas_Crit)) ? "<br>" : ""; 
                 $sc_todas_Crit .= "<B>" . $this->Ini->Nm_lang['lang_errm_line'] . $sc_seq_vert . "</B>: "; 
                 $sc_todas_Crit .= $this->Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros);
                 $this->Campos_Mens_erro = ""; 
             }
             if ($this->nmgp_opcao != "recarga") 
             {
                $this->nm_guardar_campos();
                $this->nm_formatar_campos();
             }
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['dye_order_'] =  $this->dye_order_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['p_o_number_'] =  $this->p_o_number_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['style_'] =  $this->style_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['invoice_'] =  $this->invoice_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['case_'] =  $this->case_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['piece_'] =  $this->piece_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['racks_'] =  $this->racks_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_recd_'] =  $this->lbs_recd_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_used_'] =  $this->lbs_used_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_open_'] =  $this->lbs_open_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['cost_lb_g_'] =  $this->cost_lb_g_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['total_cost_'] =  $this->total_cost_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['adate_'] =  $this->adate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['edate_'] =  $this->edate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['ddate_'] =  $this->ddate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['shipto_'] =  $this->shipto_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['sdate_'] =  $this->sdate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['ac_'] =  $this->ac_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['defects_'] =  $this->defects_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['rpd_'] =  $this->rpd_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['id2_'] =  $this->id2_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['old_po_'] =  $this->old_po_; 
         }
         $sc_seq_vert++; 
      } 
      if (!empty($sc_todas_Crit)) 
      { 
          $this->Erro->mensagem(__FILE__, __LINE__, "critica", $sc_todas_Crit); 
          if ($this->nmgp_opcao == "incluir")
          { 
              $this->nmgp_opcao = "novo"; 
          }
      } 
      elseif ($this->nmgp_opcao == "incluir")
      { 
          $this->nmgp_opcao = "novo"; 
      }
      if ($this->nmgp_opcao == 'incluir' && isset($_POST['upload_file_row']) && '' != $_POST['upload_file_row'])
      {
          $this->nmgp_opcao = 'igual';
      }
      if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form") 
      { 
          if ($this->sc_teve_incl) 
          { 
              $this->sc_after_all_insert = true;
          }
          if ($this->sc_teve_alt || $this->sc_teve_excl) 
          { 
              $this->sc_after_all_update = true;
          }
          if (empty($sc_todas_Crit)) 
          { 
              $this->NM_commit_db(); 
              $this->nm_select_banco();
              $sc_check_excl = array(); 
          } 
          else
          { 
              $this->NM_rollback_db(); 
          } 
      } 
      if ($this->nmgp_opcao == "recarga") 
      { 
          $this->NM_gera_nav_page(); 
      } 
      if ($this->NM_ajax_flag && ('navigate_form' == $this->NM_ajax_opcao || !empty($this->nmgp_refresh_fields)))
      {
          $this->ajax_return_values();
          $this->ajax_add_parameters();
          $this->NM_close_db();
          dye_grpcs_edit_grid_pack_ajax_response();
          exit;
      }
      if ($this->NM_ajax_flag && 'table_refresh' == $this->NM_ajax_opcao)
      {
          $this->nm_gera_html();
          $this->NM_ajax_info['tableRefresh'] = NM_charset_to_utf8($this->Table_refresh . $this->New_Line) . '</table>';
          $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['rsSize'] = sizeof($this->form_vert_dye_grpcs_edit_grid);
          $this->NM_ajax_info['fldList']['id2_']['keyVal'] = htmlentities($this->nmgp_dados_form['id2_'], ENT_COMPAT, $_SESSION['scriptcase']['charset']);
          $this->NM_close_db();
          dye_grpcs_edit_grid_pack_ajax_response();
          exit;
      }
      if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form" && !$this->Apl_com_erro)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['recarga'] = $this->nmgp_opcao;
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_insert']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_insert'] == "ok")
          {
              if ($this->sc_teve_incl && empty($sc_todas_Crit))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_atualiz']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_atualiz'] == "ok")
          {
              if ($this->sc_teve_alt && empty($sc_todas_Crit))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
              if ($this->sc_teve_excl && empty($sc_todas_Crit))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
      }
      $this->nm_todas_criticas = $sc_todas_Crit;
      $this->nm_gera_html();
      $this->NM_close_db(); 
   }
   function controle_form_vert()
   {
     global $nm_opc_lookup,$Campos_Crit, $Campos_Falta, $Campos_Erros, 
            $glo_senha_protect, $nm_apl_dependente, $nm_form_submit;

//
//-----> 
//
      if (isset($this->sc_inline_call) && 'Y' == $this->sc_inline_call)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['inline_form_seq'] = $this->sc_seq_row;
          $this->nm_tira_formatacao();
          $this->nm_converte_datas();
      }
      if ($this->nmgp_opcao == "recarga" || $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();
              dye_grpcs_edit_grid_pack_ajax_response();
              exit;
          }
          $this->nm_formatar_campos();
          $this->nmgp_opcao = $nm_sc_sv_opcao; 
          return; 
      }
      if ($this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "excluir") 
      {
          $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $_SESSION['scriptcase']['dye_grpcs_edit_grid']['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 != "")
          {
              $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) && $this->nmgp_opcao != "menu_link")
      {
      }
//
      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();
           }
      }
   }
//
//--------------------------------------------------------------------------------------
   function NM_has_trans()
   {
       return !in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access);
   }
//
//--------------------------------------------------------------------------------------
   function NM_commit_db()
   {
       if ($this->Ini->sc_tem_trans_banco && !$this->Embutida_proc)
       { 
           $this->Db->CommitTrans(); 
           $this->Ini->sc_tem_trans_banco = false;
       } 
   }
//
//--------------------------------------------------------------------------------------
   function NM_rollback_db()
   {
       if ($this->Ini->sc_tem_trans_banco && !$this->Embutida_proc)
       { 
           $this->Db->RollbackTrans(); 
           $this->Ini->sc_tem_trans_banco = false;
       } 
   }
//
//--------------------------------------------------------------------------------------
   function NM_close_db()
   {
       if ($this->Db && !$this->Embutida_proc)
       { 
           $this->Db->Close(); 
       } 
   }
   function sc_btn_sc_btn_0() 
   {
        global $nm_url_saida, $teste_validade, 
               $GLOBALS, $Campos_Crit, $Campos_Falta, $Campos_Erros, $sc_seq_vert, $sc_check_incl, 
               $glo_senha_protect, $nm_apl_dependente, $nm_form_submit, $sc_check_excl, $nm_opc_form_php, $nm_call_php, $nm_opc_lookup;
 
?>
<!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'] ?>" />
    <SCRIPT type="text/javascript">
      var sc_pathToTB = '<?php echo $this->Ini->path_prod ?>/third/jquery_plugin/thickbox/';
    </SCRIPT>
    <SCRIPT type="text/javascript" src="<?php echo $this->Ini->path_prod; ?>/third/jquery/js/jquery.js"></SCRIPT>
    <SCRIPT type="text/javascript" src="<?php echo $this->Ini->path_prod; ?>/third/jquery_plugin/malsup-blockui/jquery.blockUI.js"></SCRIPT>
    <SCRIPT type="text/javascript" src="<?php echo $this->Ini->path_prod; ?>/third/jquery_plugin/thickbox/thickbox-compressed.js"></SCRIPT>
    <link rel="stylesheet" href="<?php echo $this->Ini->path_prod ?>/third/jquery_plugin/thickbox/thickbox.css" type="text/css" media="screen" />
    <link rel="stylesheet" type="text/css" href="../_lib/css/<?php echo $this->Ini->str_schema_all ?>_form.css" />
 </head>
  <body class="scFormPage">
      <table class="scFormTabela" align="center"><tr><td>
<?php
      $nmgp_opcao_saida_php = "igual";
      $nmgp_opc_ant_saida_php = "";
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opc_ant'] == "novo" || $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opc_ant'] == "incluir")
      {
          $nmgp_opc_ant_saida_php = "novo";
          $nmgp_opcao_saida_php   = "recarga";
      }
      $nm_f_saida = "./";
      if (!empty($this->field_config['lbs_recd_']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_recd_, $this->field_config['lbs_recd_']['symbol_dec'], $this->field_config['lbs_recd_']['symbol_grp']) ; 
      }
      if (!empty($this->field_config['lbs_used_']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_used_, $this->field_config['lbs_used_']['symbol_dec'], $this->field_config['lbs_used_']['symbol_grp']) ; 
      }
      if (!empty($this->field_config['lbs_open_']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_open_, $this->field_config['lbs_open_']['symbol_dec'], $this->field_config['lbs_open_']['symbol_grp']) ; 
      }
      if (!empty($this->field_config['cost_lb_g_']['symbol_dec']))
      {
          $this->sc_remove_currency($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp'], $this->field_config['cost_lb_g_']['symbol_mon']); 
          nm_limpa_valor($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp']) ; 
      }
      if (!empty($this->field_config['total_cost_']['symbol_dec']))
      {
          $this->sc_remove_currency($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp'], $this->field_config['total_cost_']['symbol_mon']); 
          nm_limpa_valor($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp']) ; 
      }
      nm_limpa_data($this->adate_, $this->field_config['adate_']['date_sep']) ; 
      nm_limpa_data($this->edate_, $this->field_config['edate_']['date_sep']) ; 
      nm_limpa_data($this->ddate_, $this->field_config['ddate_']['date_sep']) ; 
      nm_limpa_data($this->sdate_, $this->field_config['sdate_']['date_sep']) ; 
      nm_limpa_numero($this->defects_, $this->field_config['defects_']['symbol_grp']) ; 
      nm_limpa_numero($this->rpd_, $this->field_config['rpd_']['symbol_grp']) ; 
      nm_limpa_numero($this->id2_, $this->field_config['id2_']['symbol_grp']) ; 
      $this->nm_converte_datas();
      $_SESSION['scriptcase']['dye_grpcs_edit_grid']['contr_erro'] = 'on';
 
$update_sql = "ALTER TABLE grpcs ADD ID2 INT PRIMARY KEY AUTO_INCREMENT";

     $nm_select = $update_sql; 
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select;
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
         $rf = $this->Db->Execute($nm_select);
         if ($rf === false)
         {
             $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
             $this->NM_rollback_db(); 
             if ($this->NM_ajax_flag)
             {
                dye_grpcs_edit_grid_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      ;
$_SESSION['scriptcase']['dye_grpcs_edit_grid']['contr_erro'] = 'off'; 
?>
      </td></tr><tr><td align="center">
      <form name="FPHP" method="post" 
                        action="<?php echo $nm_f_saida ?>" 
                        target="_self">
      <input type=hidden name="nmgp_opcao" value=""/>
      <input type=hidden name="script_case_init" value="<?php  echo NM_encode_input($this->Ini->sc_page); ?>"/>
      <input type=hidden name="script_case_session" value="<?php  echo NM_encode_input(session_id()); ?>"/>
      <input type=hidden name="id2_" value="<?php echo NM_encode_input($this->id2_) ?>"/>
      <input type=hidden name="nmgp_opcao" value="<?php echo NM_encode_input($nmgp_opcao_saida_php); ?>"/>
      <input type=hidden name="nmgp_opc_ant" value="<?php echo NM_encode_input($nmgp_opc_ant_saida_php); ?>"/>
      <input type=submit name="nmgp_bok" value="<?php echo $this->Ini->Nm_lang['lang_btns_cfrm'] ?>"/>
      </form>
      </td></tr></table>
      </body>
      </html>
<?php
   }
//
//--------------------------------------------------------------------------------------
   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 'dye_order_':
               return "DYE ORDER";
               break;
           case 'p_o_number_':
               return "P O NUMBER";
               break;
           case 'style_':
               return "STYLE";
               break;
           case 'invoice_':
               return "INVOICE";
               break;
           case 'case_':
               return "CASE";
               break;
           case 'piece_':
               return "PIECE";
               break;
           case 'racks_':
               return "RACKS";
               break;
           case 'lbs_recd_':
               return "LBS RECD";
               break;
           case 'lbs_used_':
               return "LBS USED";
               break;
           case 'lbs_open_':
               return "LBS OPEN";
               break;
           case 'cost_lb_g_':
               return "COST LB G";
               break;
           case 'total_cost_':
               return "TOTAL COST";
               break;
           case 'adate_':
               return "ADATE";
               break;
           case 'edate_':
               return "EDATE";
               break;
           case 'ddate_':
               return "DDATE";
               break;
           case 'shipto_':
               return "SHIPTO";
               break;
           case 'sdate_':
               return "SDATE";
               break;
           case 'ac_':
               return "AC";
               break;
           case 'defects_':
               return "DEFECTS";
               break;
           case 'rpd_':
               return "RPD";
               break;
           case 'id2_':
               return "ID2";
               break;
           case 'old_po_':
               return "OLD PO";
               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 || 'dye_order_' == $filtro)
        $this->ValidateField_dye_order_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'p_o_number_' == $filtro)
        $this->ValidateField_p_o_number_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'style_' == $filtro)
        $this->ValidateField_style_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'invoice_' == $filtro)
        $this->ValidateField_invoice_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'case_' == $filtro)
        $this->ValidateField_case_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'piece_' == $filtro)
        $this->ValidateField_piece_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'racks_' == $filtro)
        $this->ValidateField_racks_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_recd_' == $filtro)
        $this->ValidateField_lbs_recd_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_used_' == $filtro)
        $this->ValidateField_lbs_used_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_open_' == $filtro)
        $this->ValidateField_lbs_open_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'cost_lb_g_' == $filtro)
        $this->ValidateField_cost_lb_g_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'total_cost_' == $filtro)
        $this->ValidateField_total_cost_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'adate_' == $filtro)
        $this->ValidateField_adate_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'edate_' == $filtro)
        $this->ValidateField_edate_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'ddate_' == $filtro)
        $this->ValidateField_ddate_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'shipto_' == $filtro)
        $this->ValidateField_shipto_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'sdate_' == $filtro)
        $this->ValidateField_sdate_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'ac_' == $filtro)
        $this->ValidateField_ac_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'defects_' == $filtro)
        $this->ValidateField_defects_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'rpd_' == $filtro)
        $this->ValidateField_rpd_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'id2_' == $filtro)
        $this->ValidateField_id2_($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_dye_order_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->dye_order_) > 5) 
          { 
              $Campos_Crit .= "DYE ORDER " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 5 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['dye_order_']))
              {
                  $Campos_Erros['dye_order_'] = array();
              }
              $Campos_Erros['dye_order_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 5 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['dye_order_']) || !is_array($this->NM_ajax_info['errList']['dye_order_']))
              {
                  $this->NM_ajax_info['errList']['dye_order_'] = array();
              }
              $this->NM_ajax_info['errList']['dye_order_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 5 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_dye_order_

    function ValidateField_p_o_number_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->p_o_number_) > 5) 
          { 
              $Campos_Crit .= "P O NUMBER " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 5 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['p_o_number_']))
              {
                  $Campos_Erros['p_o_number_'] = array();
              }
              $Campos_Erros['p_o_number_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 5 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['p_o_number_']) || !is_array($this->NM_ajax_info['errList']['p_o_number_']))
              {
                  $this->NM_ajax_info['errList']['p_o_number_'] = array();
              }
              $this->NM_ajax_info['errList']['p_o_number_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 5 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_p_o_number_

    function ValidateField_style_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->style_) > 14) 
          { 
              $Campos_Crit .= "STYLE " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 14 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['style_']))
              {
                  $Campos_Erros['style_'] = array();
              }
              $Campos_Erros['style_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 14 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['style_']) || !is_array($this->NM_ajax_info['errList']['style_']))
              {
                  $this->NM_ajax_info['errList']['style_'] = array();
              }
              $this->NM_ajax_info['errList']['style_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 14 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_style_

    function ValidateField_invoice_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->invoice_) > 8) 
          { 
              $Campos_Crit .= "INVOICE " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 8 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['invoice_']))
              {
                  $Campos_Erros['invoice_'] = array();
              }
              $Campos_Erros['invoice_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 8 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['invoice_']) || !is_array($this->NM_ajax_info['errList']['invoice_']))
              {
                  $this->NM_ajax_info['errList']['invoice_'] = array();
              }
              $this->NM_ajax_info['errList']['invoice_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 8 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_invoice_

    function ValidateField_case_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->case_) > 11) 
          { 
              $Campos_Crit .= "CASE " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 11 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['case_']))
              {
                  $Campos_Erros['case_'] = array();
              }
              $Campos_Erros['case_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 11 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['case_']) || !is_array($this->NM_ajax_info['errList']['case_']))
              {
                  $this->NM_ajax_info['errList']['case_'] = array();
              }
              $this->NM_ajax_info['errList']['case_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 11 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_case_

    function ValidateField_piece_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->piece_) > 11) 
          { 
              $Campos_Crit .= "PIECE " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 11 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['piece_']))
              {
                  $Campos_Erros['piece_'] = array();
              }
              $Campos_Erros['piece_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 11 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['piece_']) || !is_array($this->NM_ajax_info['errList']['piece_']))
              {
                  $this->NM_ajax_info['errList']['piece_'] = array();
              }
              $this->NM_ajax_info['errList']['piece_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 11 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_piece_

    function ValidateField_racks_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->racks_) > 4) 
          { 
              $Campos_Crit .= "RACKS " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['racks_']))
              {
                  $Campos_Erros['racks_'] = array();
              }
              $Campos_Erros['racks_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['racks_']) || !is_array($this->NM_ajax_info['errList']['racks_']))
              {
                  $this->NM_ajax_info['errList']['racks_'] = array();
              }
              $this->NM_ajax_info['errList']['racks_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_racks_

    function ValidateField_lbs_recd_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->lbs_recd_ == "")  
      { 
          $this->lbs_recd_ = 0;
          $this->sc_force_zero[] = 'lbs_recd_';
      } 
      if (!empty($this->field_config['lbs_recd_']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_recd_, $this->field_config['lbs_recd_']['symbol_dec'], $this->field_config['lbs_recd_']['symbol_grp']) ; 
          if ('.' == substr($this->lbs_recd_, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->lbs_recd_, 1)))
              {
                  $this->lbs_recd_ = '';
              }
              else
              {
                  $this->lbs_recd_ = '0' . $this->lbs_recd_;
              }
          }
      }
      if ($this->nmgp_opcao == "incluir")
      { 
          if ($this->lbs_recd_ != '')  
          { 
              $iTestSize = 10;
              if (strlen($this->lbs_recd_) > $iTestSize)  
              { 
                  $Campos_Crit .= "LBS RECD: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['lbs_recd_']))
                  {
                      $Campos_Erros['lbs_recd_'] = array();
                  }
                  $Campos_Erros['lbs_recd_'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['lbs_recd_']) || !is_array($this->NM_ajax_info['errList']['lbs_recd_']))
                  {
                      $this->NM_ajax_info['errList']['lbs_recd_'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_recd_'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->lbs_recd_, 7, 2, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "LBS RECD; " ; 
                  if (!isset($Campos_Erros['lbs_recd_']))
                  {
                      $Campos_Erros['lbs_recd_'] = array();
                  }
                  $Campos_Erros['lbs_recd_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['lbs_recd_']) || !is_array($this->NM_ajax_info['errList']['lbs_recd_']))
                  {
                      $this->NM_ajax_info['errList']['lbs_recd_'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_recd_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_lbs_recd_

    function ValidateField_lbs_used_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->lbs_used_ == "")  
      { 
          $this->lbs_used_ = 0;
          $this->sc_force_zero[] = 'lbs_used_';
      } 
      if (!empty($this->field_config['lbs_used_']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_used_, $this->field_config['lbs_used_']['symbol_dec'], $this->field_config['lbs_used_']['symbol_grp']) ; 
          if ('.' == substr($this->lbs_used_, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->lbs_used_, 1)))
              {
                  $this->lbs_used_ = '';
              }
              else
              {
                  $this->lbs_used_ = '0' . $this->lbs_used_;
              }
          }
      }
      if ($this->nmgp_opcao == "incluir")
      { 
          if ($this->lbs_used_ != '')  
          { 
              $iTestSize = 10;
              if (strlen($this->lbs_used_) > $iTestSize)  
              { 
                  $Campos_Crit .= "LBS USED: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['lbs_used_']))
                  {
                      $Campos_Erros['lbs_used_'] = array();
                  }
                  $Campos_Erros['lbs_used_'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['lbs_used_']) || !is_array($this->NM_ajax_info['errList']['lbs_used_']))
                  {
                      $this->NM_ajax_info['errList']['lbs_used_'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_used_'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->lbs_used_, 7, 2, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "LBS USED; " ; 
                  if (!isset($Campos_Erros['lbs_used_']))
                  {
                      $Campos_Erros['lbs_used_'] = array();
                  }
                  $Campos_Erros['lbs_used_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['lbs_used_']) || !is_array($this->NM_ajax_info['errList']['lbs_used_']))
                  {
                      $this->NM_ajax_info['errList']['lbs_used_'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_used_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_lbs_used_

    function ValidateField_lbs_open_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->lbs_open_ == "")  
      { 
          $this->lbs_open_ = 0;
          $this->sc_force_zero[] = 'lbs_open_';
      } 
      if (!empty($this->field_config['lbs_open_']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_open_, $this->field_config['lbs_open_']['symbol_dec'], $this->field_config['lbs_open_']['symbol_grp']) ; 
          if ('.' == substr($this->lbs_open_, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->lbs_open_, 1)))
              {
                  $this->lbs_open_ = '';
              }
              else
              {
                  $this->lbs_open_ = '0' . $this->lbs_open_;
              }
          }
      }
      if ($this->nmgp_opcao == "incluir")
      { 
          if ($this->lbs_open_ != '')  
          { 
              $iTestSize = 10;
              if (strlen($this->lbs_open_) > $iTestSize)  
              { 
                  $Campos_Crit .= "LBS OPEN: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['lbs_open_']))
                  {
                      $Campos_Erros['lbs_open_'] = array();
                  }
                  $Campos_Erros['lbs_open_'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['lbs_open_']) || !is_array($this->NM_ajax_info['errList']['lbs_open_']))
                  {
                      $this->NM_ajax_info['errList']['lbs_open_'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_open_'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->lbs_open_, 7, 2, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "LBS OPEN; " ; 
                  if (!isset($Campos_Erros['lbs_open_']))
                  {
                      $Campos_Erros['lbs_open_'] = array();
                  }
                  $Campos_Erros['lbs_open_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['lbs_open_']) || !is_array($this->NM_ajax_info['errList']['lbs_open_']))
                  {
                      $this->NM_ajax_info['errList']['lbs_open_'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_open_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_lbs_open_

    function ValidateField_cost_lb_g_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->cost_lb_g_ == "")  
      { 
          $this->cost_lb_g_ = 0;
          $this->sc_force_zero[] = 'cost_lb_g_';
      } 
      if (!empty($this->field_config['cost_lb_g_']['symbol_dec']))
      {
          $this->sc_remove_currency($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp'], $this->field_config['cost_lb_g_']['symbol_mon']); 
          nm_limpa_valor($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp']) ; 
          if ('.' == substr($this->cost_lb_g_, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->cost_lb_g_, 1)))
              {
                  $this->cost_lb_g_ = '';
              }
              else
              {
                  $this->cost_lb_g_ = '0' . $this->cost_lb_g_;
              }
          }
      }
      if ($this->nmgp_opcao == "incluir")
      { 
          if ($this->cost_lb_g_ != '')  
          { 
              $iTestSize = 8;
              if (strlen($this->cost_lb_g_) > $iTestSize)  
              { 
                  $Campos_Crit .= "COST LB G: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['cost_lb_g_']))
                  {
                      $Campos_Erros['cost_lb_g_'] = array();
                  }
                  $Campos_Erros['cost_lb_g_'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['cost_lb_g_']) || !is_array($this->NM_ajax_info['errList']['cost_lb_g_']))
                  {
                      $this->NM_ajax_info['errList']['cost_lb_g_'] = array();
                  }
                  $this->NM_ajax_info['errList']['cost_lb_g_'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->cost_lb_g_, 5, 2, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "COST LB G; " ; 
                  if (!isset($Campos_Erros['cost_lb_g_']))
                  {
                      $Campos_Erros['cost_lb_g_'] = array();
                  }
                  $Campos_Erros['cost_lb_g_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['cost_lb_g_']) || !is_array($this->NM_ajax_info['errList']['cost_lb_g_']))
                  {
                      $this->NM_ajax_info['errList']['cost_lb_g_'] = array();
                  }
                  $this->NM_ajax_info['errList']['cost_lb_g_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_cost_lb_g_

    function ValidateField_total_cost_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->total_cost_ == "")  
      { 
          $this->total_cost_ = 0;
          $this->sc_force_zero[] = 'total_cost_';
      } 
      if (!empty($this->field_config['total_cost_']['symbol_dec']))
      {
          $this->sc_remove_currency($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp'], $this->field_config['total_cost_']['symbol_mon']); 
          nm_limpa_valor($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp']) ; 
          if ('.' == substr($this->total_cost_, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->total_cost_, 1)))
              {
                  $this->total_cost_ = '';
              }
              else
              {
                  $this->total_cost_ = '0' . $this->total_cost_;
              }
          }
      }
      if ($this->nmgp_opcao == "incluir")
      { 
          if ($this->total_cost_ != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->total_cost_) > $iTestSize)  
              { 
                  $Campos_Crit .= "TOTAL COST: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['total_cost_']))
                  {
                      $Campos_Erros['total_cost_'] = array();
                  }
                  $Campos_Erros['total_cost_'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['total_cost_']) || !is_array($this->NM_ajax_info['errList']['total_cost_']))
                  {
                      $this->NM_ajax_info['errList']['total_cost_'] = array();
                  }
                  $this->NM_ajax_info['errList']['total_cost_'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->total_cost_, 8, 2, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "TOTAL COST; " ; 
                  if (!isset($Campos_Erros['total_cost_']))
                  {
                      $Campos_Erros['total_cost_'] = array();
                  }
                  $Campos_Erros['total_cost_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['total_cost_']) || !is_array($this->NM_ajax_info['errList']['total_cost_']))
                  {
                      $this->NM_ajax_info['errList']['total_cost_'] = array();
                  }
                  $this->NM_ajax_info['errList']['total_cost_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_total_cost_

    function ValidateField_adate_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      nm_limpa_data($this->adate_, $this->field_config['adate_']['date_sep']) ; 
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao == "incluir")
      { 
          $guarda_datahora = $this->field_config['adate_']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['adate_']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['adate_']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['adate_']['date_sep']) ; 
          if (trim($this->adate_) != "")  
          { 
              if ($teste_validade->Data($this->adate_, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $Campos_Crit .= "ADATE; " ; 
                  if (!isset($Campos_Erros['adate_']))
                  {
                      $Campos_Erros['adate_'] = array();
                  }
                  $Campos_Erros['adate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['adate_']) || !is_array($this->NM_ajax_info['errList']['adate_']))
                  {
                      $this->NM_ajax_info['errList']['adate_'] = array();
                  }
                  $this->NM_ajax_info['errList']['adate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['adate_']['date_format'] = $guarda_datahora; 
       } 
    } // ValidateField_adate_

    function ValidateField_edate_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      nm_limpa_data($this->edate_, $this->field_config['edate_']['date_sep']) ; 
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao == "incluir")
      { 
          $guarda_datahora = $this->field_config['edate_']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['edate_']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['edate_']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['edate_']['date_sep']) ; 
          if (trim($this->edate_) != "")  
          { 
              if ($teste_validade->Data($this->edate_, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $Campos_Crit .= "EDATE; " ; 
                  if (!isset($Campos_Erros['edate_']))
                  {
                      $Campos_Erros['edate_'] = array();
                  }
                  $Campos_Erros['edate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['edate_']) || !is_array($this->NM_ajax_info['errList']['edate_']))
                  {
                      $this->NM_ajax_info['errList']['edate_'] = array();
                  }
                  $this->NM_ajax_info['errList']['edate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['edate_']['date_format'] = $guarda_datahora; 
       } 
    } // ValidateField_edate_

    function ValidateField_ddate_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      nm_limpa_data($this->ddate_, $this->field_config['ddate_']['date_sep']) ; 
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao == "incluir")
      { 
          $guarda_datahora = $this->field_config['ddate_']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['ddate_']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['ddate_']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['ddate_']['date_sep']) ; 
          if (trim($this->ddate_) != "")  
          { 
              if ($teste_validade->Data($this->ddate_, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $Campos_Crit .= "DDATE; " ; 
                  if (!isset($Campos_Erros['ddate_']))
                  {
                      $Campos_Erros['ddate_'] = array();
                  }
                  $Campos_Erros['ddate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['ddate_']) || !is_array($this->NM_ajax_info['errList']['ddate_']))
                  {
                      $this->NM_ajax_info['errList']['ddate_'] = array();
                  }
                  $this->NM_ajax_info['errList']['ddate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['ddate_']['date_format'] = $guarda_datahora; 
       } 
    } // ValidateField_ddate_

    function ValidateField_shipto_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->shipto_) > 4) 
          { 
              $Campos_Crit .= "SHIPTO " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['shipto_']))
              {
                  $Campos_Erros['shipto_'] = array();
              }
              $Campos_Erros['shipto_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['shipto_']) || !is_array($this->NM_ajax_info['errList']['shipto_']))
              {
                  $this->NM_ajax_info['errList']['shipto_'] = array();
              }
              $this->NM_ajax_info['errList']['shipto_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_shipto_

    function ValidateField_sdate_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      nm_limpa_data($this->sdate_, $this->field_config['sdate_']['date_sep']) ; 
      $trab_dt_min = ""; 
      $trab_dt_max = ""; 
      if ($this->nmgp_opcao == "incluir")
      { 
          $guarda_datahora = $this->field_config['sdate_']['date_format']; 
          if (false !== strpos($guarda_datahora, ';')) $this->field_config['sdate_']['date_format'] = substr($guarda_datahora, 0, strpos($guarda_datahora, ';'));
          $Format_Data = $this->field_config['sdate_']['date_format']; 
          nm_limpa_data($Format_Data, $this->field_config['sdate_']['date_sep']) ; 
          if (trim($this->sdate_) != "")  
          { 
              if ($teste_validade->Data($this->sdate_, $Format_Data, $trab_dt_min, $trab_dt_max) == false)  
              { 
                  $Campos_Crit .= "SDATE; " ; 
                  if (!isset($Campos_Erros['sdate_']))
                  {
                      $Campos_Erros['sdate_'] = array();
                  }
                  $Campos_Erros['sdate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['sdate_']) || !is_array($this->NM_ajax_info['errList']['sdate_']))
                  {
                      $this->NM_ajax_info['errList']['sdate_'] = array();
                  }
                  $this->NM_ajax_info['errList']['sdate_'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
          $this->field_config['sdate_']['date_format'] = $guarda_datahora; 
       } 
    } // ValidateField_sdate_

    function ValidateField_ac_(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao == "incluir")
      { 
          if (NM_utf8_strlen($this->ac_) > 4) 
          { 
              $Campos_Crit .= "AC " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['ac_']))
              {
                  $Campos_Erros['ac_'] = array();
              }
              $Campos_Erros['ac_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['ac_']) || !is_array($this->NM_ajax_info['errList']['ac_']))
              {
                  $this->NM_ajax_info['errList']['ac_'] = array();
              }
              $this->NM_ajax_info['errList']['ac_'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 4 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_ac_

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

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

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

    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['dye_order_'] = $this->dye_order_;
    $this->nmgp_dados_form['p_o_number_'] = $this->p_o_number_;
    $this->nmgp_dados_form['style_'] = $this->style_;
    $this->nmgp_dados_form['invoice_'] = $this->invoice_;
    $this->nmgp_dados_form['case_'] = $this->case_;
    $this->nmgp_dados_form['piece_'] = $this->piece_;
    $this->nmgp_dados_form['racks_'] = $this->racks_;
    $this->nmgp_dados_form['lbs_recd_'] = $this->lbs_recd_;
    $this->nmgp_dados_form['lbs_used_'] = $this->lbs_used_;
    $this->nmgp_dados_form['lbs_open_'] = $this->lbs_open_;
    $this->nmgp_dados_form['cost_lb_g_'] = $this->cost_lb_g_;
    $this->nmgp_dados_form['total_cost_'] = $this->total_cost_;
    $this->nmgp_dados_form['adate_'] = $this->adate_;
    $this->nmgp_dados_form['edate_'] = $this->edate_;
    $this->nmgp_dados_form['ddate_'] = $this->ddate_;
    $this->nmgp_dados_form['shipto_'] = $this->shipto_;
    $this->nmgp_dados_form['sdate_'] = $this->sdate_;
    $this->nmgp_dados_form['ac_'] = $this->ac_;
    $this->nmgp_dados_form['defects_'] = $this->defects_;
    $this->nmgp_dados_form['rpd_'] = $this->rpd_;
    $this->nmgp_dados_form['id2_'] = $this->id2_;
    $this->nmgp_dados_form['old_po_'] = $this->old_po_;
    $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_form'][$sc_seq_vert] = $this->nmgp_dados_form;
   }
   function nm_tira_formatacao()
   {
      global $nm_form_submit;
         $this->formatado = false;
      if (!empty($this->field_config['lbs_recd_']['symbol_dec']))
      {
         nm_limpa_valor($this->lbs_recd_, $this->field_config['lbs_recd_']['symbol_dec'], $this->field_config['lbs_recd_']['symbol_grp']);
      }
      if (!empty($this->field_config['lbs_used_']['symbol_dec']))
      {
         nm_limpa_valor($this->lbs_used_, $this->field_config['lbs_used_']['symbol_dec'], $this->field_config['lbs_used_']['symbol_grp']);
      }
      if (!empty($this->field_config['lbs_open_']['symbol_dec']))
      {
         nm_limpa_valor($this->lbs_open_, $this->field_config['lbs_open_']['symbol_dec'], $this->field_config['lbs_open_']['symbol_grp']);
      }
      if (!empty($this->field_config['cost_lb_g_']['symbol_dec']))
      {
         $this->sc_remove_currency($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp'], $this->field_config['cost_lb_g_']['symbol_mon']);
         nm_limpa_valor($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp']);
      }
      if (!empty($this->field_config['total_cost_']['symbol_dec']))
      {
         $this->sc_remove_currency($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp'], $this->field_config['total_cost_']['symbol_mon']);
         nm_limpa_valor($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp']);
      }
      nm_limpa_data($this->adate_, $this->field_config['adate_']['date_sep']) ; 
      nm_limpa_data($this->edate_, $this->field_config['edate_']['date_sep']) ; 
      nm_limpa_data($this->ddate_, $this->field_config['ddate_']['date_sep']) ; 
      nm_limpa_data($this->sdate_, $this->field_config['sdate_']['date_sep']) ; 
      nm_limpa_numero($this->defects_, $this->field_config['defects_']['symbol_grp']) ; 
      nm_limpa_numero($this->rpd_, $this->field_config['rpd_']['symbol_grp']) ; 
      nm_limpa_numero($this->id2_, $this->field_config['id2_']['symbol_grp']) ; 
   }
   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]+);~ei', '', $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 == "lbs_recd_")
      {
          if (!empty($this->field_config['lbs_recd_']['symbol_dec']))
          {
             nm_limpa_valor($this->lbs_recd_, $this->field_config['lbs_recd_']['symbol_dec'], $this->field_config['lbs_recd_']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "lbs_used_")
      {
          if (!empty($this->field_config['lbs_used_']['symbol_dec']))
          {
             nm_limpa_valor($this->lbs_used_, $this->field_config['lbs_used_']['symbol_dec'], $this->field_config['lbs_used_']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "lbs_open_")
      {
          if (!empty($this->field_config['lbs_open_']['symbol_dec']))
          {
             nm_limpa_valor($this->lbs_open_, $this->field_config['lbs_open_']['symbol_dec'], $this->field_config['lbs_open_']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "cost_lb_g_")
      {
          if (!empty($this->field_config['cost_lb_g_']['symbol_dec']))
          {
             $this->sc_remove_currency($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp'], $this->field_config['cost_lb_g_']['symbol_mon']);
             nm_limpa_valor($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_dec'], $this->field_config['cost_lb_g_']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "total_cost_")
      {
          if (!empty($this->field_config['total_cost_']['symbol_dec']))
          {
             $this->sc_remove_currency($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp'], $this->field_config['total_cost_']['symbol_mon']);
             nm_limpa_valor($this->total_cost_, $this->field_config['total_cost_']['symbol_dec'], $this->field_config['total_cost_']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "defects_")
      {
          nm_limpa_numero($this->defects_, $this->field_config['defects_']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "rpd_")
      {
          nm_limpa_numero($this->rpd_, $this->field_config['rpd_']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "id2_")
      {
          nm_limpa_numero($this->id2_, $this->field_config['id2_']['symbol_grp']) ; 
      }
   }
   function nm_formatar_campos($format_fields = array())
   {
      global $nm_form_submit;
      if (!empty($this->lbs_recd_) || (!empty($format_fields) && isset($format_fields['lbs_recd_'])))
      {
          nmgp_Form_Num_Val($this->lbs_recd_, $this->field_config['lbs_recd_']['symbol_grp'], $this->field_config['lbs_recd_']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['lbs_recd_']['symbol_fmt']) ; 
      }
      if (!empty($this->lbs_used_) || (!empty($format_fields) && isset($format_fields['lbs_used_'])))
      {
          nmgp_Form_Num_Val($this->lbs_used_, $this->field_config['lbs_used_']['symbol_grp'], $this->field_config['lbs_used_']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['lbs_used_']['symbol_fmt']) ; 
      }
      if (!empty($this->lbs_open_) || (!empty($format_fields) && isset($format_fields['lbs_open_'])))
      {
          nmgp_Form_Num_Val($this->lbs_open_, $this->field_config['lbs_open_']['symbol_grp'], $this->field_config['lbs_open_']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['lbs_open_']['symbol_fmt']) ; 
      }
      if (!empty($this->cost_lb_g_) || (!empty($format_fields) && isset($format_fields['cost_lb_g_'])))
      {
          nmgp_Form_Num_Val($this->cost_lb_g_, $this->field_config['cost_lb_g_']['symbol_grp'], $this->field_config['cost_lb_g_']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['cost_lb_g_']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['cost_lb_g_']['symbol_mon'];
          $this->sc_add_currency($this->cost_lb_g_, $sMonSymb, $this->field_config['cost_lb_g_']['format_pos']); 
      }
      if (!empty($this->total_cost_) || (!empty($format_fields) && isset($format_fields['total_cost_'])))
      {
          nmgp_Form_Num_Val($this->total_cost_, $this->field_config['total_cost_']['symbol_grp'], $this->field_config['total_cost_']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['total_cost_']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['total_cost_']['symbol_mon'];
          $this->sc_add_currency($this->total_cost_, $sMonSymb, $this->field_config['total_cost_']['format_pos']); 
      }
      if ((!empty($this->adate_) && 'null' != $this->adate_) || (!empty($format_fields) && isset($format_fields['adate_'])))
      {
          nm_volta_data($this->adate_, $this->field_config['adate_']['date_format']) ; 
          nmgp_Form_Datas($this->adate_, $this->field_config['adate_']['date_format'], $this->field_config['adate_']['date_sep']) ;  
      }
      elseif ('null' == $this->adate_ || '' == $this->adate_)
      {
          $this->adate_ = '';
      }
      if ((!empty($this->edate_) && 'null' != $this->edate_) || (!empty($format_fields) && isset($format_fields['edate_'])))
      {
          nm_volta_data($this->edate_, $this->field_config['edate_']['date_format']) ; 
          nmgp_Form_Datas($this->edate_, $this->field_config['edate_']['date_format'], $this->field_config['edate_']['date_sep']) ;  
      }
      elseif ('null' == $this->edate_ || '' == $this->edate_)
      {
          $this->edate_ = '';
      }
      if ((!empty($this->ddate_) && 'null' != $this->ddate_) || (!empty($format_fields) && isset($format_fields['ddate_'])))
      {
          nm_volta_data($this->ddate_, $this->field_config['ddate_']['date_format']) ; 
          nmgp_Form_Datas($this->ddate_, $this->field_config['ddate_']['date_format'], $this->field_config['ddate_']['date_sep']) ;  
      }
      elseif ('null' == $this->ddate_ || '' == $this->ddate_)
      {
          $this->ddate_ = '';
      }
      if ((!empty($this->sdate_) && 'null' != $this->sdate_) || (!empty($format_fields) && isset($format_fields['sdate_'])))
      {
          nm_volta_data($this->sdate_, $this->field_config['sdate_']['date_format']) ; 
          nmgp_Form_Datas($this->sdate_, $this->field_config['sdate_']['date_format'], $this->field_config['sdate_']['date_sep']) ;  
      }
      elseif ('null' == $this->sdate_ || '' == $this->sdate_)
      {
          $this->sdate_ = '';
      }
      if (!empty($this->defects_) || (!empty($format_fields) && isset($format_fields['defects_'])))
      {
          nmgp_Form_Num_Val($this->defects_, $this->field_config['defects_']['symbol_grp'], $this->field_config['defects_']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['defects_']['symbol_fmt']) ; 
      }
      if (!empty($this->rpd_) || (!empty($format_fields) && isset($format_fields['rpd_'])))
      {
          nmgp_Form_Num_Val($this->rpd_, $this->field_config['rpd_']['symbol_grp'], $this->field_config['rpd_']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['rpd_']['symbol_fmt']) ; 
      }
      if (!empty($this->id2_) || (!empty($format_fields) && isset($format_fields['id2_'])))
      {
          nmgp_Form_Num_Val($this->id2_, $this->field_config['id2_']['symbol_grp'], $this->field_config['id2_']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['id2_']['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)
   {
       $guarda_format_hora = $this->field_config['adate_']['date_format'];
      if ($this->adate_ != "")  
      { 
          nm_conv_data($this->adate_, $this->field_config['adate_']['date_format']) ; 
          $this->adate__hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->adate__hora = substr($this->adate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->adate__hora = substr($this->adate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->adate__hora = substr($this->adate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->adate__hora = substr($this->adate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->adate__hora = substr($this->adate__hora, 0, -4);
          }
      } 
      if ($this->adate_ == "" && $use_null)  
      { 
          $this->adate_ = "null" ; 
      } 
       $this->field_config['adate_']['date_format'] = $guarda_format_hora;
       $guarda_format_hora = $this->field_config['edate_']['date_format'];
      if ($this->edate_ != "")  
      { 
          nm_conv_data($this->edate_, $this->field_config['edate_']['date_format']) ; 
          $this->edate__hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->edate__hora = substr($this->edate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->edate__hora = substr($this->edate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->edate__hora = substr($this->edate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->edate__hora = substr($this->edate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->edate__hora = substr($this->edate__hora, 0, -4);
          }
      } 
      if ($this->edate_ == "" && $use_null)  
      { 
          $this->edate_ = "null" ; 
      } 
       $this->field_config['edate_']['date_format'] = $guarda_format_hora;
       $guarda_format_hora = $this->field_config['ddate_']['date_format'];
      if ($this->ddate_ != "")  
      { 
          nm_conv_data($this->ddate_, $this->field_config['ddate_']['date_format']) ; 
          $this->ddate__hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->ddate__hora = substr($this->ddate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->ddate__hora = substr($this->ddate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->ddate__hora = substr($this->ddate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->ddate__hora = substr($this->ddate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->ddate__hora = substr($this->ddate__hora, 0, -4);
          }
      } 
      if ($this->ddate_ == "" && $use_null)  
      { 
          $this->ddate_ = "null" ; 
      } 
       $this->field_config['ddate_']['date_format'] = $guarda_format_hora;
       $guarda_format_hora = $this->field_config['sdate_']['date_format'];
      if ($this->sdate_ != "")  
      { 
          nm_conv_data($this->sdate_, $this->field_config['sdate_']['date_format']) ; 
          $this->sdate__hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->sdate__hora = substr($this->sdate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->sdate__hora = substr($this->sdate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->sdate__hora = substr($this->sdate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->sdate__hora = substr($this->sdate__hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->sdate__hora = substr($this->sdate__hora, 0, -4);
          }
      } 
      if ($this->sdate_ == "" && $use_null)  
      { 
          $this->sdate_ = "null" ; 
      } 
       $this->field_config['sdate_']['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_all_vert();
          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']['id2_']['keyVal'] = dye_grpcs_edit_grid_pack_protect_string($this->nmgp_dados_form['id2_']);
          }
   } // ajax_return_values
   function ajax_return_values_all_vert()
   {
          if (isset($this->nmgp_refresh_fields) && isset($this->nmgp_refresh_row) && '' != $this->nmgp_refresh_row)
          {
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row] = $this->NM_ajax_info['param'];
              if (isset($this->Embutida_ronly) && $this->Embutida_ronly)
              {
                  if (isset($this->NM_ajax_changed['dye_order_']) && $this->NM_ajax_changed['dye_order_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['dye_order_'] = $this->dye_order_;
                  }
                  if (isset($this->NM_ajax_changed['p_o_number_']) && $this->NM_ajax_changed['p_o_number_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['p_o_number_'] = $this->p_o_number_;
                  }
                  if (isset($this->NM_ajax_changed['style_']) && $this->NM_ajax_changed['style_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['style_'] = $this->style_;
                  }
                  if (isset($this->NM_ajax_changed['invoice_']) && $this->NM_ajax_changed['invoice_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['invoice_'] = $this->invoice_;
                  }
                  if (isset($this->NM_ajax_changed['case_']) && $this->NM_ajax_changed['case_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['case_'] = $this->case_;
                  }
                  if (isset($this->NM_ajax_changed['piece_']) && $this->NM_ajax_changed['piece_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['piece_'] = $this->piece_;
                  }
                  if (isset($this->NM_ajax_changed['racks_']) && $this->NM_ajax_changed['racks_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['racks_'] = $this->racks_;
                  }
                  if (isset($this->NM_ajax_changed['lbs_recd_']) && $this->NM_ajax_changed['lbs_recd_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['lbs_recd_'] = $this->lbs_recd_;
                  }
                  if (isset($this->NM_ajax_changed['lbs_used_']) && $this->NM_ajax_changed['lbs_used_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['lbs_used_'] = $this->lbs_used_;
                  }
                  if (isset($this->NM_ajax_changed['lbs_open_']) && $this->NM_ajax_changed['lbs_open_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['lbs_open_'] = $this->lbs_open_;
                  }
                  if (isset($this->NM_ajax_changed['cost_lb_g_']) && $this->NM_ajax_changed['cost_lb_g_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['cost_lb_g_'] = $this->cost_lb_g_;
                  }
                  if (isset($this->NM_ajax_changed['total_cost_']) && $this->NM_ajax_changed['total_cost_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['total_cost_'] = $this->total_cost_;
                  }
                  if (isset($this->NM_ajax_changed['adate_']) && $this->NM_ajax_changed['adate_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['adate_'] = $this->adate_;
                  }
                  if (isset($this->NM_ajax_changed['edate_']) && $this->NM_ajax_changed['edate_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['edate_'] = $this->edate_;
                  }
                  if (isset($this->NM_ajax_changed['ddate_']) && $this->NM_ajax_changed['ddate_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['ddate_'] = $this->ddate_;
                  }
                  if (isset($this->NM_ajax_changed['shipto_']) && $this->NM_ajax_changed['shipto_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['shipto_'] = $this->shipto_;
                  }
                  if (isset($this->NM_ajax_changed['sdate_']) && $this->NM_ajax_changed['sdate_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['sdate_'] = $this->sdate_;
                  }
                  if (isset($this->NM_ajax_changed['ac_']) && $this->NM_ajax_changed['ac_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['ac_'] = $this->ac_;
                  }
                  if (isset($this->NM_ajax_changed['defects_']) && $this->NM_ajax_changed['defects_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['defects_'] = $this->defects_;
                  }
                  if (isset($this->NM_ajax_changed['rpd_']) && $this->NM_ajax_changed['rpd_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['rpd_'] = $this->rpd_;
                  }
                  if (isset($this->NM_ajax_changed['id2_']) && $this->NM_ajax_changed['id2_'])
                  {
                      $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['id2_'] = $this->id2_;
                  }
              }
          }
          if (isset($this->nmgp_refresh_row) && '' != $this->nmgp_refresh_row)
          {
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['dye_order_'] = $this->dye_order_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['p_o_number_'] = $this->p_o_number_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['style_'] = $this->style_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['invoice_'] = $this->invoice_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['case_'] = $this->case_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['piece_'] = $this->piece_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['racks_'] = $this->racks_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['shipto_'] = $this->shipto_;
              $this->form_vert_dye_grpcs_edit_grid[$this->nmgp_refresh_row]['ac_'] = $this->ac_;
          }
          $this->NM_ajax_info['rsSize'] = sizeof($this->form_vert_dye_grpcs_edit_grid);
          foreach($this->form_vert_dye_grpcs_edit_grid as $sc_seq_vert => $aRecData)
          {
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("dye_order_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['dye_order_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['dye_order_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'text',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("p_o_number_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['p_o_number_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['p_o_number_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("style_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['style_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['style_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("invoice_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['invoice_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['invoice_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("case_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['case_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['case_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("piece_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['piece_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['piece_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("racks_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['racks_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['racks_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("lbs_recd_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['lbs_recd_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['lbs_recd_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("lbs_used_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['lbs_used_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['lbs_used_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("lbs_open_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['lbs_open_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['lbs_open_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("cost_lb_g_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['cost_lb_g_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['cost_lb_g_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("total_cost_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['total_cost_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['total_cost_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("adate_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['adate_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['adate_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("edate_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['edate_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['edate_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("ddate_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['ddate_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['ddate_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("shipto_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['shipto_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['shipto_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("sdate_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['sdate_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['sdate_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("ac_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['ac_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['ac_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("defects_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['defects_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['defects_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("rpd_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['rpd_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['rpd_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
              if ('navigate_form' == $this->NM_ajax_opcao || 'backup_line' == $this->NM_ajax_opcao || (isset($this->nmgp_refresh_fields) && in_array("id2_", $this->nmgp_refresh_fields)))
              {
                  $sTmpValue = NM_charset_to_utf8($aRecData['id2_']);
                  $aLookup = array();
          $aLookupOrig = $aLookup;
                  $this->NM_ajax_info['fldList']['id2_' . $sc_seq_vert] = array(
                       'row'    => $sc_seq_vert,
                       'type'    => 'label',
                       'valList' => array($sTmpValue),
                       );
              }
          }
   }

   function ajax_add_parameters()
   {
   } // ajax_add_parameters
  function nm_proc_onload_record($sc_seq_vert=0)
  {
          if (!$this->NM_ajax_flag || !isset($this->nmgp_refresh_fields)) {
          $_SESSION['scriptcase']['dye_grpcs_edit_grid']['contr_erro'] = 'on';
if (!isset($this->sc_temp_var_id2)) {$this->sc_temp_var_id2 = (isset($_SESSION['var_id2'])) ? $_SESSION['var_id2'] : "";}
 $this->sc_temp_var_id2 = $this->id2_ ;

if (isset($this->sc_temp_var_id2)) { $_SESSION['var_id2'] = $this->sc_temp_var_id2;}
$_SESSION['scriptcase']['dye_grpcs_edit_grid']['contr_erro'] = 'off'; 
          }
  }
  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->lbs_recd_ = str_replace($sc_parm1, $sc_parm2, $this->lbs_recd_); 
      $this->lbs_used_ = str_replace($sc_parm1, $sc_parm2, $this->lbs_used_); 
      $this->lbs_open_ = str_replace($sc_parm1, $sc_parm2, $this->lbs_open_); 
      $this->cost_lb_g_ = str_replace($sc_parm1, $sc_parm2, $this->cost_lb_g_); 
      $this->total_cost_ = str_replace($sc_parm1, $sc_parm2, $this->total_cost_); 
   } 
   function nm_poe_aspas_decimal() 
   { 
      $this->lbs_recd_ = "'" . $this->lbs_recd_ . "'";
      $this->lbs_used_ = "'" . $this->lbs_used_ . "'";
      $this->lbs_open_ = "'" . $this->lbs_open_ . "'";
      $this->cost_lb_g_ = "'" . $this->cost_lb_g_ . "'";
      $this->total_cost_ = "'" . $this->total_cost_ . "'";
   } 
   function nm_tira_aspas_decimal() 
   { 
      $this->lbs_recd_ = str_replace("'", "", $this->lbs_recd_); 
      $this->lbs_used_ = str_replace("'", "", $this->lbs_used_); 
      $this->lbs_open_ = str_replace("'", "", $this->lbs_open_); 
      $this->cost_lb_g_ = str_replace("'", "", $this->cost_lb_g_); 
      $this->total_cost_ = str_replace("'", "", $this->total_cost_); 
   } 
//----------- 


   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 $sc_seq_vert,  $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 = "";
      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; 
      if ($this->nmgp_opcao == "alterar")
      {
          $SC_ex_update = true; 
          $SC_ex_upd_or = true; 
          $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert];
          if ($this->nmgp_dados_select['dye_order_'] == $this->dye_order_ &&
              $this->nmgp_dados_select['p_o_number_'] == $this->p_o_number_ &&
              $this->nmgp_dados_select['style_'] == $this->style_ &&
              $this->nmgp_dados_select['invoice_'] == $this->invoice_ &&
              $this->nmgp_dados_select['case_'] == $this->case_ &&
              $this->nmgp_dados_select['piece_'] == $this->piece_ &&
              $this->nmgp_dados_select['racks_'] == $this->racks_ &&
              $this->nmgp_dados_select['lbs_recd_'] == $this->lbs_recd_ &&
              $this->nmgp_dados_select['lbs_used_'] == $this->lbs_used_ &&
              $this->nmgp_dados_select['lbs_open_'] == $this->lbs_open_ &&
              $this->nmgp_dados_select['cost_lb_g_'] == $this->cost_lb_g_ &&
              $this->nmgp_dados_select['total_cost_'] == $this->total_cost_ &&
              $this->nmgp_dados_select['adate_'] == $this->adate_ &&
              $this->nmgp_dados_select['edate_'] == $this->edate_ &&
              $this->nmgp_dados_select['ddate_'] == $this->ddate_ &&
              $this->nmgp_dados_select['shipto_'] == $this->shipto_ &&
              $this->nmgp_dados_select['sdate_'] == $this->sdate_ &&
              $this->nmgp_dados_select['ac_'] == $this->ac_ &&
              $this->nmgp_dados_select['defects_'] == $this->defects_ &&
              $this->nmgp_dados_select['rpd_'] == $this->rpd_ &&
              $this->nmgp_dados_select['id2_'] == $this->id2_)
          {
              $SC_ex_update = false; 
              $SC_ex_upd_or = false; 
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['dye_order_'] = $this->dye_order_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['p_o_number_'] = $this->p_o_number_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['style_'] = $this->style_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['invoice_'] = $this->invoice_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['case_'] = $this->case_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['piece_'] = $this->piece_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['racks_'] = $this->racks_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['lbs_recd_'] = $this->lbs_recd_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['lbs_used_'] = $this->lbs_used_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['lbs_open_'] = $this->lbs_open_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['cost_lb_g_'] = $this->cost_lb_g_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['total_cost_'] = $this->total_cost_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['adate_'] = $this->adate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['edate_'] = $this->edate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['ddate_'] = $this->ddate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['shipto_'] = $this->shipto_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['sdate_'] = $this->sdate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['ac_'] = $this->ac_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['defects_'] = $this->defects_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['rpd_'] = $this->rpd_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['id2_'] = $this->id2_;
          }
      }
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $salva_opcao = $this->nmgp_opcao; 
      if ($this->sc_evento != "novo") 
      { 
          $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; 
      } 
      $NM_val_form['dye_order_'] = $this->dye_order_;
      $NM_val_form['p_o_number_'] = $this->p_o_number_;
      $NM_val_form['style_'] = $this->style_;
      $NM_val_form['invoice_'] = $this->invoice_;
      $NM_val_form['case_'] = $this->case_;
      $NM_val_form['piece_'] = $this->piece_;
      $NM_val_form['racks_'] = $this->racks_;
      $NM_val_form['lbs_recd_'] = $this->lbs_recd_;
      $NM_val_form['lbs_used_'] = $this->lbs_used_;
      $NM_val_form['lbs_open_'] = $this->lbs_open_;
      $NM_val_form['cost_lb_g_'] = $this->cost_lb_g_;
      $NM_val_form['total_cost_'] = $this->total_cost_;
      $NM_val_form['adate_'] = $this->adate_;
      $NM_val_form['edate_'] = $this->edate_;
      $NM_val_form['ddate_'] = $this->ddate_;
      $NM_val_form['shipto_'] = $this->shipto_;
      $NM_val_form['sdate_'] = $this->sdate_;
      $NM_val_form['ac_'] = $this->ac_;
      $NM_val_form['defects_'] = $this->defects_;
      $NM_val_form['rpd_'] = $this->rpd_;
      $NM_val_form['id2_'] = $this->id2_;
      $NM_val_form['old_po_'] = $this->old_po_;
      if ($this->lbs_recd_ == "")  
      { 
          $this->lbs_recd_ = 0;
          $this->sc_force_zero[] = 'lbs_recd_';
      } 
      if ($this->lbs_used_ == "")  
      { 
          $this->lbs_used_ = 0;
          $this->sc_force_zero[] = 'lbs_used_';
      } 
      if ($this->lbs_open_ == "")  
      { 
          $this->lbs_open_ = 0;
          $this->sc_force_zero[] = 'lbs_open_';
      } 
      if ($this->cost_lb_g_ == "")  
      { 
          $this->cost_lb_g_ = 0;
          $this->sc_force_zero[] = 'cost_lb_g_';
      } 
      if ($this->total_cost_ == "")  
      { 
          $this->total_cost_ = 0;
          $this->sc_force_zero[] = 'total_cost_';
      } 
      if ($this->defects_ == "")  
      { 
          $this->defects_ = 0;
          $this->sc_force_zero[] = 'defects_';
      } 
      if ($this->rpd_ == "")  
      { 
          $this->rpd_ = 0;
          $this->sc_force_zero[] = 'rpd_';
      } 
      if ($this->id2_ == "")  
      { 
          $this->id2_ = 0;
      } 
      $nm_bases_lob_geral = array_merge($this->Ini->nm_bases_oracle, $this->Ini->nm_bases_ibase, $this->Ini->nm_bases_informix);
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['decimal_db'] == ",") 
      {
          $this->nm_troca_decimal(".", ",");
      }
      if ($this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "incluir") 
      {
          $this->p_o_number_ = substr($this->Db->qstr($this->p_o_number_), 1, -1); 
          if ($this->p_o_number_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->p_o_number_ = "null"; 
              $NM_val_null[] = "p_o_number_";
          } 
          $this->old_po_ = substr($this->Db->qstr($this->old_po_), 1, -1); 
          if ($this->old_po_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->old_po_ = "null"; 
              $NM_val_null[] = "old_po_";
          } 
          $this->style_ = substr($this->Db->qstr($this->style_), 1, -1); 
          if ($this->style_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->style_ = "null"; 
              $NM_val_null[] = "style_";
          } 
          $this->invoice_ = substr($this->Db->qstr($this->invoice_), 1, -1); 
          if ($this->invoice_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->invoice_ = "null"; 
              $NM_val_null[] = "invoice_";
          } 
          $this->case_ = substr($this->Db->qstr($this->case_), 1, -1); 
          if ($this->case_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->case_ = "null"; 
              $NM_val_null[] = "case_";
          } 
          $this->piece_ = substr($this->Db->qstr($this->piece_), 1, -1); 
          if ($this->piece_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->piece_ = "null"; 
              $NM_val_null[] = "piece_";
          } 
          $this->racks_ = substr($this->Db->qstr($this->racks_), 1, -1); 
          if ($this->racks_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->racks_ = "null"; 
              $NM_val_null[] = "racks_";
          } 
          $this->dye_order_ = substr($this->Db->qstr($this->dye_order_), 1, -1); 
          if ($this->dye_order_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->dye_order_ = "null"; 
              $NM_val_null[] = "dye_order_";
          } 
          if ($this->adate_ == "")  
          { 
              $this->adate_ = "null"; 
              $NM_val_null[] = "adate_";
          } 
          if ($this->edate_ == "")  
          { 
              $this->edate_ = "null"; 
              $NM_val_null[] = "edate_";
          } 
          if ($this->ddate_ == "")  
          { 
              $this->ddate_ = "null"; 
              $NM_val_null[] = "ddate_";
          } 
          $this->shipto_ = substr($this->Db->qstr($this->shipto_), 1, -1); 
          if ($this->shipto_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->shipto_ = "null"; 
              $NM_val_null[] = "shipto_";
          } 
          if ($this->sdate_ == "")  
          { 
              $this->sdate_ = "null"; 
              $NM_val_null[] = "sdate_";
          } 
          $this->ac_ = substr($this->Db->qstr($this->ac_), 1, -1); 
          if ($this->ac_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->ac_ = "null"; 
              $NM_val_null[] = "ac_";
          } 
      }
      if ($this->nmgp_opcao == "alterar") 
      {
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['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 ID2 = $this->id2_ ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              if ($this->NM_ajax_flag)
              {
                 dye_grpcs_edit_grid_pack_ajax_response();
              }
              exit; 
          }  
          $bUpdateOk = true;
          $tmp_result = (int) $rs1->fields[0]; 
          if ($tmp_result != 1) 
          { 
              $this->Campos_Mens_erro = $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(); 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET DYE_ORDER = '$this->dye_order_'";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET DYE_ORDER = '$this->dye_order_'";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET DYE_ORDER = '$this->dye_order_'";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET DYE_ORDER = '$this->dye_order_'";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET DYE_ORDER = '$this->dye_order_'";  
              } 
              else 
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET DYE_ORDER = '$this->dye_order_'";  
              } 
              if (isset($NM_val_form['p_o_number_']) && $NM_val_form['p_o_number_'] != $this->nmgp_dados_select['p_o_number_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " P_O_NUMBER = '$this->p_o_number_'"; 
                  $comando_oracle        .= " P_O_NUMBER = '$this->p_o_number_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['old_po_']) && $NM_val_form['old_po_'] != $this->nmgp_dados_select['old_po_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " OLD_PO = '$this->old_po_'"; 
                  $comando_oracle        .= " OLD_PO = '$this->old_po_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['style_']) && $NM_val_form['style_'] != $this->nmgp_dados_select['style_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " STYLE = '$this->style_'"; 
                  $comando_oracle        .= " STYLE = '$this->style_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['invoice_']) && $NM_val_form['invoice_'] != $this->nmgp_dados_select['invoice_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " INVOICE = '$this->invoice_'"; 
                  $comando_oracle        .= " INVOICE = '$this->invoice_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['case_']) && $NM_val_form['case_'] != $this->nmgp_dados_select['case_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " `CASE` = '$this->case_'"; 
                  $comando_oracle        .= " `CASE` = '$this->case_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['piece_']) && $NM_val_form['piece_'] != $this->nmgp_dados_select['piece_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " PIECE = '$this->piece_'"; 
                  $comando_oracle        .= " PIECE = '$this->piece_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['racks_']) && $NM_val_form['racks_'] != $this->nmgp_dados_select['racks_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " RACKS = '$this->racks_'"; 
                  $comando_oracle        .= " RACKS = '$this->racks_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['lbs_recd_']) && $NM_val_form['lbs_recd_'] != $this->nmgp_dados_select['lbs_recd_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " LBS_RECD = $this->lbs_recd_"; 
                  $comando_oracle        .= " LBS_RECD = $this->lbs_recd_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['lbs_used_']) && $NM_val_form['lbs_used_'] != $this->nmgp_dados_select['lbs_used_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " LBS_USED = $this->lbs_used_"; 
                  $comando_oracle        .= " LBS_USED = $this->lbs_used_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['lbs_open_']) && $NM_val_form['lbs_open_'] != $this->nmgp_dados_select['lbs_open_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " LBS_OPEN = $this->lbs_open_"; 
                  $comando_oracle        .= " LBS_OPEN = $this->lbs_open_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['cost_lb_g_']) && $NM_val_form['cost_lb_g_'] != $this->nmgp_dados_select['cost_lb_g_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " COST_LB_G = $this->cost_lb_g_"; 
                  $comando_oracle        .= " COST_LB_G = $this->cost_lb_g_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['total_cost_']) && $NM_val_form['total_cost_'] != $this->nmgp_dados_select['total_cost_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " TOTAL_COST = $this->total_cost_"; 
                  $comando_oracle        .= " TOTAL_COST = $this->total_cost_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['adate_']) && $NM_val_form['adate_'] != $this->nmgp_dados_select['adate_']) 
              { 
                  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        .= " ADATE = #$this->adate_#"; 
                  } 
                  else 
                  { 
                      $comando        .= " ADATE = '$this->adate_'"; 
                  } 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $comando_oracle        .= " ADATE = EXTEND('" . $this->adate_ . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $comando_oracle        .= " ADATE = '$this->adate_'"; 
                  } 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['edate_']) && $NM_val_form['edate_'] != $this->nmgp_dados_select['edate_']) 
              { 
                  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        .= " EDATE = #$this->edate_#"; 
                  } 
                  else 
                  { 
                      $comando        .= " EDATE = '$this->edate_'"; 
                  } 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $comando_oracle        .= " EDATE = EXTEND('" . $this->edate_ . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $comando_oracle        .= " EDATE = '$this->edate_'"; 
                  } 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['ddate_']) && $NM_val_form['ddate_'] != $this->nmgp_dados_select['ddate_']) 
              { 
                  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        .= " DDATE = #$this->ddate_#"; 
                  } 
                  else 
                  { 
                      $comando        .= " DDATE = '$this->ddate_'"; 
                  } 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $comando_oracle        .= " DDATE = EXTEND('" . $this->ddate_ . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $comando_oracle        .= " DDATE = '$this->ddate_'"; 
                  } 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['shipto_']) && $NM_val_form['shipto_'] != $this->nmgp_dados_select['shipto_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " SHIPTO = '$this->shipto_'"; 
                  $comando_oracle        .= " SHIPTO = '$this->shipto_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['sdate_']) && $NM_val_form['sdate_'] != $this->nmgp_dados_select['sdate_']) 
              { 
                  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        .= " SDATE = #$this->sdate_#"; 
                  } 
                  else 
                  { 
                      $comando        .= " SDATE = '$this->sdate_'"; 
                  } 
                  if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
                  { 
                      $comando_oracle        .= " SDATE = EXTEND('" . $this->sdate_ . "', YEAR TO DAY)"; 
                  } 
                  else
                  { 
                      $comando_oracle        .= " SDATE = '$this->sdate_'"; 
                  } 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['ac_']) && $NM_val_form['ac_'] != $this->nmgp_dados_select['ac_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " AC = '$this->ac_'"; 
                  $comando_oracle        .= " AC = '$this->ac_'"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['defects_']) && $NM_val_form['defects_'] != $this->nmgp_dados_select['defects_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " DEFECTS = $this->defects_"; 
                  $comando_oracle        .= " DEFECTS = $this->defects_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              if (isset($NM_val_form['rpd_']) && $NM_val_form['rpd_'] != $this->nmgp_dados_select['rpd_']) 
              { 
                  if ($SC_ex_update || $SC_tem_cmp_update) 
                  { 
                      $comando        .= ","; 
                      $comando_oracle .= ","; 
                  } 
                  $comando        .= " RPD = $this->rpd_"; 
                  $comando_oracle        .= " RPD = $this->rpd_"; 
                  $SC_ex_update = true; 
                  $SC_ex_upd_or = true; 
              } 
              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 ID2 = $this->id2_ ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $comando .= " WHERE ID2 = $this->id2_ ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $comando .= " WHERE ID2 = $this->id2_ ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $comando .= " WHERE ID2 = $this->id2_ ";  
              }  
              else  
              {
                  $comando .= " WHERE ID2 = $this->id2_ ";  
              }  
              $comando = str_replace("'null'", "null", $comando) ; 
              $comando = str_replace("#null#", "null", $comando) ; 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                $comando = str_replace("EXTEND('', YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND('', YEAR TO DAY)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO DAY)", "null", $comando) ; 
              }  
              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)
                              {
                                  dye_grpcs_edit_grid_pack_ajax_response();
                              }
                              exit;  
                          }   
                      }   
                  }   
              }   
              if (in_array(strtolower($this->Ini->nm_tpbanco), $nm_bases_lob_geral))
              { 
              }   
              $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_nav_page(); 
              $this->NM_ajax_info['navPage'] = $this->SC_nav_page; 

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

              $this->sc_teve_alt = true; 
              if     (isset($NM_val_form) && isset($NM_val_form['p_o_number_'])) { $this->p_o_number_ = $NM_val_form['p_o_number_']; }
              elseif (isset($this->p_o_number_)) { $this->nm_limpa_alfa($this->p_o_number_); }
              if     (isset($NM_val_form) && isset($NM_val_form['style_'])) { $this->style_ = $NM_val_form['style_']; }
              elseif (isset($this->style_)) { $this->nm_limpa_alfa($this->style_); }
              if     (isset($NM_val_form) && isset($NM_val_form['invoice_'])) { $this->invoice_ = $NM_val_form['invoice_']; }
              elseif (isset($this->invoice_)) { $this->nm_limpa_alfa($this->invoice_); }
              if     (isset($NM_val_form) && isset($NM_val_form['case_'])) { $this->case_ = $NM_val_form['case_']; }
              elseif (isset($this->case_)) { $this->nm_limpa_alfa($this->case_); }
              if     (isset($NM_val_form) && isset($NM_val_form['piece_'])) { $this->piece_ = $NM_val_form['piece_']; }
              elseif (isset($this->piece_)) { $this->nm_limpa_alfa($this->piece_); }
              if     (isset($NM_val_form) && isset($NM_val_form['racks_'])) { $this->racks_ = $NM_val_form['racks_']; }
              elseif (isset($this->racks_)) { $this->nm_limpa_alfa($this->racks_); }
              if     (isset($NM_val_form) && isset($NM_val_form['lbs_recd_'])) { $this->lbs_recd_ = $NM_val_form['lbs_recd_']; }
              elseif (isset($this->lbs_recd_)) { $this->nm_limpa_alfa($this->lbs_recd_); }
              if     (isset($NM_val_form) && isset($NM_val_form['lbs_used_'])) { $this->lbs_used_ = $NM_val_form['lbs_used_']; }
              elseif (isset($this->lbs_used_)) { $this->nm_limpa_alfa($this->lbs_used_); }
              if     (isset($NM_val_form) && isset($NM_val_form['lbs_open_'])) { $this->lbs_open_ = $NM_val_form['lbs_open_']; }
              elseif (isset($this->lbs_open_)) { $this->nm_limpa_alfa($this->lbs_open_); }
              if     (isset($NM_val_form) && isset($NM_val_form['dye_order_'])) { $this->dye_order_ = $NM_val_form['dye_order_']; }
              elseif (isset($this->dye_order_)) { $this->nm_limpa_alfa($this->dye_order_); }
              if     (isset($NM_val_form) && isset($NM_val_form['cost_lb_g_'])) { $this->cost_lb_g_ = $NM_val_form['cost_lb_g_']; }
              elseif (isset($this->cost_lb_g_)) { $this->nm_limpa_alfa($this->cost_lb_g_); }
              if     (isset($NM_val_form) && isset($NM_val_form['total_cost_'])) { $this->total_cost_ = $NM_val_form['total_cost_']; }
              elseif (isset($this->total_cost_)) { $this->nm_limpa_alfa($this->total_cost_); }
              if     (isset($NM_val_form) && isset($NM_val_form['shipto_'])) { $this->shipto_ = $NM_val_form['shipto_']; }
              elseif (isset($this->shipto_)) { $this->nm_limpa_alfa($this->shipto_); }
              if     (isset($NM_val_form) && isset($NM_val_form['ac_'])) { $this->ac_ = $NM_val_form['ac_']; }
              elseif (isset($this->ac_)) { $this->nm_limpa_alfa($this->ac_); }
              if     (isset($NM_val_form) && isset($NM_val_form['defects_'])) { $this->defects_ = $NM_val_form['defects_']; }
              elseif (isset($this->defects_)) { $this->nm_limpa_alfa($this->defects_); }
              if     (isset($NM_val_form) && isset($NM_val_form['rpd_'])) { $this->rpd_ = $NM_val_form['rpd_']; }
              elseif (isset($this->rpd_)) { $this->nm_limpa_alfa($this->rpd_); }
              if     (isset($NM_val_form) && isset($NM_val_form['id2_'])) { $this->id2_ = $NM_val_form['id2_']; }
              elseif (isset($this->id2_)) { $this->nm_limpa_alfa($this->id2_); }
              $this->nm_proc_onload_record($this->nmgp_refresh_row);

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

              $aOldRefresh               = $this->nmgp_refresh_fields;
              $this->nmgp_refresh_fields = array('dye_order_', 'p_o_number_', 'style_', 'invoice_', 'case_', 'piece_', 'racks_', 'lbs_recd_', 'lbs_used_', 'lbs_open_', 'cost_lb_g_', 'total_cost_', 'adate_', 'edate_', 'ddate_', 'shipto_', 'sdate_', 'ac_', 'defects_', 'rpd_', 'id2_');
              $this->ajax_return_values();
              $this->nmgp_refresh_fields = $aOldRefresh;

              if (isset($this->Embutida_ronly) && $this->Embutida_ronly)
              {

                  $this->NM_ajax_info['readOnly']['dye_order_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['p_o_number_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['style_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['invoice_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['case_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['piece_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['racks_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['lbs_recd_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['lbs_used_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['lbs_open_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['cost_lb_g_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['total_cost_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['adate_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['edate_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['ddate_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['shipto_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['sdate_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['ac_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['defects_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['rpd_' . $this->nmgp_refresh_row] = 'on';

                  $this->NM_ajax_info['readOnly']['id2_' . $this->nmgp_refresh_row] = 'on';


                  $this->NM_ajax_info['closeLine'] = $this->nmgp_refresh_row;
              }

              $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]['dye_grpcs_edit_grid']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['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 = "ID2, ";
          } 
          $bInsertOk = true;
          $aInsertOk = array(); 
          $bInsertOk = $bInsertOk && empty($aInsertOk);
          if ($bInsertOk)
          { 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD) VALUES ('$this->p_o_number_', '$this->old_po_', '$this->style_', '$this->invoice_', '$this->case_', '$this->piece_', '$this->racks_', $this->lbs_recd_, $this->lbs_used_, $this->lbs_open_, '$this->dye_order_', $this->cost_lb_g_, $this->total_cost_, #$this->adate_#, #$this->edate_#, #$this->ddate_#, '$this->shipto_', #$this->sdate_#, '$this->ac_', $this->defects_, $this->rpd_)"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              { 
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD) VALUES (" . $NM_seq_auto . "'$this->p_o_number_', '$this->old_po_', '$this->style_', '$this->invoice_', '$this->case_', '$this->piece_', '$this->racks_', $this->lbs_recd_, $this->lbs_used_, $this->lbs_open_, '$this->dye_order_', $this->cost_lb_g_, $this->total_cost_, '$this->adate_', '$this->edate_', '$this->ddate_', '$this->shipto_', '$this->sdate_', '$this->ac_', $this->defects_, $this->rpd_)"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD) VALUES (" . $NM_seq_auto . "'$this->p_o_number_', '$this->old_po_', '$this->style_', '$this->invoice_', '$this->case_', '$this->piece_', '$this->racks_', $this->lbs_recd_, $this->lbs_used_, $this->lbs_open_, '$this->dye_order_', $this->cost_lb_g_, $this->total_cost_, '$this->adate_', '$this->edate_', '$this->ddate_', '$this->shipto_', '$this->sdate_', '$this->ac_', $this->defects_, $this->rpd_)"; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD) VALUES (" . $NM_seq_auto . "'$this->p_o_number_', '$this->old_po_', '$this->style_', '$this->invoice_', '$this->case_', '$this->piece_', '$this->racks_', $this->lbs_recd_, $this->lbs_used_, $this->lbs_open_, '$this->dye_order_', $this->cost_lb_g_, $this->total_cost_, EXTEND('$this->adate_', YEAR TO DAY), EXTEND('$this->edate_', YEAR TO DAY), EXTEND('$this->ddate_', YEAR TO DAY), '$this->shipto_', EXTEND('$this->sdate_', YEAR TO DAY), '$this->ac_', $this->defects_, $this->rpd_)"; 
              }
              else
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD) VALUES (" . $NM_seq_auto . "'$this->p_o_number_', '$this->old_po_', '$this->style_', '$this->invoice_', '$this->case_', '$this->piece_', '$this->racks_', $this->lbs_recd_, $this->lbs_used_, $this->lbs_open_, '$this->dye_order_', $this->cost_lb_g_, $this->total_cost_, '$this->adate_', '$this->edate_', '$this->ddate_', '$this->shipto_', '$this->sdate_', '$this->ac_', $this->defects_, $this->rpd_)"; 
              }
              $comando = str_replace("'null'", "null", $comando) ; 
              $comando = str_replace("#null#", "null", $comando) ; 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                $comando = str_replace("EXTEND('', YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO FRACTION)", "null", $comando) ; 
                $comando = str_replace("EXTEND('', YEAR TO DAY)", "null", $comando) ; 
                $comando = str_replace("EXTEND(null, YEAR TO DAY)", "null", $comando) ; 
              }  
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $comando; 
              $rs = $this->Db->Execute($comando); 
              if ($rs === false)  
              { 
                  if (FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "MAIL SENT") && FALSE === strpos(strtoupper($this->Db->ErrorMsg()), "WARNING"))
                  {
                      $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)
                          {
                              dye_grpcs_edit_grid_pack_ajax_response();
                              exit; 
                          }
                      }  
                  }  
              }  
              if ('refresh_insert' != $this->nmgp_opcao)
              {
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase)) 
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select @@identity"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      $this->NM_rollback_db(); 
                      if ($this->NM_ajax_flag)
                      {
                          dye_grpcs_edit_grid_pack_ajax_response();
                      }
                      exit; 
                  } 
                  $this->id2_ =  $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->id2_ = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SELECT dbinfo('sqlca.sqlerrd1') FROM " . $this->Ini->nm_tabela; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id2_ = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select .currval from dual"; 
                  $rsy = $this->Db->Execute($_SESSION['scriptcase']['sc_sql_ult_comando']); 
                  if ($rsy === false && !$rsy->EOF)  
                  { 
                      $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
                      exit; 
                  } 
                  $this->id2_ = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
              { 
                  $str_tabela = "SYSIBM.SYSDUMMY1"; 
                  if($this->Ini->nm_con_use_schema == "N") 
                  { 
                          $str_tabela = "SYSDUMMY1"; 
                  } 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SELECT IDENTITY_VAL_LOCAL() FROM " . $str_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->id2_ = $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->id2_ = $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->id2_ = $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->id2_ = $rsy->fields[0];
                  $rsy->Close(); 
              } 
              }

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

              $this->sc_evento = "insert"; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total']++; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_qtd']++; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_I_E']++; 
              $this->NM_ajax_info['navSummary']['reg_ini'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] + 1; 
              $this->NM_ajax_info['navSummary']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_qtd']; 
              $this->NM_ajax_info['navSummary']['reg_tot'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] + 1; 
              $this->NM_gera_nav_page(); 
              $this->NM_ajax_info['navPage'] = $this->SC_nav_page; 
              $this->sc_teve_incl = true; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['dye_order_'] = $this->dye_order_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['p_o_number_'] = $this->p_o_number_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['style_'] = $this->style_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['invoice_'] = $this->invoice_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['case_'] = $this->case_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['piece_'] = $this->piece_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['racks_'] = $this->racks_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['lbs_recd_'] = $this->lbs_recd_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['lbs_used_'] = $this->lbs_used_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['lbs_open_'] = $this->lbs_open_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['cost_lb_g_'] = $this->cost_lb_g_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['total_cost_'] = $this->total_cost_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['adate_'] = $this->adate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['edate_'] = $this->edate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['ddate_'] = $this->ddate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['shipto_'] = $this->shipto_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['sdate_'] = $this->sdate_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['ac_'] = $this->ac_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['defects_'] = $this->defects_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['rpd_'] = $this->rpd_;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert]['id2_'] = $this->id2_;
              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 (isset($this->p_o_number_)) { $this->nm_limpa_alfa($this->p_o_number_); }
              if (isset($this->style_)) { $this->nm_limpa_alfa($this->style_); }
              if (isset($this->invoice_)) { $this->nm_limpa_alfa($this->invoice_); }
              if (isset($this->case_)) { $this->nm_limpa_alfa($this->case_); }
              if (isset($this->piece_)) { $this->nm_limpa_alfa($this->piece_); }
              if (isset($this->racks_)) { $this->nm_limpa_alfa($this->racks_); }
              if (isset($this->lbs_recd_)) { $this->nm_limpa_alfa($this->lbs_recd_); }
              if (isset($this->lbs_used_)) { $this->nm_limpa_alfa($this->lbs_used_); }
              if (isset($this->lbs_open_)) { $this->nm_limpa_alfa($this->lbs_open_); }
              if (isset($this->dye_order_)) { $this->nm_limpa_alfa($this->dye_order_); }
              if (isset($this->cost_lb_g_)) { $this->nm_limpa_alfa($this->cost_lb_g_); }
              if (isset($this->total_cost_)) { $this->nm_limpa_alfa($this->total_cost_); }
              if (isset($this->shipto_)) { $this->nm_limpa_alfa($this->shipto_); }
              if (isset($this->ac_)) { $this->nm_limpa_alfa($this->ac_); }
              if (isset($this->defects_)) { $this->nm_limpa_alfa($this->defects_); }
              if (isset($this->rpd_)) { $this->nm_limpa_alfa($this->rpd_); }
              if (isset($this->id2_)) { $this->nm_limpa_alfa($this->id2_); }
              if (isset($this->Embutida_form) && $this->Embutida_form)
              {
                  $this->nm_guardar_campos();
                  $this->nm_proc_onload_record($this->nmgp_refresh_row);
                  $this->nm_formatar_campos();

                  $this->NM_ajax_info['fldList']['dye_order_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['dye_order_' . $this->nmgp_refresh_row]['valList'] = array($this->dye_order_);
                  $this->NM_ajax_info['fldList']['dye_order_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_dye_order_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['dye_order_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['dye_order_' . $this->nmgp_refresh_row] = "off";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['dye_order_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['dye_order_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['p_o_number_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['p_o_number_' . $this->nmgp_refresh_row]['valList'] = array($this->p_o_number_);
                  $this->NM_ajax_info['fldList']['p_o_number_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_p_o_number_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['p_o_number_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['p_o_number_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['p_o_number_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['p_o_number_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['style_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['style_' . $this->nmgp_refresh_row]['valList'] = array($this->style_);
                  $this->NM_ajax_info['fldList']['style_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_style_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['style_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['style_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['style_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['style_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['invoice_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['invoice_' . $this->nmgp_refresh_row]['valList'] = array($this->invoice_);
                  $this->NM_ajax_info['fldList']['invoice_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_invoice_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['invoice_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['invoice_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['invoice_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['invoice_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['case_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['case_' . $this->nmgp_refresh_row]['valList'] = array($this->case_);
                  $this->NM_ajax_info['fldList']['case_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_case_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['case_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['case_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['case_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['case_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['piece_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['piece_' . $this->nmgp_refresh_row]['valList'] = array($this->piece_);
                  $this->NM_ajax_info['fldList']['piece_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_piece_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['piece_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['piece_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['piece_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['piece_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['racks_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['racks_' . $this->nmgp_refresh_row]['valList'] = array($this->racks_);
                  $this->NM_ajax_info['fldList']['racks_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_racks_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['racks_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['racks_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['racks_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['racks_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['lbs_recd_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['lbs_recd_' . $this->nmgp_refresh_row]['valList'] = array($this->lbs_recd_);
                  $this->NM_ajax_info['fldList']['lbs_recd_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_lbs_recd_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['lbs_recd_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['lbs_recd_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['lbs_recd_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['lbs_recd_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['lbs_used_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['lbs_used_' . $this->nmgp_refresh_row]['valList'] = array($this->lbs_used_);
                  $this->NM_ajax_info['fldList']['lbs_used_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_lbs_used_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['lbs_used_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['lbs_used_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['lbs_used_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['lbs_used_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['lbs_open_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['lbs_open_' . $this->nmgp_refresh_row]['valList'] = array($this->lbs_open_);
                  $this->NM_ajax_info['fldList']['lbs_open_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_lbs_open_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['lbs_open_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['lbs_open_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['lbs_open_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['lbs_open_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['cost_lb_g_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['cost_lb_g_' . $this->nmgp_refresh_row]['valList'] = array($this->cost_lb_g_);
                  $this->NM_ajax_info['fldList']['cost_lb_g_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_cost_lb_g_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['cost_lb_g_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['cost_lb_g_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['cost_lb_g_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['cost_lb_g_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['total_cost_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['total_cost_' . $this->nmgp_refresh_row]['valList'] = array($this->total_cost_);
                  $this->NM_ajax_info['fldList']['total_cost_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_total_cost_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['total_cost_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['total_cost_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['total_cost_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['total_cost_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['adate_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['adate_' . $this->nmgp_refresh_row]['valList'] = array($this->adate_);
                  $this->NM_ajax_info['fldList']['adate_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_adate_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['adate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['adate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['adate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['adate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['edate_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['edate_' . $this->nmgp_refresh_row]['valList'] = array($this->edate_);
                  $this->NM_ajax_info['fldList']['edate_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_edate_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['edate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['edate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['edate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['edate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['ddate_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['ddate_' . $this->nmgp_refresh_row]['valList'] = array($this->ddate_);
                  $this->NM_ajax_info['fldList']['ddate_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_ddate_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['ddate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['ddate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['ddate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['ddate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['shipto_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['shipto_' . $this->nmgp_refresh_row]['valList'] = array($this->shipto_);
                  $this->NM_ajax_info['fldList']['shipto_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_shipto_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['shipto_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['shipto_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['shipto_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['shipto_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['sdate_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['sdate_' . $this->nmgp_refresh_row]['valList'] = array($this->sdate_);
                  $this->NM_ajax_info['fldList']['sdate_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_sdate_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['sdate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['sdate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['sdate_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['sdate_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['ac_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['ac_' . $this->nmgp_refresh_row]['valList'] = array($this->ac_);
                  $this->NM_ajax_info['fldList']['ac_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_ac_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['ac_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['ac_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['ac_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['ac_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['defects_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['defects_' . $this->nmgp_refresh_row]['valList'] = array($this->defects_);
                  $this->NM_ajax_info['fldList']['defects_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_defects_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['defects_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['defects_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['defects_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['defects_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['rpd_' . $this->nmgp_refresh_row]['type']    = 'text';
                  $this->NM_ajax_info['fldList']['rpd_' . $this->nmgp_refresh_row]['valList'] = array($this->rpd_);
                  $this->NM_ajax_info['fldList']['rpd_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_rpd_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['rpd_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['rpd_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['rpd_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['rpd_' . $this->nmgp_refresh_row] = "on";
                      }
                  }

                  $this->NM_ajax_info['fldList']['id2_' . $this->nmgp_refresh_row]['type']    = 'label';
                  $this->NM_ajax_info['fldList']['id2_' . $this->nmgp_refresh_row]['valList'] = array($this->id2_);
                  $this->NM_ajax_info['fldList']['id2_' . $this->nmgp_refresh_row]['labList'] = array($tmpLabel_id2_);

                  if ((isset($this->Embutida_form) && $this->Embutida_form) && (!isset($this->Embutida_ronly) || !$this->Embutida_ronly))
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['id2_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['id2_' . $this->nmgp_refresh_row] = "on";
                      }
                  }
                  elseif (isset($this->Embutida_ronly) && $this->Embutida_ronly)
                  {
                      if (!isset($this->NM_ajax_info['readOnly']['id2_' . $this->nmgp_refresh_row]))
                      {
                          $this->NM_ajax_info['readOnly']['id2_' . $this->nmgp_refresh_row] = "on";
                      }
                  }


                  $this->nm_tira_formatacao();
                  $this->nm_converte_datas();

                  $this->NM_ajax_info['closeLine'] = $this->nmgp_refresh_row;
              }
              if ('refresh_insert' != $this->nmgp_opcao && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_insert']) || $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_redir_insert'] != "S"))
              {
              $this->nmgp_opcao = "novo"; 
              }
              $this->nm_flag_iframe = true;
          } 
          if ($this->lig_edit_lookup)
          {
              $this->lig_edit_lookup_call = true;
          }
      } 
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['decimal_db'] == ",") 
      {
          $this->nm_tira_aspas_decimal();
      }
      if ($this->nmgp_opcao == "excluir") 
      { 
          $this->id2_ = substr($this->Db->qstr($this->id2_), 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 ID2 = $this->id2_"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
          }  
          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->Campos_Mens_erro = $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 ID2 = $this->id2_ "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
              }  
              else  
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where ID2 = $this->id2_ "); 
              }  
              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)
                      {
                          dye_grpcs_edit_grid_pack_ajax_response();
                          exit; 
                      }
                  } 
              } 
              $this->sc_evento = "delete"; 
              $this->nmgp_opcao = "avanca"; 
              $this->nm_flag_iframe = true;
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start']--; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] < 0)
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0; 
              }

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

              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_qtd']--; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total']--; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_I_E']--; 
              $this->NM_ajax_info['navSummary']['reg_ini'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] + 1; 
              $this->NM_ajax_info['navSummary']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_qtd']; 
              $this->NM_ajax_info['navSummary']['reg_tot'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] + 1; 
              $this->NM_gera_nav_page(); 
              $this->NM_ajax_info['navPage'] = $this->SC_nav_page; 
              $this->sc_teve_excl = true; 
              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 ("update" == $this->sc_evento && $this->nmgp_opcao != "nada") {
        if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['decimal_db'] == ",")
        {
           $this->nm_troca_decimal(",", ".");
        }
        $_SESSION['scriptcase']['dye_grpcs_edit_grid']['contr_erro'] = 'on';
if (!isset($this->sc_temp_var_id2)) {$this->sc_temp_var_id2 = (isset($_SESSION['var_id2'])) ? $_SESSION['var_id2'] : "";}
if (!isset($this->sc_temp_var_dyeorder)) {$this->sc_temp_var_dyeorder = (isset($_SESSION['var_dyeorder'])) ? $_SESSION['var_dyeorder'] : "";}
 
     $nm_select ="UPDATE grpcs              SET dye_order = '     ',                  lbs_open = lbs_recd,                  lbs_dyed = 0              WHERE id2 = '$this->sc_temp_var_id2'"; 
         $_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)
             {
                dye_grpcs_edit_grid_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      ;
 
      $nm_select = sum(total_cost) FROM grpcs
           WHERE dye_order = '$this->sc_temp_var_dyeorder'"; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->"SELECT SUM(lbs_dyed) = array();
      $this->"select sum(lbs_dyed) = 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->"SELECT SUM(lbs_dyed)[$y] [$x] = $rx->fields[$x];
                      $this->"select sum(lbs_dyed)[$y] [$x] = $rx->fields[$x];
                 }
                 $y++; 
                 $rx->MoveNext();
          } 
          $rx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->"SELECT SUM(lbs_dyed) = false;
          $this->"SELECT SUM(lbs_dyed)_erro = $this->Db->ErrorMsg();
          $this->"select sum(lbs_dyed) = false;
          $this->"select sum(lbs_dyed)_erro = $this->Db->ErrorMsg();
      } 
;
$lbsdyed = $dataset[0][0];
$totalcost= $dataset[0][1];
$costlbg = $totalcost/$lbsdyed


     $nm_select ="UPDATE dyeorder              SET gr_lbs_o = $lbsdyed,                  gr_lbs_op = gr_lbs_o - gr_lbs_d,                  cost_lb_g = $costlbg,                  gr_value = gr_lbs_op * cost_lb_g,                  cost_lb_t = cost_lb_g + cost_lb_d,                  cost_yd_t = cost_lb_t * gr_lbs_d / yards_recd              WHERE p_o_number = '$this->sc_temp_var_dyeorder'"; 
         $_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)
             {
                dye_grpcs_edit_grid_pack_ajax_response();
             }
             exit;
         }
         $rf->Close();
      ; 
 if (isset($this->sc_temp_var_dyeorder)) { $_SESSION['var_dyeorder'] = $this->sc_temp_var_dyeorder;}
 if (isset($this->sc_temp_var_id2)) { $_SESSION['var_id2'] = $this->sc_temp_var_id2;}
 if (!isset($this->Campos_Mens_erro) || empty($this->Campos_Mens_erro))
 {
$this->nmgp_redireciona_form($this->Ini->path_link . "" . SC_dir_app_name('dye_grpcs_edit_grid') . "/", $this->nm_location, "", "_self", "ret_self", 440, 630);
 };
if (isset($this->sc_temp_var_dyeorder)) { $_SESSION['var_dyeorder'] = $this->sc_temp_var_dyeorder;}
if (isset($this->sc_temp_var_id2)) { $_SESSION['var_id2'] = $this->sc_temp_var_id2;}
$_SESSION['scriptcase']['dye_grpcs_edit_grid']['contr_erro'] = 'off'; 
    }
      if (!empty($this->Campos_Mens_erro)) 
      {
          return;
      }
   if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['decimal_db'] == ",")
   {
       $this->nm_troca_decimal(".", ",");
   }
      if ($salva_opcao == "incluir" && $GLOBALS["erro_incl"] != 1) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['parms'] = "id2_?#?$this->id2_?@?"; 
      }
      if ($this->sc_evento != "insert" && $this->sc_evento != "update" && $this->sc_evento != "delete")
      { 
          $this->id2_ = substr($this->Db->qstr($this->id2_), 1, -1); 
      } 
   }
//---------- 
   function nm_select_banco() 
   { 
      global $nm_form_submit, $sc_seq_vert, $sc_check_incl, $teste_validade, $sc_where;
 
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['rows']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['rows']))
      {
          $this->sc_max_reg = $_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['rows'];
      } 
      if (isset($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['rows_ins']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['rows_ins']))
      {
          $this->sc_max_reg_incl = $_SESSION['scriptcase']['sc_apl_conf']['dye_grpcs_edit_grid']['rows_ins'];
      } 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['embutida_liga_qtd_reg']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['embutida_liga_qtd_reg'])
      {
          $this->sc_max_reg = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['embutida_liga_qtd_reg'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_max_reg']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_max_reg'] > 0)
      {
          $this->sc_max_reg = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_max_reg'];
      } 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $GLOBALS["NM_ERRO_IBASE"] = 0;  
      $this->form_vert_dye_grpcs_edit_grid = array();
      if ($this->nmgp_opcao != "novo") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['parms'] = ""; 
      } 
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
      { 
          $GLOBALS["NM_ERRO_IBASE"] = 1;  
      } 
      if ($this->sc_teve_excl)
      {
          $this->nmgp_opcao = "avanca";
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] -= $this->sc_max_reg;
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start']) || empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start']))
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0;
      }
      if (isset($this->NM_where_filter))
      {
          $this->NM_where_filter = str_replace("@percent@", "%", $this->NM_where_filter);
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter'] = trim($this->NM_where_filter);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total']))
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total']);
          }
      }
      $sc_where_filter = '';
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter_form'])
      {
          $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter_form'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter'])
      {
          if (empty($sc_where_filter))
          {
              $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter'];
          }
          else
          {
              $sc_where_filter .= " and (" . $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter'] . ")";
          }
      }
      $sc_where = "";
      if ('' != $sc_where_filter)
      {
          $sc_where = (isset($sc_where) && '' != $sc_where) ? $sc_where . ' and (' . $sc_where_filter . ')' : ' where ' . $sc_where_filter;
      }
      if (isset($this->NM_ajax_opcao) && 'backup_line' == $this->NM_ajax_opcao)
      {
          if ('' == $sc_where)
          {
              $sc_where = " where (";
          }
          else
          {
              $sc_where .= " and (";
          }
          $sc_where .= "ID2_ = " . $this->id2_;
          $sc_where .= ")";
      }
      if ('total' != $this->form_paginacao)
      {
      if ((isset($_POST['master_nav']) && 'on' == $_POST['master_nav']) || !isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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_dye_grpcs_edit_grid = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] = $qt_geral_reg_dye_grpcs_edit_grid;
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_I_E'] = 0; 
          if (!$this->sc_teve_excl && !$this->sc_teve_incl) 
          { 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0; 
          } 
          $rt->Close(); 
          if ($this->nmgp_opcao == "igual" && isset($this->NM_btn_navega) && 'S' == $this->NM_btn_navega && !empty($this->id2_))
          {
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $Key_Where = "ID2 < $this->id2_ "; 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $Key_Where = "ID2 < $this->id2_ "; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $Key_Where = "ID2 < $this->id2_ "; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $Key_Where = "ID2 < $this->id2_ "; 
              }
              else  
              {
                  $Key_Where = "ID2 < $this->id2_ "; 
              }
              $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]['dye_grpcs_edit_grid']['reg_start'] = $rt->fields[0];
              $rt->Close(); 
          }
      } 
      else 
      { 
          $qt_geral_reg_dye_grpcs_edit_grid = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'];
      } 
      if ($this->nmgp_opcao == "inicio" || $this->nmgp_opcao == "ordem") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0; 
      } 
      if ($this->nmgp_opcao == "navpage" && ($this->nmgp_ordem - 1) <= $qt_geral_reg_dye_grpcs_edit_grid) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = $this->nmgp_ordem - 1; 
      } 
      if ($this->nmgp_opcao == "avanca")  
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] += ($this->sc_max_reg + $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_I_E']); 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] > $qt_geral_reg_dye_grpcs_edit_grid)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = $qt_geral_reg_dye_grpcs_edit_grid - $this->sc_max_reg; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] < 0)
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0; 
              }
          }
      } 
      if ($this->nmgp_opcao == "retorna") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] -= $this->sc_max_reg; 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] < 0)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0; 
          }
      } 
      if ($this->nmgp_opcao == "final") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = ($qt_geral_reg_dye_grpcs_edit_grid + 1) - $this->sc_max_reg; 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] < 0)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] = 0; 
          }
      } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_I_E'] = 0; 
      }
      $sc_order_by = "";
      $sc_order_by = "ID2";
      $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))
      {
          $sc_order_by = " order by $sc_order_by "; 
      }
      if ($this->nmgp_opcao == "ordem") 
      { 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_cmp'] != $this->nmgp_ordem)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_cmp'] = $this->nmgp_ordem; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_ord'] = ' asc'; 
          }
          elseif ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_ord'] == ' asc')
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_ord'] = ' desc'; 
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_ord'] = ' asc'; 
          }
      } 
      if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_cmp'])) 
      { 
          $sc_order_by = " order by " . $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_cmp'] . $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['ordem_ord']; 
      } 
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
      { 
          $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, str_replace (convert(char(10),ADATE,102), '.', '-') + ' ' + convert(char(8),ADATE,20), str_replace (convert(char(10),EDATE,102), '.', '-') + ' ' + convert(char(8),EDATE,20), str_replace (convert(char(10),DDATE,102), '.', '-') + ' ' + convert(char(8),DDATE,20), SHIPTO, str_replace (convert(char(10),SDATE,102), '.', '-') + ' ' + convert(char(8),SDATE,20), AC, DEFECTS, RPD, ID2 from " . $this->Ini->nm_tabela . $sc_where . $sc_order_by; 
      } 
      elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
      { 
          $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, convert(char(23),ADATE,121), convert(char(23),EDATE,121), convert(char(23),DDATE,121), SHIPTO, convert(char(23),SDATE,121), AC, DEFECTS, RPD, ID2 from " . $this->Ini->nm_tabela . $sc_where . $sc_order_by; 
      } 
      elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
      { 
          $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD, ID2 from " . $this->Ini->nm_tabela . $sc_where . $sc_order_by; 
      } 
      elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
      { 
          $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, EXTEND(ADATE, YEAR TO DAY), EXTEND(EDATE, YEAR TO DAY), EXTEND(DDATE, YEAR TO DAY), SHIPTO, EXTEND(SDATE, YEAR TO DAY), AC, DEFECTS, RPD, ID2 from " . $this->Ini->nm_tabela . $sc_where . $sc_order_by; 
      } 
      else 
      { 
          $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, STYLE, INVOICE, `CASE`, PIECE, RACKS, LBS_RECD, LBS_USED, LBS_OPEN, DYE_ORDER, COST_LB_G, TOTAL_COST, ADATE, EDATE, DDATE, SHIPTO, SDATE, AC, DEFECTS, RPD, ID2 from " . $this->Ini->nm_tabela . $sc_where . $sc_order_by; 
      } 
      if ($this->nmgp_opcao != "novo") 
      { 
      if (isset($this->NM_ajax_opcao) && 'backup_line' == $this->NM_ajax_opcao)
      {
          $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select;
          $rs = $this->Db->Execute($nmgp_select) ;
      }
      elseif ('total' == $this->form_paginacao)
      {
          $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
          $rs = $this->Db->Execute($nmgp_select) ; 
      }
      else
      {
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe'] == "R")
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
              $rs = $this->Db->Execute($nmgp_select) ; 
          } 
          else 
          { 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, $this->sc_max_reg, " . $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] . ")" ; 
                  $rs = $this->Db->SelectLimit($nmgp_select, $this->sc_max_reg, $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start']) ; 
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              { 
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, $this->sc_max_reg, " . $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] . ")" ; 
                  $rs = $this->Db->SelectLimit($nmgp_select, $this->sc_max_reg, $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['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 && $this->nmgp_botoes['new'] != "on")
          {
              $this->nmgp_form_empty = true;
          }
          if ($rs->EOF)
          {
              $sc_seq_vert = 0; 
          }
          else
          {
              $sc_seq_vert = 1; 
          }
          if ('total' == $this->form_paginacao)
          {
              $bPagTest = true;
          }
          else
          {
              $bPagTest = $sc_seq_vert <= $this->sc_max_reg;
          }
          while (!$rs->EOF && $bPagTest)
          { 
              if (isset($this->NM_ajax_opcao) && 'backup_line' == $this->NM_ajax_opcao)
              {
                  $guard_seq_vert = $sc_seq_vert;
                  $sc_seq_vert    = $this->nmgp_refresh_row;
              }
              if ('total' != $this->form_paginacao)
              {
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe'] == "R")
              { 
                  $this->sc_max_reg++;
              } 
              }
              $this->p_o_number_ = $rs->fields[0] ; 
              $this->nmgp_dados_select['p_o_number_'] = $this->p_o_number_;
              $this->old_po_ = $rs->fields[1] ; 
              $this->nmgp_dados_select['old_po_'] = $this->old_po_;
              $this->style_ = $rs->fields[2] ; 
              $this->nmgp_dados_select['style_'] = $this->style_;
              $this->invoice_ = $rs->fields[3] ; 
              $this->nmgp_dados_select['invoice_'] = $this->invoice_;
              $this->case_ = $rs->fields[4] ; 
              $this->nmgp_dados_select['case_'] = $this->case_;
              $this->piece_ = $rs->fields[5] ; 
              $this->nmgp_dados_select['piece_'] = $this->piece_;
              $this->racks_ = $rs->fields[6] ; 
              $this->nmgp_dados_select['racks_'] = $this->racks_;
              $this->lbs_recd_ = trim($rs->fields[7]) ; 
              $this->nmgp_dados_select['lbs_recd_'] = $this->lbs_recd_;
              $this->lbs_used_ = trim($rs->fields[8]) ; 
              $this->nmgp_dados_select['lbs_used_'] = $this->lbs_used_;
              $this->lbs_open_ = trim($rs->fields[9]) ; 
              $this->nmgp_dados_select['lbs_open_'] = $this->lbs_open_;
              $this->dye_order_ = $rs->fields[10] ; 
              $this->nmgp_dados_select['dye_order_'] = $this->dye_order_;
              $this->cost_lb_g_ = trim($rs->fields[11]) ; 
              $this->nmgp_dados_select['cost_lb_g_'] = $this->cost_lb_g_;
              $this->total_cost_ = trim($rs->fields[12]) ; 
              $this->nmgp_dados_select['total_cost_'] = $this->total_cost_;
              $this->adate_ = $rs->fields[13] ; 
              $this->nmgp_dados_select['adate_'] = $this->adate_;
              $this->edate_ = $rs->fields[14] ; 
              $this->nmgp_dados_select['edate_'] = $this->edate_;
              $this->ddate_ = $rs->fields[15] ; 
              $this->nmgp_dados_select['ddate_'] = $this->ddate_;
              $this->shipto_ = $rs->fields[16] ; 
              $this->nmgp_dados_select['shipto_'] = $this->shipto_;
              $this->sdate_ = $rs->fields[17] ; 
              $this->nmgp_dados_select['sdate_'] = $this->sdate_;
              $this->ac_ = $rs->fields[18] ; 
              $this->nmgp_dados_select['ac_'] = $this->ac_;
              $this->defects_ = $rs->fields[19] ; 
              $this->nmgp_dados_select['defects_'] = $this->defects_;
              $this->rpd_ = $rs->fields[20] ; 
              $this->nmgp_dados_select['rpd_'] = $this->rpd_;
              $this->id2_ = $rs->fields[21] ; 
              $this->nmgp_dados_select['id2_'] = $this->id2_;
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->nm_troca_decimal(",", ".");
              $this->lbs_recd_ = (strpos(strtolower($this->lbs_recd_), "e")) ? (float)$this->lbs_recd_ : $this->lbs_recd_; 
              $this->lbs_recd_ = (string)$this->lbs_recd_; 
              $this->lbs_used_ = (strpos(strtolower($this->lbs_used_), "e")) ? (float)$this->lbs_used_ : $this->lbs_used_; 
              $this->lbs_used_ = (string)$this->lbs_used_; 
              $this->lbs_open_ = (strpos(strtolower($this->lbs_open_), "e")) ? (float)$this->lbs_open_ : $this->lbs_open_; 
              $this->lbs_open_ = (string)$this->lbs_open_; 
              $this->cost_lb_g_ = (strpos(strtolower($this->cost_lb_g_), "e")) ? (float)$this->cost_lb_g_ : $this->cost_lb_g_; 
              $this->cost_lb_g_ = (string)$this->cost_lb_g_; 
              $this->total_cost_ = (strpos(strtolower($this->total_cost_), "e")) ? (float)$this->total_cost_ : $this->total_cost_; 
              $this->total_cost_ = (string)$this->total_cost_; 
              $this->defects_ = (string)$this->defects_; 
              $this->rpd_ = (string)$this->rpd_; 
              $this->id2_ = (string)$this->id2_; 
              if (empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['parms'])) 
              { 
                  $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['parms'] = "id2_?#?$this->id2_?@?";
              } 
              $this->nm_proc_onload_record($sc_seq_vert);
//
//-- 
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['dados_select'][$sc_seq_vert] = $this->nmgp_dados_select;
              $this->nm_guardar_campos();
              $this->nm_formatar_campos();
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['dye_order_'] =  $this->dye_order_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['p_o_number_'] =  $this->p_o_number_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['style_'] =  $this->style_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['invoice_'] =  $this->invoice_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['case_'] =  $this->case_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['piece_'] =  $this->piece_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['racks_'] =  $this->racks_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_recd_'] =  $this->lbs_recd_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_used_'] =  $this->lbs_used_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_open_'] =  $this->lbs_open_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['cost_lb_g_'] =  $this->cost_lb_g_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['total_cost_'] =  $this->total_cost_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['adate_'] =  $this->adate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['edate_'] =  $this->edate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['ddate_'] =  $this->ddate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['shipto_'] =  $this->shipto_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['sdate_'] =  $this->sdate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['ac_'] =  $this->ac_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['defects_'] =  $this->defects_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['rpd_'] =  $this->rpd_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['id2_'] =  $this->id2_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['old_po_'] =  $this->old_po_; 
              $sc_seq_vert++; 
              $rs->MoveNext() ; 
              if (isset($this->NM_ajax_opcao) && 'backup_line' == $this->NM_ajax_opcao)
              {
                  $sc_seq_vert = $guard_seq_vert;
              }
              if ('total' != $this->form_paginacao)
              {
                  $bPagTest = $sc_seq_vert <= $this->sc_max_reg;
              }
          } 
          ksort ($this->form_vert_dye_grpcs_edit_grid); 
          $rs->Close(); 
          $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_qtd'] = $sc_seq_vert + $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] - 1;
          $this->NM_ajax_info['navSummary']['reg_ini'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] + 1; 
          $this->NM_ajax_info['navSummary']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_qtd']; 
          $this->NM_ajax_info['navSummary']['reg_tot'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] + 1; 
          $this->NM_gera_nav_page(); 
          $this->NM_ajax_info['navPage'] = $this->SC_nav_page; 
          if (!$this->NM_ajax_flag || 'backup_line' != $this->NM_ajax_opcao)
          {
              $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'];
              $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] < (($qt_geral_reg_dye_grpcs_edit_grid + 1) - $this->sc_max_reg);
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao'] = '';
          }
      } 
      if ($this->nmgp_opcao == "novo") 
      { 
          $sc_seq_vert = 1; 
          $sc_check_incl = array(); 
          if ($this->NM_ajax_flag && 'add_new_line' == $this->NM_ajax_opcao) 
          { 
              $sc_seq_vert = $this->sc_seq_vert; 
              $this->sc_evento = "novo"; 
              $this->sc_max_reg_incl = $this->sc_seq_vert; 
          } 
          else 
          { 
              $this->sc_max_reg_incl = 0; 
          } 
          while ($sc_seq_vert <= $this->sc_max_reg_incl) 
          { 
              $this->p_o_number_ = "";  
              $this->style_ = "";  
              $this->invoice_ = "";  
              $this->case_ = "";  
              $this->piece_ = "";  
              $this->racks_ = "";  
              $this->lbs_recd_ = "";  
              $this->lbs_used_ = "";  
              $this->lbs_open_ = "";  
              $this->dye_order_ = "";  
              $this->cost_lb_g_ = "";  
              $this->total_cost_ = "";  
              $this->adate_ = "";  
              $this->edate_ = "";  
              $this->ddate_ = "";  
              $this->shipto_ = "";  
              $this->sdate_ = "";  
              $this->ac_ = "";  
              $this->defects_ = "";  
              $this->rpd_ = "";  
              $this->id2_ = "";  
              $this->nm_proc_onload_record($sc_seq_vert);
              if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['foreign_key']))
              {
                  foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['foreign_key'] as $sFKName => $sFKValue)
                  {
                      if (isset($this->sc_conv_var[$sFKName]))
                      {
                          $sFKName = $this->sc_conv_var[$sFKName];
                      }
                      eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
                  }
              }
              $this->nm_guardar_campos();
              $this->nm_formatar_campos();
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['dye_order_'] =  $this->dye_order_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['p_o_number_'] =  $this->p_o_number_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['style_'] =  $this->style_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['invoice_'] =  $this->invoice_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['case_'] =  $this->case_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['piece_'] =  $this->piece_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['racks_'] =  $this->racks_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_recd_'] =  $this->lbs_recd_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_used_'] =  $this->lbs_used_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['lbs_open_'] =  $this->lbs_open_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['cost_lb_g_'] =  $this->cost_lb_g_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['total_cost_'] =  $this->total_cost_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['adate_'] =  $this->adate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['edate_'] =  $this->edate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['ddate_'] =  $this->ddate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['shipto_'] =  $this->shipto_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['sdate_'] =  $this->sdate_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['ac_'] =  $this->ac_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['defects_'] =  $this->defects_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['rpd_'] =  $this->rpd_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['id2_'] =  $this->id2_; 
             $this->form_vert_dye_grpcs_edit_grid[$sc_seq_vert]['old_po_'] =  $this->old_po_; 
              $sc_seq_vert++; 
          } 
      }  
  }
   function NM_gera_nav_page() 
   {
       $this->SC_nav_page = "";
       $Reg_Page   = $this->sc_max_reg;
       $Max_link   = 5;
       $Mid_link   = ceil($Max_link / 2);
       $Corr_link  = (($Max_link % 2) == 0) ? 0 : 1;
       $rec_tot    = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] + 1;
       $rec_fim    = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['reg_start'] + $this->sc_max_reg;
       $rec_fim    = ($rec_fim > $rec_tot) ? $rec_tot : $rec_fim;
       if ($rec_tot == 0)
       {
           return;
       }
       $Qtd_Pages  = ceil($rec_tot / $Reg_Page);
       $Page_Atu   = ceil($rec_fim / $Reg_Page);
       $Link_ini   = 1;
       if ($Page_Atu > $Max_link)
       {
           $Link_ini = $Page_Atu - $Mid_link + $Corr_link;
       }
       elseif ($Page_Atu > $Mid_link)
       {
           $Link_ini = $Page_Atu - $Mid_link + $Corr_link;
       }
       if (($Qtd_Pages - $Link_ini) < $Max_link)
       {
           $Link_ini = ($Qtd_Pages - $Max_link) + 1;
       }
       if ($Link_ini < 1)
       {
           $Link_ini = 1;
       }
       for ($x = 0; $x < $Max_link && $Link_ini <= $Qtd_Pages; $x++)
       {
           $rec = (($Link_ini - 1) * $Reg_Page) + 1;
           if ($Link_ini == $Page_Atu)
           {
               $this->SC_nav_page .= '<span class="scFormToolbarNavOpen" style="vertical-align: middle;">' . $Link_ini . '</span>';
           }
           else
           {
               $this->SC_nav_page .= '<a class="scFormToolbarNav" style="vertical-align: middle;" href="javascript: nm_navpage(' . $rec . ')">' . $Link_ini . '</a>';
           }
           $Link_ini++;
           if (($x + 1) < $Max_link && $Link_ini <= $Qtd_Pages && '' != $this->Ini->Str_toolbarnav_separator && @is_file($this->Ini->root . $this->Ini->path_img_global . $this->Ini->Str_toolbarnav_separator))
           {
               $this->SC_nav_page .= '<img src="' . $this->Ini->path_img_global . $this->Ini->Str_toolbarnav_separator . '" align="absmiddle" style="vertical-align: middle;">';
           }
       }
   }
//
 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;
     }
     $HTTP_REFERER = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ""; 
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['botoes'] = $this->nmgp_botoes;
     if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")
     {
         $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe'] == "R") && $this->nm_flag_iframe && empty($this->nm_todas_criticas))
     {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe_ajax']))
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['retorno_edit'] = array("edit", "");
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['retorno_edit'] .= "&nmgp_opcao=edit";
          }
          if ($this->sc_evento == "insert" && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe'] == "F")
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe_ajax']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['retorno_edit'] = array("edit", "fim");
              }
              else
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['retorno_edit'] .= "&rec=fim";
              }
          }
          $this->NM_close_db(); 
          $sJsParent = '';
          if ($this->NM_ajax_flag && isset($this->NM_ajax_info['param']['buffer_output']) && $this->NM_ajax_info['param']['buffer_output'])
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['run_iframe_ajax']))
              {
                  $this->NM_ajax_info['ajaxJavascript'][] = array("parent.ajax_navigate", $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['retorno_edit'];
                  $this->NM_ajax_info['redir']['target'] = $sJsParent;
              }
              dye_grpcs_edit_grid_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]['dye_grpcs_edit_grid']['run_iframe_ajax']))
    {
        $opc = ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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]['dye_grpcs_edit_grid']['retorno_edit'] . "';";
    }
?>
         </script>
         </body></html>
<?php
         exit;
     }
   if ($this->NM_ajax_flag && 'add_new_line' == $this->NM_ajax_opcao)
   {
        $this->Form_Corpo(true);
   }
   elseif ($this->NM_ajax_flag && 'table_refresh' == $this->NM_ajax_opcao)
   {
        $this->Form_Table(true);
        $this->Form_Corpo(false, true);
   }
   else
   {
        $this->Form_Init();
        $this->Form_Table();
        $this->Form_Corpo();
        $this->Form_Fim();
   }
 }
   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 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 SC_fast_search($field, $arg_search, $data_search)
   {
      if (empty($data_search)) 
      {
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['fast_search']);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_detal'])) 
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter'] = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_detal'];
          }
          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, "DYE_ORDER", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "P_O_NUMBER", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "STYLE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "INVOICE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "`CASE`", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "PIECE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "RACKS", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "LBS_RECD", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "LBS_USED", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "LBS_OPEN", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "COST_LB_G", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TOTAL_COST", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "SHIPTO", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "AC", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "DEFECTS", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "RPD", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "ID2", $arg_search, $data_search);
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_detal']) && !empty($comando)) 
      {
          $comando = $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_detal'] . " and (" .  $comando . ")";
      }
      if (empty($comando)) 
      {
          $comando = " 1 <> 1 "; 
      }
      $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_dye_grpcs_edit_grid = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
     $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['total'] = $qt_geral_reg_dye_grpcs_edit_grid;
      $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['where_filter'] = $comando;
      $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['fast_search'][0] = $field;
      $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['fast_search'][1] = $arg_search;
      $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['fast_search'][2] = $sv_data;
      $rt->Close(); 
   }
   function SC_monta_condicao(&$comando, $nome, $condicao, $campo, $tp_campo="")
   {
      $nm_aspas   = "'";
      $nm_numeric = array();
      $campo_join = strtolower(str_replace(".", "_", $nome));
      $nm_ini_lower = "";
      $nm_fim_lower = "";
      $nm_numeric[] = "lbs_recd";$nm_numeric[] = "lbs_used";$nm_numeric[] = "lbs_open";$nm_numeric[] = "cost_lb_g";$nm_numeric[] = "total_cost";$nm_numeric[] = "defects";$nm_numeric[] = "rpd";$nm_numeric[] = "id2";
      if (in_array($campo_join, $nm_numeric))
      {
         if ($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['decimal_db'] == ".")
         {
             $nm_aspas = "";
         }
         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;
             }
         }
      }
      $Nm_datas[] = "adate_";$Nm_datas[] = "edate_";$Nm_datas[] = "ddate_";$Nm_datas[] = "sdate_";
          if (in_array($campo_join, $Nm_datas) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
             $nm_aspas = "#";
          }
         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 = "'";
         }
         if (in_array($campo_join, $Nm_datas) && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
         {
             $nome     = "to_char ($nome, 'YYYY-MM-DD')";
         }
         if (substr($tp_campo, 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)";
         }
         if (substr($tp_campo, 0, 4) == "DATE" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
         {
             $nome     = "convert(char(23),$nome,121)";
         }
         if (substr($tp_campo, 0, 5) == "TIMES" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
         {
             $nome     = "TO_DATE(TO_CHAR($nome, 'yyyy-mm-dd hh24:mi:ss'), 'yyyy-mm-dd hh24:mi:ss')";
             $tp_campo = "DATE" . substr($tp_campo, 4);
         }
         $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_aspas;
             }
             $prep .= (empty($prep)) ? $nm_aspas . $nm_aspas : "";
             $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_aspas;
            break;
            case "II":     // 
               $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " like '" . $campo . "%'";
            break;
            case "QP":     // 
               if (substr($tp_campo, 0, 4) == "DATE")
               {
                   $NM_cmd     = "";
                   if ($this->NM_data_qp['ano'] != "____")
                   {
                       $NM_cmd     .= (empty($NM_cmd)) ? "" : " and ";
                       if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
                       {
                           $NM_cmd     .= "extract('year' from $nome) = " . $this->NM_data_qp['ano'];
                       }
                       elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
                       {
                           $NM_cmd     .= "extract(year from $nome) = " . $this->NM_data_qp['ano'];
                       }
                       else
                       {
                       $NM_cmd     .= "year($nome) = " . $this->NM_data_qp['ano'];
                       }
                   }
                   if ($this->NM_data_qp['mes'] != "__")
                   {
                       $NM_cmd     .= (empty($NM_cmd)) ? "" : " and ";
                       if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
                       {
                           $NM_cmd     .= "extract('month' from $nome) = " . $this->NM_data_qp['mes'];
                       }
                       elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
                       {
                           $NM_cmd     .= "extract(month from $nome) = " . $this->NM_data_qp['mes'];
                       }
                       else
                       {
                       $NM_cmd     .= "month($nome) = " . $this->NM_data_qp['mes'];
                       }
                   }
                   if ($this->NM_data_qp['dia'] != "__")
                   {
                       $NM_cmd     .= (empty($NM_cmd)) ? "" : " and ";
                       if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
                       {
                           $NM_cmd     .= "extract('day' from $nome) = " . $this->NM_data_qp['dia'];
                       }
                       elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
                       {
                           $NM_cmd     .= "extract(day from $nome) = " . $this->NM_data_qp['dia'];
                       }
                       else
                       {
                       $NM_cmd     .= "day($nome) = " . $this->NM_data_qp['dia'];
                       }
                   }
                   if (!empty($NM_cmd))
                   {
                       $NM_cmd     = " (" . $NM_cmd . ")";
                       $comando        .= $NM_cmd;
                   }
               }
               else
               {
                   $comando        .= $nm_ini_lower . $nome . $nm_fim_lower ." like '%" . $campo . "%'";
               }
            break;
            case "NP":     // 
               if (substr($tp_campo, 0, 4) == "DATE")
               {
                   $NM_cmd     = "";
                   if ($this->NM_data_qp['ano'] != "____")
                   {
                       $NM_cmd     .= (empty($NM_cmd)) ? "" : " and ";
                       if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
                       {
                           $NM_cmd     .= "extract('year' from $nome) <> " . $this->NM_data_qp['ano'];
                       }
                       elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
                       {
                           $NM_cmd     .= "extract(year from $nome) <> " . $this->NM_data_qp['ano'];
                       }
                       else
                       {
                       $NM_cmd     .= "year($nome) <> " . $this->NM_data_qp['ano'];
                       }
                   }
                   if ($this->NM_data_qp['mes'] != "__")
                   {
                       $NM_cmd     .= (empty($NM_cmd)) ? "" : " and ";
                       if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
                       {
                           $NM_cmd     .= "extract('month' from $nome) <> " . $this->NM_data_qp['mes'];
                       }
                       elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
                       {
                           $NM_cmd     .= "extract(month from $nome) <> " . $this->NM_data_qp['mes'];
                       }
                       else
                       {
                       $NM_cmd     .= "month($nome) <> " . $this->NM_data_qp['mes'];
                       }
                   }
                   if ($this->NM_data_qp['dia'] != "__")
                   {
                       $NM_cmd     .= (empty($NM_cmd)) ? "" : " and ";
                       if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
                       {
                           $NM_cmd     .= "extract('day' from $nome) <> " . $this->NM_data_qp['dia'];
                       }
                       elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
                       {
                           $NM_cmd     .= "extract(day from $nome) <> " . $this->NM_data_qp['dia'];
                       }
                       else
                       {
                       $NM_cmd     .= "day($nome) <> " . $this->NM_data_qp['dia'];
                       }
                   }
                   if (!empty($NM_cmd))
                   {
                       $NM_cmd     = " (" . $NM_cmd . ")";
                       $comando        .= $NM_cmd;
                   }
               }
               else
               {
                   $comando        .= $nm_ini_lower . $nome . $nm_fim_lower ." not like '%" . $campo . "%'";
               }
            break;
            case "DF":     // 
               if ($tp_campo == "DTDF" || $tp_campo == "DATEDF")
               {
                   $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " not like '%" . $campo . "%'";
               }
               else
               {
                   $comando        .= $nm_ini_lower . $nome . $nm_fim_lower . " <> " . $nm_aspas . $campo . $nm_aspas;
               }
            break;
            case "GT":     // 
               $comando        .= " $nome > " . $nm_aspas . $campo . $nm_aspas;
            break;
            case "GE":     // 
               $comando        .= " $nome >= " . $nm_aspas . $campo . $nm_aspas;
            break;
            case "LT":     // 
               $comando        .= " $nome < " . $nm_aspas . $campo . $nm_aspas;
            break;
            case "LE":     // 
               $comando        .= " $nome <= " . $nm_aspas . $campo . $nm_aspas;
            break;
         }
   }
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 && isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_outra_jan']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['sc_outra_jan'])
   {
       $nmgp_saida_form = "dye_grpcs_edit_grid_fim.php";
   }
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['redir']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['redir'] == 'redir')
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']);
   }
   unset($_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opc_ant']);
   $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)
   {
       $this->NM_ajax_info['redir']['metodo']              = 'post';
       $this->NM_ajax_info['redir']['action']              = $nmgp_saida_form;
       $this->NM_ajax_info['redir']['target']              = '_self';
       $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;
       }
       dye_grpcs_edit_grid_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'] ?>" />
    <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"/>
   </HEAD>
   <BODY>
   <FORM name="form_ok" method="POST" action="<?php echo NM_encode_input($nmgp_saida_form); ?>" target="_self">
<?php
   if ($tipo == 0)
   {
?>
     <INPUT type="hidden" name="nmgp_url_saida" value="<?php echo NM_encode_input($this->nm_location); ?>"> 
<?php
   }
?>
     <INPUT type="hidden" name="script_case_init" value="<?php echo NM_encode_input($this->Ini->sc_page); ?>"> 
     <INPUT type="hidden" name="script_case_session" value="<?php echo NM_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]['dye_grpcs_edit_grid']['sc_modal']) && $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['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();
      }
      document.form_ok.submit();
   </SCRIPT>
   </BODY>
   </HTML>
<?php
  exit;
}
function nmgp_redireciona_form($nm_apl_dest, $nm_apl_retorno, $nm_apl_parms, $nm_target="", $opc="", $alt_modal=430, $larg_modal=630)
{
   if (isset($this->NM_is_redirected) && $this->NM_is_redirected)
   {
       return;
   }
   if (is_array($nm_apl_parms))
   {
       $tmp_parms = "";
       foreach ($nm_apl_parms as $par => $val)
       {
           $par = trim($par);
           $val = trim($val);
           $tmp_parms .= str_replace(".", "_", $par) . "?#?";
           if (substr($val, 0, 1) == "$")
           {
               $tmp_parms .= $$val;
           }
           elseif (substr($val, 0, 1) == "{")
           {
               $val        = substr($val, 1, -1);
               $tmp_parms .= $this->$val;
           }
           elseif (substr($val, 0, 1) == "[")
           {
               $tmp_parms .= $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid'][substr($val, 1, -1)];
           }
           else
           {
               $tmp_parms .= $val;
           }
           $tmp_parms .= "?@?";
       }
       $nm_apl_parms = $tmp_parms;
   }
   if (empty($opc))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['opcao'] = "";
       $_SESSION['sc_session'][$this->Ini->sc_page]['dye_grpcs_edit_grid']['retorno_edit'] = "";
   }
   $nm_target_form = (empty($nm_target)) ? "_self" : $nm_target;
   if (strtolower(substr($nm_apl_dest, -4)) != ".php" && (strtolower(substr($nm_apl_dest, 0, 7)) == "http://" || strtolower(substr($nm_apl_dest, 0, 8)) == "https://" || strtolower(substr($nm_apl_dest, 0, 3)) == "../"))
   {
       if ($this->NM_ajax_flag)
       {
           $this->NM_ajax_info['redir']['metodo'] = 'location';
           $this->NM_ajax_info['redir']['action'] = $nm_apl_dest;
           $this->NM_ajax_info['redir']['target'] = $nm_target_form;
           dye_grpcs_edit_grid_pack_ajax_response();
           exit;
       }
       echo "<SCRIPT language=\"javascript\">";
       if (strtolower($nm_target) == "_blank")
       {
           echo "window.open ('" . $nm_apl_dest . "');";
           echo "</SCRIPT>";
           return;
       }
       else
       {
           echo "window.location='" . $nm_apl_dest . "';";
           echo "</SCRIPT>";
           $this->NM_close_db();
           exit;
       }
   }
   $dir = explode("/", $nm_apl_dest);
   if (count($dir) == 1)
   {
       $nm_apl_dest = str_replace(".php", "", $nm_apl_dest);
       $nm_apl_dest = $this->Ini->path_link . SC_dir_app_name($nm_apl_dest) . "/" . $nm_apl_dest . ".php";
   }
   if ($this->NM_ajax_flag)
   {
       $nm_apl_parms = str_replace("?#?", "*scin", $nm_apl_parms);
       $nm_apl_parms = str_replace("?@?", "*scout", $nm_apl_parms);
       $this->NM_ajax_info['redir']['metodo']     = 'post';
       $this->NM_ajax_info['redir']['action']     = $nm_apl_dest;
       $this->NM_ajax_info['redir']['nmgp_parms'] = $nm_apl_parms;
       $this->NM_ajax_info['redir']['target']     = $nm_target_form;
       $this->NM_ajax_info['redir']['h_modal']    = $alt_modal;
       $this->NM_ajax_info['redir']['w_modal']    = $larg_modal;
       if ($nm_target_form == "_blank")
       {
           $this->NM_ajax_info['redir']['nmgp_outra_jan'] = 'true';
       }
       else
       {
           $this->NM_ajax_info['redir']['nmgp_url_saida']      = $nm_apl_retorno;
           $this->NM_ajax_info['redir']['script_case_init']    = $this->Ini->sc_page;
           $this->NM_ajax_info['redir']['script_case_session'] = session_id();
       }
       dye_grpcs_edit_grid_pack_ajax_response();
       exit;
   }
   if ($nm_target == "modal")
   {
       if (!empty($nm_apl_parms))
       {
           $nm_apl_parms = str_replace("?#?", "*scin", $nm_apl_parms);
           $nm_apl_parms = str_replace("?@?", "*scout", $nm_apl_parms);
           $nm_apl_parms = "nmgp_parms=" . $nm_apl_parms . "&";
       }
       $par_modal = "?script_case_init=" . $this->Ini->sc_page . "&script_case_session=" . session_id() . "&nmgp_outra_jan=true&nmgp_url_saida=modal&NMSC_modal=ok&";
       $this->redir_modal = "$(function() { tb_show('', '" . $nm_apl_dest . $par_modal . $nm_apl_parms . "TB_iframe=true&modal=true&height=" . $alt_modal . "&width=" . $larg_modal . "', '') })";
       $this->NM_is_redirected = true;
       return;
   }
?>
<!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'] ?>" />
    <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"/>
   </HEAD>
   <BODY>
<form name="Fredir" method="post" 
                  target="_self"> 
  <input type="hidden" name="nmgp_parms" value="<?php echo NM_encode_input($nm_apl_parms); ?>"/>
<?php
   if ($nm_target_form == "_blank")
   {
?>
  <input type="hidden" name="nmgp_outra_jan" value="true"/> 
<?php
   }
   else
   {
?>
  <input type="hidden" name="nmgp_url_saida" value="<?php echo NM_encode_input($nm_apl_retorno) ?>">
  <input type="hidden" name="script_case_init" value="<?php echo NM_encode_input($this->Ini->sc_page); ?>"/> 
  <input type="hidden" name="script_case_session" value="<?php echo NM_encode_input(session_id()); ?>"> 
<?php
   }
?>
</form> 
   <SCRIPT type="text/javascript">
<?php
   if ($nm_target_form == "modal")
   {
?>
       $(document).ready(function(){
           tb_show('', '<?php echo $nm_apl_dest ?>?script_case_init=<?php echo $this->Ini->sc_page; ?>&script_case_session=<?php echo session_id() ?> &nmgp_url_saida=modal&nmgp_parms=<?php echo NM_encode_input($nm_apl_parms); ?>&nmgp_outra_jan=true&TB_iframe=true&height=<?php echo $alt_modal; ?>&width=<?php echo $larg_modal; ?>&modal=true', '');
       });
<?php
   }
   else
   {
?>
       document.Fredir.target = "<?php echo $nm_target_form ?>"; 
       document.Fredir.action = "<?php echo $nm_apl_dest ?>";
       document.Fredir.submit();
<?php
   }
?>
   </SCRIPT>
   </BODY>
   </HTML>
<?php
   if ($nm_target_form != "_blank" && $nm_target_form != "modal")
   {
       $this->NM_close_db();
       exit;
   }
}
}
?>
