<?php
//
class greige_greigepo_greige_form_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 $date;
   var $mill;
   var $ship_to;
   var $style;
   var $new_style;
   var $desc1;
   var $desc2;
   var $top_p_o_;
   var $top_lbs;
   var $top_ship;
   var $top_cost;
   var $bot_p_o_;
   var $bot_lbs;
   var $bot_ship;
   var $bot_cost;
   var $terms;
   var $delivery;
   var $order_amt;
   var $lbs_ordere;
   var $lbs;
   var $lbs_open;
   var $lbs_dyed;
   var $adjustment;
   var $inventory;
   var $pinv;
   var $knit_price;
   var $cost_lb_k;
   var $totalkc;
   var $cost_lb_y;
   var $cost_lb;
   var $status;
   var $amount;
   var $roll_size;
   var $spec;
   var $mach;
   var $production;
   var $ac;
   var $lbs_rack;
   var $nm_data;
   var $nmgp_opcao;
   var $nmgp_opc_ant;
   var $sc_evento;
   var $sc_insert_on;
   var $nmgp_clone;
   var $nmgp_return_img = array();
   var $nmgp_dados_form = array();
   var $nmgp_dados_select = array();
   var $nm_location;
   var $nm_flag_iframe;
   var $nm_flag_saida_novo;
   var $nmgp_botoes = array();
   var $nmgp_url_saida;
   var $nmgp_form_show;
   var $nmgp_form_empty;
   var $nmgp_cmp_readonly = array();
   var $nmgp_cmp_hidden = array();
   var $form_paginacao = 'parcial';
   var $lig_edit_lookup      = false;
   var $lig_edit_lookup_call = false;
   var $lig_edit_lookup_cb   = '';
   var $lig_edit_lookup_row  = '';
   var $is_calendar_app = false;
   var $Embutida_call  = false;
   var $Embutida_ronly = false;
   var $Embutida_proc  = false;
   var $Embutida_form  = false;
   var $Grid_editavel  = false;
   var $url_webhelp = '';
   var $nm_todas_criticas;
   var $Campos_Mens_erro;
   var $nm_new_label = array();
//
//----- 
   function ini_controle()
   {
        global $nm_url_saida, $teste_validade, $script_case_init, 
               $glo_senha_protect, $nm_apl_dependente, $nm_form_submit, $sc_check_excl, $nm_opc_form_php, $nm_call_php, $nm_opc_lookup;


      if ($this->NM_ajax_flag)
      {
          if (isset($this->NM_ajax_info['param']['ac']))
          {
              $this->ac = $this->NM_ajax_info['param']['ac'];
          }
          if (isset($this->NM_ajax_info['param']['adjustment']))
          {
              $this->adjustment = $this->NM_ajax_info['param']['adjustment'];
          }
          if (isset($this->NM_ajax_info['param']['amount']))
          {
              $this->amount = $this->NM_ajax_info['param']['amount'];
          }
          if (isset($this->NM_ajax_info['param']['bot_cost']))
          {
              $this->bot_cost = $this->NM_ajax_info['param']['bot_cost'];
          }
          if (isset($this->NM_ajax_info['param']['bot_lbs']))
          {
              $this->bot_lbs = $this->NM_ajax_info['param']['bot_lbs'];
          }
          if (isset($this->NM_ajax_info['param']['bot_p_o_']))
          {
              $this->bot_p_o_ = $this->NM_ajax_info['param']['bot_p_o_'];
          }
          if (isset($this->NM_ajax_info['param']['bot_ship']))
          {
              $this->bot_ship = $this->NM_ajax_info['param']['bot_ship'];
          }
          if (isset($this->NM_ajax_info['param']['cost_lb']))
          {
              $this->cost_lb = $this->NM_ajax_info['param']['cost_lb'];
          }
          if (isset($this->NM_ajax_info['param']['cost_lb_k']))
          {
              $this->cost_lb_k = $this->NM_ajax_info['param']['cost_lb_k'];
          }
          if (isset($this->NM_ajax_info['param']['cost_lb_y']))
          {
              $this->cost_lb_y = $this->NM_ajax_info['param']['cost_lb_y'];
          }
          if (isset($this->NM_ajax_info['param']['date']))
          {
              $this->date = $this->NM_ajax_info['param']['date'];
          }
          if (isset($this->NM_ajax_info['param']['delivery']))
          {
              $this->delivery = $this->NM_ajax_info['param']['delivery'];
          }
          if (isset($this->NM_ajax_info['param']['desc1']))
          {
              $this->desc1 = $this->NM_ajax_info['param']['desc1'];
          }
          if (isset($this->NM_ajax_info['param']['desc2']))
          {
              $this->desc2 = $this->NM_ajax_info['param']['desc2'];
          }
          if (isset($this->NM_ajax_info['param']['inventory']))
          {
              $this->inventory = $this->NM_ajax_info['param']['inventory'];
          }
          if (isset($this->NM_ajax_info['param']['knit_price']))
          {
              $this->knit_price = $this->NM_ajax_info['param']['knit_price'];
          }
          if (isset($this->NM_ajax_info['param']['lbs']))
          {
              $this->lbs = $this->NM_ajax_info['param']['lbs'];
          }
          if (isset($this->NM_ajax_info['param']['lbs_dyed']))
          {
              $this->lbs_dyed = $this->NM_ajax_info['param']['lbs_dyed'];
          }
          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_ordere']))
          {
              $this->lbs_ordere = $this->NM_ajax_info['param']['lbs_ordere'];
          }
          if (isset($this->NM_ajax_info['param']['lbs_rack']))
          {
              $this->lbs_rack = $this->NM_ajax_info['param']['lbs_rack'];
          }
          if (isset($this->NM_ajax_info['param']['mach']))
          {
              $this->mach = $this->NM_ajax_info['param']['mach'];
          }
          if (isset($this->NM_ajax_info['param']['mill']))
          {
              $this->mill = $this->NM_ajax_info['param']['mill'];
          }
          if (isset($this->NM_ajax_info['param']['new_style']))
          {
              $this->new_style = $this->NM_ajax_info['param']['new_style'];
          }
          if (isset($this->NM_ajax_info['param']['nm_form_submit']))
          {
              $this->nm_form_submit = $this->NM_ajax_info['param']['nm_form_submit'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_ancora']))
          {
              $this->nmgp_ancora = $this->NM_ajax_info['param']['nmgp_ancora'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_arg_fast_search']))
          {
              $this->nmgp_arg_fast_search = $this->NM_ajax_info['param']['nmgp_arg_fast_search'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_cond_fast_search']))
          {
              $this->nmgp_cond_fast_search = $this->NM_ajax_info['param']['nmgp_cond_fast_search'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_fast_search']))
          {
              $this->nmgp_fast_search = $this->NM_ajax_info['param']['nmgp_fast_search'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_num_form']))
          {
              $this->nmgp_num_form = $this->NM_ajax_info['param']['nmgp_num_form'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_opcao']))
          {
              $this->nmgp_opcao = $this->NM_ajax_info['param']['nmgp_opcao'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_ordem']))
          {
              $this->nmgp_ordem = $this->NM_ajax_info['param']['nmgp_ordem'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_parms']))
          {
              $this->nmgp_parms = $this->NM_ajax_info['param']['nmgp_parms'];
          }
          if (isset($this->NM_ajax_info['param']['nmgp_url_saida']))
          {
              $this->nmgp_url_saida = $this->NM_ajax_info['param']['nmgp_url_saida'];
          }
          if (isset($this->NM_ajax_info['param']['old_po']))
          {
              $this->old_po = $this->NM_ajax_info['param']['old_po'];
          }
          if (isset($this->NM_ajax_info['param']['order_amt']))
          {
              $this->order_amt = $this->NM_ajax_info['param']['order_amt'];
          }
          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']['pinv']))
          {
              $this->pinv = $this->NM_ajax_info['param']['pinv'];
          }
          if (isset($this->NM_ajax_info['param']['production']))
          {
              $this->production = $this->NM_ajax_info['param']['production'];
          }
          if (isset($this->NM_ajax_info['param']['roll_size']))
          {
              $this->roll_size = $this->NM_ajax_info['param']['roll_size'];
          }
          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']['ship_to']))
          {
              $this->ship_to = $this->NM_ajax_info['param']['ship_to'];
          }
          if (isset($this->NM_ajax_info['param']['spec']))
          {
              $this->spec = $this->NM_ajax_info['param']['spec'];
          }
          if (isset($this->NM_ajax_info['param']['status']))
          {
              $this->status = $this->NM_ajax_info['param']['status'];
          }
          if (isset($this->NM_ajax_info['param']['style']))
          {
              $this->style = $this->NM_ajax_info['param']['style'];
          }
          if (isset($this->NM_ajax_info['param']['terms']))
          {
              $this->terms = $this->NM_ajax_info['param']['terms'];
          }
          if (isset($this->NM_ajax_info['param']['top_cost']))
          {
              $this->top_cost = $this->NM_ajax_info['param']['top_cost'];
          }
          if (isset($this->NM_ajax_info['param']['top_lbs']))
          {
              $this->top_lbs = $this->NM_ajax_info['param']['top_lbs'];
          }
          if (isset($this->NM_ajax_info['param']['top_p_o_']))
          {
              $this->top_p_o_ = $this->NM_ajax_info['param']['top_p_o_'];
          }
          if (isset($this->NM_ajax_info['param']['top_ship']))
          {
              $this->top_ship = $this->NM_ajax_info['param']['top_ship'];
          }
          if (isset($this->NM_ajax_info['param']['totalkc']))
          {
              $this->totalkc = $this->NM_ajax_info['param']['totalkc'];
          }
          if (isset($this->nmgp_refresh_fields))
          {
              $this->nmgp_refresh_fields = explode('_#fld#_', $this->nmgp_refresh_fields);
              $this->nmgp_opcao          = 'recarga';
          }
          if (!isset($this->nmgp_refresh_row))
          {
              $this->nmgp_refresh_row = '';
          }
      }

      $this->sc_conv_var = array();
      if (!empty($_FILES))
      {
          foreach ($_FILES as $nmgp_campo => $nmgp_valores)
          {
               if (isset($this->sc_conv_var[$nmgp_campo]))
               {
                   $nmgp_campo = $this->sc_conv_var[$nmgp_campo];
               }
               elseif (isset($this->sc_conv_var[strtolower($nmgp_campo)]))
               {
                   $nmgp_campo = $this->sc_conv_var[strtolower($nmgp_campo)];
               }
               $tmp_scfile_name     = $nmgp_campo . "_scfile_name";
               $tmp_scfile_type     = $nmgp_campo . "_scfile_type";
               $this->$nmgp_campo = is_array($nmgp_valores['tmp_name']) ? $nmgp_valores['tmp_name'][0] : $nmgp_valores['tmp_name'];
               $this->$tmp_scfile_type   = is_array($nmgp_valores['type'])     ? $nmgp_valores['type'][0]     : $nmgp_valores['type'];
               $this->$tmp_scfile_name   = is_array($nmgp_valores['name'])     ? $nmgp_valores['name'][0]     : $nmgp_valores['name'];
          }
      }
      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($_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['embutida_parms']))
      { 
          $this->nmgp_parms = $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['embutida_parms'];
          unset($_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['embutida_parms']);
      } 
      if (isset($this->nmgp_parms) && !empty($this->nmgp_parms)) 
      { 
          if (isset($_SESSION['nm_aba_bg_color'])) 
          { 
              unset($_SESSION['nm_aba_bg_color']);
          }   
          $nmgp_parms = NM_decode_input($nmgp_parms);
          $nmgp_parms = str_replace("@aspass@", "'", $this->nmgp_parms);
          $nmgp_parms = str_replace("*scout", "?@?", $nmgp_parms);
          $nmgp_parms = str_replace("*scin", "?#?", $nmgp_parms);
          $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_greige_greigepo_greige_form($cadapar[1]);
                 $this->$cadapar[0] = $cadapar[1];
             }
             $ix++;
          }
          if (isset($this->NM_where_filter_form))
          {
              $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['where_filter_form'] = $this->NM_where_filter_form;
             unset($_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['total']);
          }
          if (isset($this->sc_redir_atualiz))
          {
              $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['sc_redir_atualiz'] = $this->sc_redir_atualiz;
          }
          if (isset($this->sc_redir_insert))
          {
              $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['sc_redir_insert'] = $this->sc_redir_insert;
          }
      } 
      elseif (isset($script_case_init) && !empty($script_case_init) && isset($_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['lig_edit_lookup']     = true;
          $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['lig_edit_lookup_cb']  = $this->nm_evt_ret_edit;
          $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['lig_edit_lookup_row'] = isset($this->nm_evt_ret_row) ? $this->nm_evt_ret_row : '';
      }
      if (isset($_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['lig_edit_lookup']) && $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['lig_edit_lookup'])
      {
          $this->lig_edit_lookup     = true;
          $this->lig_edit_lookup_cb  = $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['lig_edit_lookup_cb'];
          $this->lig_edit_lookup_row = $_SESSION['sc_session'][$script_case_init]['greige_greigepo_greige_form']['lig_edit_lookup_row'];
      }
      if (!$this->Ini)
      { 
          $this->Ini = new greige_greigepo_greige_form_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)   ? ""     : $str_img_status_ok;
      $this->Ini->Img_status_err  = "" == trim($str_img_status_err)  ? ""     : $str_img_status_err;
      $this->Ini->Css_status      = "scFormInputError";
      $this->Ini->Error_icon_span = "" == trim($str_error_icon_span) ? false  : "message" == $str_error_icon_span;
      $this->Ini->Img_qs_search        = "" == trim($img_qs_search)        ? "scriptcase__NM__qs_lupa.png"  : $img_qs_search;
      $this->Ini->Img_qs_clean         = "" == trim($img_qs_clean)         ? "scriptcase__NM__qs_close.png" : $img_qs_clean;
      $this->Ini->Str_qs_image_padding = "" == trim($str_qs_image_padding) ? "0"                            : $str_qs_image_padding;



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

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

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

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

      $this->loadFieldConfig();

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

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

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

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

      if (isset($_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['field_display']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['field_display']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['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']['greige_greigepo_greige_form']['field_readonly']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['field_readonly']))
      {
          foreach ($_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['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']['greige_greigepo_greige_form']['exit']) && $_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['exit'] != '')
      {
          $_SESSION['scriptcase']['sc_url_saida'][$this->Ini->sc_page] = $_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['exit'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_form']))
      {
          $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_form'];
      }
      $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("greige_greigepo_greige_form", $apls_aba))
              {
                  $this->aba_iframe = true;
                  break;
              }
          }
      }
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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 . 'greige_greigepo_greige_form/greige_greigepo_greige_form_calendar.php');
          }
          else
          { 
              include_once($this->Ini->path_aplicacao . 'greige_greigepo_greige_form_calendar.php');
          }
          exit;
      }

      if (is_file($this->Ini->path_aplicacao . 'greige_greigepo_greige_form_help.txt'))
      {
          $arr_link_webhelp = file($this->Ini->path_aplicacao . 'greige_greigepo_greige_form_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 . 'greige_greigepo_greige_form/greige_greigepo_greige_form_erro.class.php');
      }
      else
      { 
          require_once($this->Ini->path_aplicacao . "greige_greigepo_greige_form_erro.class.php"); 
      }
      $this->Erro      = new greige_greigepo_greige_form_erro();
      $this->Erro->Ini = $this->Ini;
      $this->proc_fast_search = false;
      if ($this->nmgp_opcao == "fast_search")  
      {
          $this->SC_fast_search($this->nmgp_fast_search, $this->nmgp_cond_fast_search, $this->nmgp_arg_fast_search);
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao'] = "inicio";
          $this->nmgp_opcao = "inicio";
          $this->proc_fast_search = true;
      } 
      if ($nm_opc_lookup != "lookup" && $nm_opc_php != "formphp")
      { 
         if (empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao']))
         { 
             if ($this->p_o_number != "")   
             { 
                 $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao'] = "igual" ;  
             }   
         }   
      } 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao']) && empty($this->nmgp_refresh_fields))
      {
          $this->nmgp_opcao = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao'];  
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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']['greige_greigepo_greige_form']['start']) && $_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['start'] == 'new')
      {
          $this->nmgp_opcao = "novo";
          $this->nm_Start_new = true;
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao'] = "novo";
          unset($_SESSION['scriptcase']['sc_apl_conf']['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['opc_ant'];
      } 
      if ($this->nmgp_opcao == "recarga" || $this->nmgp_opcao == "muda_form")  
      {
          $this->nmgp_botoes = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['botoes'];
          $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['inicio'];
          $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total'] != $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['final'];
      }
      else
      {
      }
      $this->nm_flag_iframe = false;
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_form'])) 
      {
         $this->nmgp_dados_form = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_form'];
      }
      if ($this->nmgp_opcao == "edit_novo")  
      {
          $this->nmgp_opcao = "novo";
          $this->nm_flag_saida_novo = "S";
      }
//
      $this->sc_evento = $this->nmgp_opcao;
      $this->sc_insert_on = false;
      if (isset($this->p_o_number)) { $this->nm_limpa_alfa($this->p_o_number); }
      if (isset($this->old_po)) { $this->nm_limpa_alfa($this->old_po); }
      if (isset($this->mill)) { $this->nm_limpa_alfa($this->mill); }
      if (isset($this->ship_to)) { $this->nm_limpa_alfa($this->ship_to); }
      if (isset($this->style)) { $this->nm_limpa_alfa($this->style); }
      if (isset($this->new_style)) { $this->nm_limpa_alfa($this->new_style); }
      if (isset($this->desc1)) { $this->nm_limpa_alfa($this->desc1); }
      if (isset($this->desc2)) { $this->nm_limpa_alfa($this->desc2); }
      if (isset($this->top_p_o_)) { $this->nm_limpa_alfa($this->top_p_o_); }
      if (isset($this->top_lbs)) { $this->nm_limpa_alfa($this->top_lbs); }
      if (isset($this->top_ship)) { $this->nm_limpa_alfa($this->top_ship); }
      if (isset($this->top_cost)) { $this->nm_limpa_alfa($this->top_cost); }
      if (isset($this->bot_p_o_)) { $this->nm_limpa_alfa($this->bot_p_o_); }
      if (isset($this->bot_lbs)) { $this->nm_limpa_alfa($this->bot_lbs); }
      if (isset($this->bot_ship)) { $this->nm_limpa_alfa($this->bot_ship); }
      if (isset($this->bot_cost)) { $this->nm_limpa_alfa($this->bot_cost); }
      if (isset($this->terms)) { $this->nm_limpa_alfa($this->terms); }
      if (isset($this->delivery)) { $this->nm_limpa_alfa($this->delivery); }
      if (isset($this->order_amt)) { $this->nm_limpa_alfa($this->order_amt); }
      if (isset($this->lbs_ordere)) { $this->nm_limpa_alfa($this->lbs_ordere); }
      if (isset($this->lbs)) { $this->nm_limpa_alfa($this->lbs); }
      if (isset($this->lbs_open)) { $this->nm_limpa_alfa($this->lbs_open); }
      if (isset($this->lbs_dyed)) { $this->nm_limpa_alfa($this->lbs_dyed); }
      if (isset($this->adjustment)) { $this->nm_limpa_alfa($this->adjustment); }
      if (isset($this->inventory)) { $this->nm_limpa_alfa($this->inventory); }
      if (isset($this->pinv)) { $this->nm_limpa_alfa($this->pinv); }
      if (isset($this->knit_price)) { $this->nm_limpa_alfa($this->knit_price); }
      if (isset($this->cost_lb_k)) { $this->nm_limpa_alfa($this->cost_lb_k); }
      if (isset($this->totalkc)) { $this->nm_limpa_alfa($this->totalkc); }
      if (isset($this->cost_lb_y)) { $this->nm_limpa_alfa($this->cost_lb_y); }
      if (isset($this->cost_lb)) { $this->nm_limpa_alfa($this->cost_lb); }
      if (isset($this->status)) { $this->nm_limpa_alfa($this->status); }
      if (isset($this->amount)) { $this->nm_limpa_alfa($this->amount); }
      if (isset($this->roll_size)) { $this->nm_limpa_alfa($this->roll_size); }
      if (isset($this->spec)) { $this->nm_limpa_alfa($this->spec); }
      if (isset($this->mach)) { $this->nm_limpa_alfa($this->mach); }
      if (isset($this->production)) { $this->nm_limpa_alfa($this->production); }
      if (isset($this->ac)) { $this->nm_limpa_alfa($this->ac); }
      if (isset($this->lbs_rack)) { $this->nm_limpa_alfa($this->lbs_rack); }
      $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]['greige_greigepo_greige_form']['opc_edit'] = true;  
     if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_select'])) 
     {
        $this->nmgp_dados_select = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_select'];
     }
   }

   function loadFieldConfig()
   {
      $this->field_config = array();
      //-- date
      $this->field_config['date']                 = array();
      $this->field_config['date']['date_format']  = $_SESSION['scriptcase']['reg_conf']['date_format'];
      $this->field_config['date']['date_sep']     = $_SESSION['scriptcase']['reg_conf']['date_sep'];
      $this->field_config['date']['date_display'] = "ddmmaaaa";
      $this->new_date_format('DT', 'date');
      //-- top_lbs
      $this->field_config['top_lbs']               = array();
      $this->field_config['top_lbs']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['top_lbs']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['top_lbs']['symbol_dec'] = '';
      $this->field_config['top_lbs']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['top_lbs']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- top_ship
      $this->field_config['top_ship']               = array();
      $this->field_config['top_ship']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['top_ship']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['top_ship']['symbol_dec'] = '';
      $this->field_config['top_ship']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['top_ship']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- top_cost
      $this->field_config['top_cost']               = array();
      $this->field_config['top_cost']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['top_cost']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['top_cost']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['top_cost']['symbol_mon'] = '';
      $this->field_config['top_cost']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['top_cost']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- bot_lbs
      $this->field_config['bot_lbs']               = array();
      $this->field_config['bot_lbs']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['bot_lbs']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['bot_lbs']['symbol_dec'] = '';
      $this->field_config['bot_lbs']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['bot_lbs']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- bot_ship
      $this->field_config['bot_ship']               = array();
      $this->field_config['bot_ship']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['bot_ship']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['bot_ship']['symbol_dec'] = '';
      $this->field_config['bot_ship']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['bot_ship']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- bot_cost
      $this->field_config['bot_cost']               = array();
      $this->field_config['bot_cost']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['bot_cost']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['bot_cost']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['bot_cost']['symbol_mon'] = '';
      $this->field_config['bot_cost']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['bot_cost']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- order_amt
      $this->field_config['order_amt']               = array();
      $this->field_config['order_amt']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['order_amt']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['order_amt']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['order_amt']['symbol_mon'] = '';
      $this->field_config['order_amt']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['order_amt']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- lbs_ordere
      $this->field_config['lbs_ordere']               = array();
      $this->field_config['lbs_ordere']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs_ordere']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs_ordere']['symbol_dec'] = '';
      $this->field_config['lbs_ordere']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs_ordere']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- lbs
      $this->field_config['lbs']               = array();
      $this->field_config['lbs']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['lbs']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs']['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'];
      //-- lbs_dyed
      $this->field_config['lbs_dyed']               = array();
      $this->field_config['lbs_dyed']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs_dyed']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs_dyed']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['lbs_dyed']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs_dyed']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- adjustment
      $this->field_config['adjustment']               = array();
      $this->field_config['adjustment']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['adjustment']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['adjustment']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['adjustment']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['adjustment']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- inventory
      $this->field_config['inventory']               = array();
      $this->field_config['inventory']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['inventory']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['inventory']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['inventory']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['inventory']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- pinv
      $this->field_config['pinv']               = array();
      $this->field_config['pinv']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['pinv']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['pinv']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['pinv']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['pinv']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
      //-- knit_price
      $this->field_config['knit_price']               = array();
      $this->field_config['knit_price']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['knit_price']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['knit_price']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['knit_price']['symbol_mon'] = '';
      $this->field_config['knit_price']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['knit_price']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- cost_lb_k
      $this->field_config['cost_lb_k']               = array();
      $this->field_config['cost_lb_k']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['cost_lb_k']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['cost_lb_k']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['cost_lb_k']['symbol_mon'] = '';
      $this->field_config['cost_lb_k']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['cost_lb_k']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- totalkc
      $this->field_config['totalkc']               = array();
      $this->field_config['totalkc']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['totalkc']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['totalkc']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['totalkc']['symbol_mon'] = '';
      $this->field_config['totalkc']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['totalkc']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- cost_lb_y
      $this->field_config['cost_lb_y']               = array();
      $this->field_config['cost_lb_y']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['cost_lb_y']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['cost_lb_y']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['cost_lb_y']['symbol_mon'] = '';
      $this->field_config['cost_lb_y']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['cost_lb_y']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- cost_lb
      $this->field_config['cost_lb']               = array();
      $this->field_config['cost_lb']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['cost_lb']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['cost_lb']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['cost_lb']['symbol_mon'] = '';
      $this->field_config['cost_lb']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['cost_lb']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- amount
      $this->field_config['amount']               = array();
      $this->field_config['amount']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_val'];
      $this->field_config['amount']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit'];
      $this->field_config['amount']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_val'];
      $this->field_config['amount']['symbol_mon'] = '';
      $this->field_config['amount']['format_pos'] = $_SESSION['scriptcase']['reg_conf']['monet_f_pos'];
      $this->field_config['amount']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['monet_f_neg'];
      //-- lbs_rack
      $this->field_config['lbs_rack']               = array();
      $this->field_config['lbs_rack']['symbol_grp'] = $_SESSION['scriptcase']['reg_conf']['grup_num'];
      $this->field_config['lbs_rack']['symbol_fmt'] = $_SESSION['scriptcase']['reg_conf']['num_group_digit'];
      $this->field_config['lbs_rack']['symbol_dec'] = $_SESSION['scriptcase']['reg_conf']['dec_num'];
      $this->field_config['lbs_rack']['symbol_neg'] = $_SESSION['scriptcase']['reg_conf']['simb_neg'];
      $this->field_config['lbs_rack']['format_neg'] = $_SESSION['scriptcase']['reg_conf']['neg_num'];
   }

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


      $this->ini_controle();

      if ('' != $_SESSION['scriptcase']['change_regional_old'])
      {
          $_SESSION['scriptcase']['str_conf_reg'] = $_SESSION['scriptcase']['change_regional_old'];
          $this->Ini->regionalDefault($_SESSION['scriptcase']['str_conf_reg']);
          $this->loadFieldConfig();
          $this->nm_tira_formatacao();
          $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'] = '';
      }

//
//-----> 
//
      if ($this->NM_ajax_flag && 'validate_' == substr($this->NM_ajax_opcao, 0, 9))
      {
          if ('validate_p_o_number' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'p_o_number');
          }
          if ('validate_old_po' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'old_po');
          }
          if ('validate_date' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'date');
          }
          if ('validate_mill' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'mill');
          }
          if ('validate_ship_to' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'ship_to');
          }
          if ('validate_style' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'style');
          }
          if ('validate_new_style' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'new_style');
          }
          if ('validate_desc1' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'desc1');
          }
          if ('validate_desc2' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'desc2');
          }
          if ('validate_top_p_o_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'top_p_o_');
          }
          if ('validate_top_lbs' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'top_lbs');
          }
          if ('validate_top_ship' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'top_ship');
          }
          if ('validate_top_cost' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'top_cost');
          }
          if ('validate_bot_p_o_' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'bot_p_o_');
          }
          if ('validate_bot_lbs' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'bot_lbs');
          }
          if ('validate_bot_ship' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'bot_ship');
          }
          if ('validate_bot_cost' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'bot_cost');
          }
          if ('validate_terms' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'terms');
          }
          if ('validate_delivery' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'delivery');
          }
          if ('validate_order_amt' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'order_amt');
          }
          if ('validate_lbs_ordere' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_ordere');
          }
          if ('validate_lbs' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs');
          }
          if ('validate_lbs_open' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_open');
          }
          if ('validate_lbs_dyed' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_dyed');
          }
          if ('validate_adjustment' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'adjustment');
          }
          if ('validate_inventory' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'inventory');
          }
          if ('validate_pinv' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'pinv');
          }
          if ('validate_knit_price' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'knit_price');
          }
          if ('validate_cost_lb_k' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'cost_lb_k');
          }
          if ('validate_totalkc' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'totalkc');
          }
          if ('validate_cost_lb_y' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'cost_lb_y');
          }
          if ('validate_cost_lb' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'cost_lb');
          }
          if ('validate_status' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'status');
          }
          if ('validate_amount' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'amount');
          }
          if ('validate_roll_size' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'roll_size');
          }
          if ('validate_spec' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'spec');
          }
          if ('validate_mach' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'mach');
          }
          if ('validate_production' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'production');
          }
          if ('validate_ac' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'ac');
          }
          if ('validate_lbs_rack' == $this->NM_ajax_opcao)
          {
              $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros, 'lbs_rack');
          }
          greige_greigepo_greige_form_pack_ajax_response();
          exit;
      }
      if (isset($this->sc_inline_call) && 'Y' == $this->sc_inline_call)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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();
              greige_greigepo_greige_form_pack_ajax_response();
              exit;
          }
          $this->nm_formatar_campos();
          $this->nmgp_opcao = $nm_sc_sv_opcao; 
          $this->nm_gera_html();
          $this->NM_close_db(); 
          $this->nmgp_opcao = ""; 
          exit; 
      }
      if ($this->nmgp_opcao == "incluir" || $this->nmgp_opcao == "alterar" || $this->nmgp_opcao == "excluir") 
      {
          $this->Valida_campos($Campos_Crit, $Campos_Falta, $Campos_Erros) ; 
          $_SESSION['scriptcase']['greige_greigepo_greige_form']['contr_erro'] = 'off';
          if ($Campos_Crit != "") 
          {
              $Campos_Crit = $this->Ini->Nm_lang['lang_errm_flds'] . ' ' . $Campos_Crit ; 
          }
          if ($Campos_Crit != "" || !empty($Campos_Falta) || $this->Campos_Mens_erro != "")
          {
              if ($this->NM_ajax_flag)
              {
                  greige_greigepo_greige_form_pack_ajax_response();
                  exit;
              }
              $campos_erro = $this->Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros);
              $this->Campos_Mens_erro = ""; 
              $this->Erro->mensagem(__FILE__, __LINE__, "critica", $campos_erro); 
              $this->nmgp_opc_ant = $this->nmgp_opcao ; 
              if ($this->nmgp_opcao == "incluir" && $nm_apl_dependente == 1) 
              { 
                  $this->nm_flag_saida_novo = "S";; 
              }
              if ($this->nmgp_opcao == "incluir") 
              { 
                  $GLOBALS["erro_incl"] = 1; 
              }
              $this->nmgp_opcao = "nada" ; 
          }
      }
      elseif (isset($nm_form_submit) && $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();
           }
      }
      if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form" && !$this->Apl_com_erro)
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['recarga'] = $this->nmgp_opcao;
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['sc_redir_insert']) && $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['sc_redir_insert'] == "ok")
          {
              if ($this->sc_evento == "insert" || ($this->nmgp_opc_ant == "novo" && $this->nmgp_opcao == "novo" && $this->sc_evento == "novo"))
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['sc_redir_atualiz']) && $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['sc_redir_atualiz'] == "ok")
          {
              if ($this->sc_evento == "update")
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
              if ($this->sc_evento == "delete")
              {
                  $this->NM_close_db(); 
                  $this->nmgp_redireciona(2); 
              }
          }
      }
      if ($this->NM_ajax_flag && 'navigate_form' == $this->NM_ajax_opcao)
      {
          $this->ajax_return_values();
          $this->ajax_add_parameters();
          greige_greigepo_greige_form_pack_ajax_response();
          exit;
      }
      $this->nm_formatar_campos();
      if ($this->NM_ajax_flag)
      {
          $this->NM_ajax_info['result'] = 'OK';
          if ('alterar' == $this->NM_ajax_info['param']['nmgp_opcao'])
          {
              $this->NM_ajax_info['msgDisplay'] = NM_charset_to_utf8($this->Ini->Nm_lang['lang_othr_ajax_frmu']);
          }
          greige_greigepo_greige_form_pack_ajax_response();
          exit;
      }
      $this->nm_gera_html();
      $this->NM_close_db(); 
      $this->nmgp_opcao = ""; 
   }
//
//--------------------------------------------------------------------------------------
   function NM_has_trans()
   {
       return !in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access);
   }
//
//--------------------------------------------------------------------------------------
   function NM_commit_db()
   {
       if ($this->Ini->sc_tem_trans_banco && !$this->Embutida_proc)
       { 
           $this->Db->CommitTrans(); 
           $this->Ini->sc_tem_trans_banco = false;
       } 
   }
//
//--------------------------------------------------------------------------------------
   function NM_rollback_db()
   {
       if ($this->Ini->sc_tem_trans_banco && !$this->Embutida_proc)
       { 
           $this->Db->RollbackTrans(); 
           $this->Ini->sc_tem_trans_banco = false;
       } 
   }
//
//--------------------------------------------------------------------------------------
   function NM_close_db()
   {
       if ($this->Db && !$this->Embutida_proc)
       { 
           $this->Db->Close(); 
       } 
   }
//
//--------------------------------------------------------------------------------------
   function Formata_Erros($Campos_Crit, $Campos_Falta, $Campos_Erros, $mode = 3) 
   {
       switch ($mode)
       {
           case 1:
               $campos_erro = array();
               if (!empty($Campos_Crit))
               {
                   $campos_erro[] = $Campos_Crit;
               }
               if (!empty($Campos_Falta))
               {
                   $campos_erro[] = $this->Formata_Campos_Falta($Campos_Falta);
               }
               if (!empty($this->Campos_Mens_erro))
               {
                   $campos_erro[] = $this->Campos_Mens_erro;
               }
               return implode('<br />', $campos_erro);
               break;

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

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

   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 'p_o_number':
               return "P_O_NUMBER";
               break;
           case 'old_po':
               return "OLD_PO";
               break;
           case 'date':
               return "DATE";
               break;
           case 'mill':
               return "MILL";
               break;
           case 'ship_to':
               return "SHIP_TO";
               break;
           case 'style':
               return "STYLE";
               break;
           case 'new_style':
               return "NEW_STYLE";
               break;
           case 'desc1':
               return "DESC1";
               break;
           case 'desc2':
               return "DESC2";
               break;
           case 'top_p_o_':
               return "TOP_P_O_";
               break;
           case 'top_lbs':
               return "TOP_LBS";
               break;
           case 'top_ship':
               return "TOP_SHIP";
               break;
           case 'top_cost':
               return "TOP_COST";
               break;
           case 'bot_p_o_':
               return "BOT_P_O_";
               break;
           case 'bot_lbs':
               return "BOT_LBS";
               break;
           case 'bot_ship':
               return "BOT_SHIP";
               break;
           case 'bot_cost':
               return "BOT_COST";
               break;
           case 'terms':
               return "TERMS";
               break;
           case 'delivery':
               return "DELIVERY";
               break;
           case 'order_amt':
               return "ORDER_AMT";
               break;
           case 'lbs_ordere':
               return "LBS_ORDERE";
               break;
           case 'lbs':
               return "LBS";
               break;
           case 'lbs_open':
               return "LBS_OPEN";
               break;
           case 'lbs_dyed':
               return "LBS_DYED";
               break;
           case 'adjustment':
               return "ADJUSTMENT";
               break;
           case 'inventory':
               return "INVENTORY";
               break;
           case 'pinv':
               return "PINV";
               break;
           case 'knit_price':
               return "KNIT_PRICE";
               break;
           case 'cost_lb_k':
               return "COST_LB_K";
               break;
           case 'totalkc':
               return "TOTALKC";
               break;
           case 'cost_lb_y':
               return "COST_LB_Y";
               break;
           case 'cost_lb':
               return "COST_LB";
               break;
           case 'status':
               return "STATUS";
               break;
           case 'amount':
               return "AMOUNT";
               break;
           case 'roll_size':
               return "ROLL_SIZE";
               break;
           case 'spec':
               return "SPEC";
               break;
           case 'mach':
               return "MACH";
               break;
           case 'production':
               return "PRODUCTION";
               break;
           case 'ac':
               return "AC";
               break;
           case 'lbs_rack':
               return "LBS_RACK";
               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 || 'p_o_number' == $filtro)
        $this->ValidateField_p_o_number($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'old_po' == $filtro)
        $this->ValidateField_old_po($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'date' == $filtro)
        $this->ValidateField_date($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'mill' == $filtro)
        $this->ValidateField_mill($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'ship_to' == $filtro)
        $this->ValidateField_ship_to($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'style' == $filtro)
        $this->ValidateField_style($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'new_style' == $filtro)
        $this->ValidateField_new_style($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'desc1' == $filtro)
        $this->ValidateField_desc1($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'desc2' == $filtro)
        $this->ValidateField_desc2($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'top_p_o_' == $filtro)
        $this->ValidateField_top_p_o_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'top_lbs' == $filtro)
        $this->ValidateField_top_lbs($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'top_ship' == $filtro)
        $this->ValidateField_top_ship($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'top_cost' == $filtro)
        $this->ValidateField_top_cost($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'bot_p_o_' == $filtro)
        $this->ValidateField_bot_p_o_($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'bot_lbs' == $filtro)
        $this->ValidateField_bot_lbs($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'bot_ship' == $filtro)
        $this->ValidateField_bot_ship($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'bot_cost' == $filtro)
        $this->ValidateField_bot_cost($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'terms' == $filtro)
        $this->ValidateField_terms($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'delivery' == $filtro)
        $this->ValidateField_delivery($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'order_amt' == $filtro)
        $this->ValidateField_order_amt($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_ordere' == $filtro)
        $this->ValidateField_lbs_ordere($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs' == $filtro)
        $this->ValidateField_lbs($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_open' == $filtro)
        $this->ValidateField_lbs_open($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_dyed' == $filtro)
        $this->ValidateField_lbs_dyed($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'adjustment' == $filtro)
        $this->ValidateField_adjustment($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'inventory' == $filtro)
        $this->ValidateField_inventory($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'pinv' == $filtro)
        $this->ValidateField_pinv($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'knit_price' == $filtro)
        $this->ValidateField_knit_price($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'cost_lb_k' == $filtro)
        $this->ValidateField_cost_lb_k($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'totalkc' == $filtro)
        $this->ValidateField_totalkc($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'cost_lb_y' == $filtro)
        $this->ValidateField_cost_lb_y($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'cost_lb' == $filtro)
        $this->ValidateField_cost_lb($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'status' == $filtro)
        $this->ValidateField_status($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'amount' == $filtro)
        $this->ValidateField_amount($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'roll_size' == $filtro)
        $this->ValidateField_roll_size($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'spec' == $filtro)
        $this->ValidateField_spec($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'mach' == $filtro)
        $this->ValidateField_mach($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'production' == $filtro)
        $this->ValidateField_production($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'ac' == $filtro)
        $this->ValidateField_ac($Campos_Crit, $Campos_Falta, $Campos_Erros);
      if ('' == $filtro || 'lbs_rack' == $filtro)
        $this->ValidateField_lbs_rack($Campos_Crit, $Campos_Falta, $Campos_Erros);
//-- converter datas   
      $this->nm_converte_datas();
//---

      if (!isset($this->NM_ajax_flag) || 'validate_' != substr($this->NM_ajax_opcao, 0, 9))
      {
      $_SESSION['scriptcase']['greige_greigepo_greige_form']['contr_erro'] = 'on';
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    $original_lbs = $this->lbs;
    $original_lbs_open = $this->lbs_open;
    $original_lbs_ordere = $this->lbs_ordere;
}
 $this->lbs_open =$this->lbs_ordere -$this->lbs ;
if (isset($this->NM_ajax_flag) && $this->NM_ajax_flag)
{
    if (($original_lbs != $this->lbs || (isset($bFlagRead_lbs) && $bFlagRead_lbs)))
    {
        $this->ajax_return_values_lbs(true);
    }
    if (($original_lbs_open != $this->lbs_open || (isset($bFlagRead_lbs_open) && $bFlagRead_lbs_open)))
    {
        $this->ajax_return_values_lbs_open(true);
    }
    if (($original_lbs_ordere != $this->lbs_ordere || (isset($bFlagRead_lbs_ordere) && $bFlagRead_lbs_ordere)))
    {
        $this->ajax_return_values_lbs_ordere(true);
    }
}
$_SESSION['scriptcase']['greige_greigepo_greige_form']['contr_erro'] = 'off'; 
      }
      if (!empty($Campos_Crit) || !empty($Campos_Falta) || !empty($this->Campos_Mens_erro))
      {
          if (!empty($this->sc_force_zero))
          {
              foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
              {
                  eval('$this->' . $sc_force_zero_field . ' = "";');
                  unset($this->sc_force_zero[$i_force_zero]);
              }
          }
      }
   }

    function ValidateField_p_o_number(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          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_old_po(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->old_po) > 6) 
          { 
              $Campos_Crit .= "OLD_PO " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 6 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['old_po']))
              {
                  $Campos_Erros['old_po'] = array();
              }
              $Campos_Erros['old_po'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 6 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['old_po']) || !is_array($this->NM_ajax_info['errList']['old_po']))
              {
                  $this->NM_ajax_info['errList']['old_po'] = array();
              }
              $this->NM_ajax_info['errList']['old_po'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 6 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_old_po

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

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

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

    function ValidateField_style(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          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_new_style(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          if (NM_utf8_strlen($this->new_style) > 14) 
          { 
              $Campos_Crit .= "NEW_STYLE " . $this->Ini->Nm_lang['lang_errm_mxch'] . " 14 " . $this->Ini->Nm_lang['lang_errm_nchr']; 
              if (!isset($Campos_Erros['new_style']))
              {
                  $Campos_Erros['new_style'] = array();
              }
              $Campos_Erros['new_style'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 14 " . $this->Ini->Nm_lang['lang_errm_nchr'];
              if (!isset($this->NM_ajax_info['errList']['new_style']) || !is_array($this->NM_ajax_info['errList']['new_style']))
              {
                  $this->NM_ajax_info['errList']['new_style'] = array();
              }
              $this->NM_ajax_info['errList']['new_style'][] = $this->Ini->Nm_lang['lang_errm_mxch'] . " 14 " . $this->Ini->Nm_lang['lang_errm_nchr'];
          } 
      } 
    } // ValidateField_new_style

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    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 != "excluir") 
      { 
          if ($this->lbs_open != '')  
          { 
              $iTestSize = 12;
              if ('-' == substr($this->lbs_open, 0, 1))
              {
                  $iTestSize++;
              }
              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, 11, 0, -1000, 100000, "S") == 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_lbs_dyed(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->lbs_dyed == "")  
      { 
          $this->lbs_dyed = 0;
          $this->sc_force_zero[] = 'lbs_dyed';
      } 
      if (!empty($this->field_config['lbs_dyed']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_dyed, $this->field_config['lbs_dyed']['symbol_dec'], $this->field_config['lbs_dyed']['symbol_grp']) ; 
          if ('.' == substr($this->lbs_dyed, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->lbs_dyed, 1)))
              {
                  $this->lbs_dyed = '';
              }
              else
              {
                  $this->lbs_dyed = '0' . $this->lbs_dyed;
              }
          }
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->lbs_dyed != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->lbs_dyed) > $iTestSize)  
              { 
                  $Campos_Crit .= "LBS_DYED: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['lbs_dyed']))
                  {
                      $Campos_Erros['lbs_dyed'] = array();
                  }
                  $Campos_Erros['lbs_dyed'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['lbs_dyed']) || !is_array($this->NM_ajax_info['errList']['lbs_dyed']))
                  {
                      $this->NM_ajax_info['errList']['lbs_dyed'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_dyed'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->lbs_dyed, 8, 2, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "LBS_DYED; " ; 
                  if (!isset($Campos_Erros['lbs_dyed']))
                  {
                      $Campos_Erros['lbs_dyed'] = array();
                  }
                  $Campos_Erros['lbs_dyed'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['lbs_dyed']) || !is_array($this->NM_ajax_info['errList']['lbs_dyed']))
                  {
                      $this->NM_ajax_info['errList']['lbs_dyed'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_dyed'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_lbs_dyed

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    function ValidateField_ac(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->nmgp_opcao != "excluir") 
      { 
          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_lbs_rack(&$Campos_Crit, &$Campos_Falta, &$Campos_Erros)
    {
        global $teste_validade;
      if ($this->lbs_rack == "")  
      { 
          $this->lbs_rack = 0;
          $this->sc_force_zero[] = 'lbs_rack';
      } 
      if (!empty($this->field_config['lbs_rack']['symbol_dec']))
      {
          nm_limpa_valor($this->lbs_rack, $this->field_config['lbs_rack']['symbol_dec'], $this->field_config['lbs_rack']['symbol_grp']) ; 
          if ('.' == substr($this->lbs_rack, 0, 1))
          {
              if ('' == str_replace('0', '', substr($this->lbs_rack, 1)))
              {
                  $this->lbs_rack = '';
              }
              else
              {
                  $this->lbs_rack = '0' . $this->lbs_rack;
              }
          }
      }
      if ($this->nmgp_opcao != "excluir") 
      { 
          if ($this->lbs_rack != '')  
          { 
              $iTestSize = 11;
              if (strlen($this->lbs_rack) > $iTestSize)  
              { 
                  $Campos_Crit .= "LBS_RACK: " . $this->Ini->Nm_lang['lang_errm_size']; 
                  if (!isset($Campos_Erros['lbs_rack']))
                  {
                      $Campos_Erros['lbs_rack'] = array();
                  }
                  $Campos_Erros['lbs_rack'][] = $this->Ini->Nm_lang['lang_errm_size'];
                  if (!isset($this->NM_ajax_info['errList']['lbs_rack']) || !is_array($this->NM_ajax_info['errList']['lbs_rack']))
                  {
                      $this->NM_ajax_info['errList']['lbs_rack'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_rack'][] = $this->Ini->Nm_lang['lang_errm_size'];
              } 
              if ($teste_validade->Valor($this->lbs_rack, 6, 4, 0, 0, "N") == false)  
              { 
                  $Campos_Crit .= "LBS_RACK; " ; 
                  if (!isset($Campos_Erros['lbs_rack']))
                  {
                      $Campos_Erros['lbs_rack'] = array();
                  }
                  $Campos_Erros['lbs_rack'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
                  if (!isset($this->NM_ajax_info['errList']['lbs_rack']) || !is_array($this->NM_ajax_info['errList']['lbs_rack']))
                  {
                      $this->NM_ajax_info['errList']['lbs_rack'] = array();
                  }
                  $this->NM_ajax_info['errList']['lbs_rack'][] = "" . $this->Ini->Nm_lang['lang_errm_ajax_data'] . "";
              } 
          } 
      } 
    } // ValidateField_lbs_rack

    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['p_o_number'] = $this->p_o_number;
    $this->nmgp_dados_form['old_po'] = $this->old_po;
    $this->nmgp_dados_form['date'] = $this->date;
    $this->nmgp_dados_form['mill'] = $this->mill;
    $this->nmgp_dados_form['ship_to'] = $this->ship_to;
    $this->nmgp_dados_form['style'] = $this->style;
    $this->nmgp_dados_form['new_style'] = $this->new_style;
    $this->nmgp_dados_form['desc1'] = $this->desc1;
    $this->nmgp_dados_form['desc2'] = $this->desc2;
    $this->nmgp_dados_form['top_p_o_'] = $this->top_p_o_;
    $this->nmgp_dados_form['top_lbs'] = $this->top_lbs;
    $this->nmgp_dados_form['top_ship'] = $this->top_ship;
    $this->nmgp_dados_form['top_cost'] = $this->top_cost;
    $this->nmgp_dados_form['bot_p_o_'] = $this->bot_p_o_;
    $this->nmgp_dados_form['bot_lbs'] = $this->bot_lbs;
    $this->nmgp_dados_form['bot_ship'] = $this->bot_ship;
    $this->nmgp_dados_form['bot_cost'] = $this->bot_cost;
    $this->nmgp_dados_form['terms'] = $this->terms;
    $this->nmgp_dados_form['delivery'] = $this->delivery;
    $this->nmgp_dados_form['order_amt'] = $this->order_amt;
    $this->nmgp_dados_form['lbs_ordere'] = $this->lbs_ordere;
    $this->nmgp_dados_form['lbs'] = $this->lbs;
    $this->nmgp_dados_form['lbs_open'] = $this->lbs_open;
    $this->nmgp_dados_form['lbs_dyed'] = $this->lbs_dyed;
    $this->nmgp_dados_form['adjustment'] = $this->adjustment;
    $this->nmgp_dados_form['inventory'] = $this->inventory;
    $this->nmgp_dados_form['pinv'] = $this->pinv;
    $this->nmgp_dados_form['knit_price'] = $this->knit_price;
    $this->nmgp_dados_form['cost_lb_k'] = $this->cost_lb_k;
    $this->nmgp_dados_form['totalkc'] = $this->totalkc;
    $this->nmgp_dados_form['cost_lb_y'] = $this->cost_lb_y;
    $this->nmgp_dados_form['cost_lb'] = $this->cost_lb;
    $this->nmgp_dados_form['status'] = $this->status;
    $this->nmgp_dados_form['amount'] = $this->amount;
    $this->nmgp_dados_form['roll_size'] = $this->roll_size;
    $this->nmgp_dados_form['spec'] = $this->spec;
    $this->nmgp_dados_form['mach'] = $this->mach;
    $this->nmgp_dados_form['production'] = $this->production;
    $this->nmgp_dados_form['ac'] = $this->ac;
    $this->nmgp_dados_form['lbs_rack'] = $this->lbs_rack;
    $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_form'] = $this->nmgp_dados_form;
   }
   function nm_tira_formatacao()
   {
      global $nm_form_submit;
         $this->formatado = false;
      nm_limpa_data($this->date, $this->field_config['date']['date_sep']) ; 
      nm_limpa_numero($this->top_lbs, $this->field_config['top_lbs']['symbol_grp']) ; 
      nm_limpa_numero($this->top_ship, $this->field_config['top_ship']['symbol_grp']) ; 
      if (!empty($this->field_config['top_cost']['symbol_dec']))
      {
         $this->sc_remove_currency($this->top_cost, $this->field_config['top_cost']['symbol_dec'], $this->field_config['top_cost']['symbol_grp'], $this->field_config['top_cost']['symbol_mon']);
         nm_limpa_valor($this->top_cost, $this->field_config['top_cost']['symbol_dec'], $this->field_config['top_cost']['symbol_grp']);
      }
      nm_limpa_numero($this->bot_lbs, $this->field_config['bot_lbs']['symbol_grp']) ; 
      nm_limpa_numero($this->bot_ship, $this->field_config['bot_ship']['symbol_grp']) ; 
      if (!empty($this->field_config['bot_cost']['symbol_dec']))
      {
         $this->sc_remove_currency($this->bot_cost, $this->field_config['bot_cost']['symbol_dec'], $this->field_config['bot_cost']['symbol_grp'], $this->field_config['bot_cost']['symbol_mon']);
         nm_limpa_valor($this->bot_cost, $this->field_config['bot_cost']['symbol_dec'], $this->field_config['bot_cost']['symbol_grp']);
      }
      if (!empty($this->field_config['order_amt']['symbol_dec']))
      {
         $this->sc_remove_currency($this->order_amt, $this->field_config['order_amt']['symbol_dec'], $this->field_config['order_amt']['symbol_grp'], $this->field_config['order_amt']['symbol_mon']);
         nm_limpa_valor($this->order_amt, $this->field_config['order_amt']['symbol_dec'], $this->field_config['order_amt']['symbol_grp']);
      }
      nm_limpa_numero($this->lbs_ordere, $this->field_config['lbs_ordere']['symbol_grp']) ; 
      if (!empty($this->field_config['lbs']['symbol_dec']))
      {
         nm_limpa_valor($this->lbs, $this->field_config['lbs']['symbol_dec'], $this->field_config['lbs']['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['lbs_dyed']['symbol_dec']))
      {
         nm_limpa_valor($this->lbs_dyed, $this->field_config['lbs_dyed']['symbol_dec'], $this->field_config['lbs_dyed']['symbol_grp']);
      }
      if (!empty($this->field_config['adjustment']['symbol_dec']))
      {
         nm_limpa_valor($this->adjustment, $this->field_config['adjustment']['symbol_dec'], $this->field_config['adjustment']['symbol_grp']);
      }
      if (!empty($this->field_config['inventory']['symbol_dec']))
      {
         nm_limpa_valor($this->inventory, $this->field_config['inventory']['symbol_dec'], $this->field_config['inventory']['symbol_grp']);
      }
      if (!empty($this->field_config['pinv']['symbol_dec']))
      {
         nm_limpa_valor($this->pinv, $this->field_config['pinv']['symbol_dec'], $this->field_config['pinv']['symbol_grp']);
      }
      if (!empty($this->field_config['knit_price']['symbol_dec']))
      {
         $this->sc_remove_currency($this->knit_price, $this->field_config['knit_price']['symbol_dec'], $this->field_config['knit_price']['symbol_grp'], $this->field_config['knit_price']['symbol_mon']);
         nm_limpa_valor($this->knit_price, $this->field_config['knit_price']['symbol_dec'], $this->field_config['knit_price']['symbol_grp']);
      }
      if (!empty($this->field_config['cost_lb_k']['symbol_dec']))
      {
         $this->sc_remove_currency($this->cost_lb_k, $this->field_config['cost_lb_k']['symbol_dec'], $this->field_config['cost_lb_k']['symbol_grp'], $this->field_config['cost_lb_k']['symbol_mon']);
         nm_limpa_valor($this->cost_lb_k, $this->field_config['cost_lb_k']['symbol_dec'], $this->field_config['cost_lb_k']['symbol_grp']);
      }
      if (!empty($this->field_config['totalkc']['symbol_dec']))
      {
         $this->sc_remove_currency($this->totalkc, $this->field_config['totalkc']['symbol_dec'], $this->field_config['totalkc']['symbol_grp'], $this->field_config['totalkc']['symbol_mon']);
         nm_limpa_valor($this->totalkc, $this->field_config['totalkc']['symbol_dec'], $this->field_config['totalkc']['symbol_grp']);
      }
      if (!empty($this->field_config['cost_lb_y']['symbol_dec']))
      {
         $this->sc_remove_currency($this->cost_lb_y, $this->field_config['cost_lb_y']['symbol_dec'], $this->field_config['cost_lb_y']['symbol_grp'], $this->field_config['cost_lb_y']['symbol_mon']);
         nm_limpa_valor($this->cost_lb_y, $this->field_config['cost_lb_y']['symbol_dec'], $this->field_config['cost_lb_y']['symbol_grp']);
      }
      if (!empty($this->field_config['cost_lb']['symbol_dec']))
      {
         $this->sc_remove_currency($this->cost_lb, $this->field_config['cost_lb']['symbol_dec'], $this->field_config['cost_lb']['symbol_grp'], $this->field_config['cost_lb']['symbol_mon']);
         nm_limpa_valor($this->cost_lb, $this->field_config['cost_lb']['symbol_dec'], $this->field_config['cost_lb']['symbol_grp']);
      }
      if (!empty($this->field_config['amount']['symbol_dec']))
      {
         $this->sc_remove_currency($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp'], $this->field_config['amount']['symbol_mon']);
         nm_limpa_valor($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp']);
      }
      if (!empty($this->field_config['lbs_rack']['symbol_dec']))
      {
         nm_limpa_valor($this->lbs_rack, $this->field_config['lbs_rack']['symbol_dec'], $this->field_config['lbs_rack']['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 == "top_lbs")
      {
          nm_limpa_numero($this->top_lbs, $this->field_config['top_lbs']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "top_ship")
      {
          nm_limpa_numero($this->top_ship, $this->field_config['top_ship']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "top_cost")
      {
          if (!empty($this->field_config['top_cost']['symbol_dec']))
          {
             $this->sc_remove_currency($this->top_cost, $this->field_config['top_cost']['symbol_dec'], $this->field_config['top_cost']['symbol_grp'], $this->field_config['top_cost']['symbol_mon']);
             nm_limpa_valor($this->top_cost, $this->field_config['top_cost']['symbol_dec'], $this->field_config['top_cost']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "bot_lbs")
      {
          nm_limpa_numero($this->bot_lbs, $this->field_config['bot_lbs']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "bot_ship")
      {
          nm_limpa_numero($this->bot_ship, $this->field_config['bot_ship']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "bot_cost")
      {
          if (!empty($this->field_config['bot_cost']['symbol_dec']))
          {
             $this->sc_remove_currency($this->bot_cost, $this->field_config['bot_cost']['symbol_dec'], $this->field_config['bot_cost']['symbol_grp'], $this->field_config['bot_cost']['symbol_mon']);
             nm_limpa_valor($this->bot_cost, $this->field_config['bot_cost']['symbol_dec'], $this->field_config['bot_cost']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "order_amt")
      {
          if (!empty($this->field_config['order_amt']['symbol_dec']))
          {
             $this->sc_remove_currency($this->order_amt, $this->field_config['order_amt']['symbol_dec'], $this->field_config['order_amt']['symbol_grp'], $this->field_config['order_amt']['symbol_mon']);
             nm_limpa_valor($this->order_amt, $this->field_config['order_amt']['symbol_dec'], $this->field_config['order_amt']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "lbs_ordere")
      {
          nm_limpa_numero($this->lbs_ordere, $this->field_config['lbs_ordere']['symbol_grp']) ; 
      }
      if ($Nome_Campo == "lbs")
      {
          if (!empty($this->field_config['lbs']['symbol_dec']))
          {
             nm_limpa_valor($this->lbs, $this->field_config['lbs']['symbol_dec'], $this->field_config['lbs']['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 == "lbs_dyed")
      {
          if (!empty($this->field_config['lbs_dyed']['symbol_dec']))
          {
             nm_limpa_valor($this->lbs_dyed, $this->field_config['lbs_dyed']['symbol_dec'], $this->field_config['lbs_dyed']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "adjustment")
      {
          if (!empty($this->field_config['adjustment']['symbol_dec']))
          {
             nm_limpa_valor($this->adjustment, $this->field_config['adjustment']['symbol_dec'], $this->field_config['adjustment']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "inventory")
      {
          if (!empty($this->field_config['inventory']['symbol_dec']))
          {
             nm_limpa_valor($this->inventory, $this->field_config['inventory']['symbol_dec'], $this->field_config['inventory']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "pinv")
      {
          if (!empty($this->field_config['pinv']['symbol_dec']))
          {
             nm_limpa_valor($this->pinv, $this->field_config['pinv']['symbol_dec'], $this->field_config['pinv']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "knit_price")
      {
          if (!empty($this->field_config['knit_price']['symbol_dec']))
          {
             $this->sc_remove_currency($this->knit_price, $this->field_config['knit_price']['symbol_dec'], $this->field_config['knit_price']['symbol_grp'], $this->field_config['knit_price']['symbol_mon']);
             nm_limpa_valor($this->knit_price, $this->field_config['knit_price']['symbol_dec'], $this->field_config['knit_price']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "cost_lb_k")
      {
          if (!empty($this->field_config['cost_lb_k']['symbol_dec']))
          {
             $this->sc_remove_currency($this->cost_lb_k, $this->field_config['cost_lb_k']['symbol_dec'], $this->field_config['cost_lb_k']['symbol_grp'], $this->field_config['cost_lb_k']['symbol_mon']);
             nm_limpa_valor($this->cost_lb_k, $this->field_config['cost_lb_k']['symbol_dec'], $this->field_config['cost_lb_k']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "totalkc")
      {
          if (!empty($this->field_config['totalkc']['symbol_dec']))
          {
             $this->sc_remove_currency($this->totalkc, $this->field_config['totalkc']['symbol_dec'], $this->field_config['totalkc']['symbol_grp'], $this->field_config['totalkc']['symbol_mon']);
             nm_limpa_valor($this->totalkc, $this->field_config['totalkc']['symbol_dec'], $this->field_config['totalkc']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "cost_lb_y")
      {
          if (!empty($this->field_config['cost_lb_y']['symbol_dec']))
          {
             $this->sc_remove_currency($this->cost_lb_y, $this->field_config['cost_lb_y']['symbol_dec'], $this->field_config['cost_lb_y']['symbol_grp'], $this->field_config['cost_lb_y']['symbol_mon']);
             nm_limpa_valor($this->cost_lb_y, $this->field_config['cost_lb_y']['symbol_dec'], $this->field_config['cost_lb_y']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "cost_lb")
      {
          if (!empty($this->field_config['cost_lb']['symbol_dec']))
          {
             $this->sc_remove_currency($this->cost_lb, $this->field_config['cost_lb']['symbol_dec'], $this->field_config['cost_lb']['symbol_grp'], $this->field_config['cost_lb']['symbol_mon']);
             nm_limpa_valor($this->cost_lb, $this->field_config['cost_lb']['symbol_dec'], $this->field_config['cost_lb']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "amount")
      {
          if (!empty($this->field_config['amount']['symbol_dec']))
          {
             $this->sc_remove_currency($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp'], $this->field_config['amount']['symbol_mon']);
             nm_limpa_valor($this->amount, $this->field_config['amount']['symbol_dec'], $this->field_config['amount']['symbol_grp']);
          }
      }
      if ($Nome_Campo == "lbs_rack")
      {
          if (!empty($this->field_config['lbs_rack']['symbol_dec']))
          {
             nm_limpa_valor($this->lbs_rack, $this->field_config['lbs_rack']['symbol_dec'], $this->field_config['lbs_rack']['symbol_grp']);
          }
      }
   }
   function nm_formatar_campos($format_fields = array())
   {
      global $nm_form_submit;
     if (isset($this->formatado) && $this->formatado)
     {
         return;
     }
     $this->formatado = true;
      if ((!empty($this->date) && 'null' != $this->date) || (!empty($format_fields) && isset($format_fields['date'])))
      {
          nm_volta_data($this->date, $this->field_config['date']['date_format']) ; 
          nmgp_Form_Datas($this->date, $this->field_config['date']['date_format'], $this->field_config['date']['date_sep']) ;  
      }
      elseif ('null' == $this->date || '' == $this->date)
      {
          $this->date = '';
      }
      if (!empty($this->top_lbs) || (!empty($format_fields) && isset($format_fields['top_lbs'])))
      {
          nmgp_Form_Num_Val($this->top_lbs, $this->field_config['top_lbs']['symbol_grp'], $this->field_config['top_lbs']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['top_lbs']['symbol_fmt']) ; 
      }
      if (!empty($this->top_ship) || (!empty($format_fields) && isset($format_fields['top_ship'])))
      {
          nmgp_Form_Num_Val($this->top_ship, $this->field_config['top_ship']['symbol_grp'], $this->field_config['top_ship']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['top_ship']['symbol_fmt']) ; 
      }
      if (!empty($this->top_cost) || (!empty($format_fields) && isset($format_fields['top_cost'])))
      {
          nmgp_Form_Num_Val($this->top_cost, $this->field_config['top_cost']['symbol_grp'], $this->field_config['top_cost']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['top_cost']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['top_cost']['symbol_mon'];
          $this->sc_add_currency($this->top_cost, $sMonSymb, $this->field_config['top_cost']['format_pos']); 
      }
      if (!empty($this->bot_lbs) || (!empty($format_fields) && isset($format_fields['bot_lbs'])))
      {
          nmgp_Form_Num_Val($this->bot_lbs, $this->field_config['bot_lbs']['symbol_grp'], $this->field_config['bot_lbs']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['bot_lbs']['symbol_fmt']) ; 
      }
      if (!empty($this->bot_ship) || (!empty($format_fields) && isset($format_fields['bot_ship'])))
      {
          nmgp_Form_Num_Val($this->bot_ship, $this->field_config['bot_ship']['symbol_grp'], $this->field_config['bot_ship']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['bot_ship']['symbol_fmt']) ; 
      }
      if (!empty($this->bot_cost) || (!empty($format_fields) && isset($format_fields['bot_cost'])))
      {
          nmgp_Form_Num_Val($this->bot_cost, $this->field_config['bot_cost']['symbol_grp'], $this->field_config['bot_cost']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['bot_cost']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['bot_cost']['symbol_mon'];
          $this->sc_add_currency($this->bot_cost, $sMonSymb, $this->field_config['bot_cost']['format_pos']); 
      }
      if (!empty($this->order_amt) || (!empty($format_fields) && isset($format_fields['order_amt'])))
      {
          nmgp_Form_Num_Val($this->order_amt, $this->field_config['order_amt']['symbol_grp'], $this->field_config['order_amt']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['order_amt']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['order_amt']['symbol_mon'];
          $this->sc_add_currency($this->order_amt, $sMonSymb, $this->field_config['order_amt']['format_pos']); 
      }
      if (!empty($this->lbs_ordere) || (!empty($format_fields) && isset($format_fields['lbs_ordere'])))
      {
          nmgp_Form_Num_Val($this->lbs_ordere, $this->field_config['lbs_ordere']['symbol_grp'], $this->field_config['lbs_ordere']['symbol_dec'], "0", "S", "", "", "", "-", $this->field_config['lbs_ordere']['symbol_fmt']) ; 
      }
      if (!empty($this->lbs) || (!empty($format_fields) && isset($format_fields['lbs'])))
      {
          nmgp_Form_Num_Val($this->lbs, $this->field_config['lbs']['symbol_grp'], $this->field_config['lbs']['symbol_dec'], "3", "S", "", "", "", "-", $this->field_config['lbs']['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'], "0", "S", "", "", "", "-", $this->field_config['lbs_open']['symbol_fmt']) ; 
      }
      if (!empty($this->lbs_dyed) || (!empty($format_fields) && isset($format_fields['lbs_dyed'])))
      {
          nmgp_Form_Num_Val($this->lbs_dyed, $this->field_config['lbs_dyed']['symbol_grp'], $this->field_config['lbs_dyed']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['lbs_dyed']['symbol_fmt']) ; 
      }
      if (!empty($this->adjustment) || (!empty($format_fields) && isset($format_fields['adjustment'])))
      {
          nmgp_Form_Num_Val($this->adjustment, $this->field_config['adjustment']['symbol_grp'], $this->field_config['adjustment']['symbol_dec'], "3", "S", "", "", "", "-", $this->field_config['adjustment']['symbol_fmt']) ; 
      }
      if (!empty($this->inventory) || (!empty($format_fields) && isset($format_fields['inventory'])))
      {
          nmgp_Form_Num_Val($this->inventory, $this->field_config['inventory']['symbol_grp'], $this->field_config['inventory']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['inventory']['symbol_fmt']) ; 
      }
      if (!empty($this->pinv) || (!empty($format_fields) && isset($format_fields['pinv'])))
      {
          nmgp_Form_Num_Val($this->pinv, $this->field_config['pinv']['symbol_grp'], $this->field_config['pinv']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['pinv']['symbol_fmt']) ; 
      }
      if (!empty($this->knit_price) || (!empty($format_fields) && isset($format_fields['knit_price'])))
      {
          nmgp_Form_Num_Val($this->knit_price, $this->field_config['knit_price']['symbol_grp'], $this->field_config['knit_price']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['knit_price']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['knit_price']['symbol_mon'];
          $this->sc_add_currency($this->knit_price, $sMonSymb, $this->field_config['knit_price']['format_pos']); 
      }
      if (!empty($this->cost_lb_k) || (!empty($format_fields) && isset($format_fields['cost_lb_k'])))
      {
          nmgp_Form_Num_Val($this->cost_lb_k, $this->field_config['cost_lb_k']['symbol_grp'], $this->field_config['cost_lb_k']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['cost_lb_k']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['cost_lb_k']['symbol_mon'];
          $this->sc_add_currency($this->cost_lb_k, $sMonSymb, $this->field_config['cost_lb_k']['format_pos']); 
      }
      if (!empty($this->totalkc) || (!empty($format_fields) && isset($format_fields['totalkc'])))
      {
          nmgp_Form_Num_Val($this->totalkc, $this->field_config['totalkc']['symbol_grp'], $this->field_config['totalkc']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['totalkc']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['totalkc']['symbol_mon'];
          $this->sc_add_currency($this->totalkc, $sMonSymb, $this->field_config['totalkc']['format_pos']); 
      }
      if (!empty($this->cost_lb_y) || (!empty($format_fields) && isset($format_fields['cost_lb_y'])))
      {
          nmgp_Form_Num_Val($this->cost_lb_y, $this->field_config['cost_lb_y']['symbol_grp'], $this->field_config['cost_lb_y']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['cost_lb_y']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['cost_lb_y']['symbol_mon'];
          $this->sc_add_currency($this->cost_lb_y, $sMonSymb, $this->field_config['cost_lb_y']['format_pos']); 
      }
      if (!empty($this->cost_lb) || (!empty($format_fields) && isset($format_fields['cost_lb'])))
      {
          nmgp_Form_Num_Val($this->cost_lb, $this->field_config['cost_lb']['symbol_grp'], $this->field_config['cost_lb']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['cost_lb']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['cost_lb']['symbol_mon'];
          $this->sc_add_currency($this->cost_lb, $sMonSymb, $this->field_config['cost_lb']['format_pos']); 
      }
      if (!empty($this->amount) || (!empty($format_fields) && isset($format_fields['amount'])))
      {
          nmgp_Form_Num_Val($this->amount, $this->field_config['amount']['symbol_grp'], $this->field_config['amount']['symbol_dec'], "2", "S", "", "", "", "-", $this->field_config['amount']['symbol_fmt']) ; 
          $sMonSymb = $this->field_config['amount']['symbol_mon'];
          $this->sc_add_currency($this->amount, $sMonSymb, $this->field_config['amount']['format_pos']); 
      }
      if (!empty($this->lbs_rack) || (!empty($format_fields) && isset($format_fields['lbs_rack'])))
      {
          nmgp_Form_Num_Val($this->lbs_rack, $this->field_config['lbs_rack']['symbol_grp'], $this->field_config['lbs_rack']['symbol_dec'], "4", "S", "", "", "", "-", $this->field_config['lbs_rack']['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['date']['date_format'];
      if ($this->date != "")  
      { 
          nm_conv_data($this->date, $this->field_config['date']['date_format']) ; 
          $this->date_hora = "00:00:00:000" ; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres))
          {
              $this->date_hora = substr($this->date_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
          {
              $this->date_hora = substr($this->date_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
          {
              $this->date_hora = substr($this->date_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          {
              $this->date_hora = substr($this->date_hora, 0, -4);
          }
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          {
              $this->date_hora = substr($this->date_hora, 0, -4);
          }
      } 
      if ($this->date == "" && $use_null)  
      { 
          $this->date = "null" ; 
      } 
       $this->field_config['date']['date_format'] = $guarda_format_hora;
   }
   function nm_conv_data_db($dt_in, $form_in, $form_out, $replaces = array())
   {
       $dt_out = $dt_in;
       if (strtoupper($form_in) == "DB_FORMAT")
       {
           if ($dt_out == "null" || $dt_out == "")
           {
               $dt_out = "";
               return $dt_out;
           }
           $form_in = "AAAA-MM-DD";
       }
       if (strtoupper($form_out) == "DB_FORMAT")
       {
           if (empty($dt_out))
           {
               $dt_out = "null";
               return $dt_out;
           }
           $form_out = "AAAA-MM-DD";
       }
       nm_conv_form_data($dt_out, $form_in, $form_out, $replaces);
       return $dt_out;
   }

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

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

   function ajax_return_values()
   {
          $this->ajax_return_values_p_o_number();
          $this->ajax_return_values_old_po();
          $this->ajax_return_values_date();
          $this->ajax_return_values_mill();
          $this->ajax_return_values_ship_to();
          $this->ajax_return_values_style();
          $this->ajax_return_values_new_style();
          $this->ajax_return_values_desc1();
          $this->ajax_return_values_desc2();
          $this->ajax_return_values_top_p_o_();
          $this->ajax_return_values_top_lbs();
          $this->ajax_return_values_top_ship();
          $this->ajax_return_values_top_cost();
          $this->ajax_return_values_bot_p_o_();
          $this->ajax_return_values_bot_lbs();
          $this->ajax_return_values_bot_ship();
          $this->ajax_return_values_bot_cost();
          $this->ajax_return_values_terms();
          $this->ajax_return_values_delivery();
          $this->ajax_return_values_order_amt();
          $this->ajax_return_values_lbs_ordere();
          $this->ajax_return_values_lbs();
          $this->ajax_return_values_lbs_open();
          $this->ajax_return_values_lbs_dyed();
          $this->ajax_return_values_adjustment();
          $this->ajax_return_values_inventory();
          $this->ajax_return_values_pinv();
          $this->ajax_return_values_knit_price();
          $this->ajax_return_values_cost_lb_k();
          $this->ajax_return_values_totalkc();
          $this->ajax_return_values_cost_lb_y();
          $this->ajax_return_values_cost_lb();
          $this->ajax_return_values_status();
          $this->ajax_return_values_amount();
          $this->ajax_return_values_roll_size();
          $this->ajax_return_values_spec();
          $this->ajax_return_values_mach();
          $this->ajax_return_values_production();
          $this->ajax_return_values_ac();
          $this->ajax_return_values_lbs_rack();
          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']['p_o_number']['keyVal'] = greige_greigepo_greige_form_pack_protect_string($this->nmgp_dados_form['p_o_number']);
          }
   } // ajax_return_values

          //----- p_o_number
   function ajax_return_values_p_o_number($bForce = false)
   {
          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)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->p_o_number);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['p_o_number'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

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

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

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

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

          //----- style
   function ajax_return_values_style($bForce = false)
   {
          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)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->style);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['style'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          //----- lbs_open
   function ajax_return_values_lbs_open($bForce = false)
   {
          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)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->lbs_open);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['lbs_open'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          //----- ac
   function ajax_return_values_ac($bForce = false)
   {
          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)) || $bForce)
          {
              $sTmpValue = NM_charset_to_utf8($this->ac);
              $aLookup = array();
          $aLookupOrig = $aLookup;
          $this->NM_ajax_info['fldList']['ac'] = array(
                       'row'    => '',
               'type'    => 'text',
               'valList' => array($sTmpValue),
              );
          }
   }

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

   function ajax_add_parameters()
   {
   } // ajax_add_parameters
  function nm_proc_onload($bFormat = true)
  {
      $this->nm_guardar_campos();
      if ($bFormat) $this->nm_formatar_campos();
  }
//
//----------------------------------------------------
//-----> 
//----------------------------------------------------
//
   function nm_troca_decimal($sc_parm1, $sc_parm2) 
   { 
      $this->top_cost = str_replace($sc_parm1, $sc_parm2, $this->top_cost); 
      $this->bot_cost = str_replace($sc_parm1, $sc_parm2, $this->bot_cost); 
      $this->order_amt = str_replace($sc_parm1, $sc_parm2, $this->order_amt); 
      $this->lbs = str_replace($sc_parm1, $sc_parm2, $this->lbs); 
      $this->lbs_open = str_replace($sc_parm1, $sc_parm2, $this->lbs_open); 
      $this->lbs_dyed = str_replace($sc_parm1, $sc_parm2, $this->lbs_dyed); 
      $this->adjustment = str_replace($sc_parm1, $sc_parm2, $this->adjustment); 
      $this->inventory = str_replace($sc_parm1, $sc_parm2, $this->inventory); 
      $this->pinv = str_replace($sc_parm1, $sc_parm2, $this->pinv); 
      $this->knit_price = str_replace($sc_parm1, $sc_parm2, $this->knit_price); 
      $this->cost_lb_k = str_replace($sc_parm1, $sc_parm2, $this->cost_lb_k); 
      $this->totalkc = str_replace($sc_parm1, $sc_parm2, $this->totalkc); 
      $this->cost_lb_y = str_replace($sc_parm1, $sc_parm2, $this->cost_lb_y); 
      $this->cost_lb = str_replace($sc_parm1, $sc_parm2, $this->cost_lb); 
      $this->amount = str_replace($sc_parm1, $sc_parm2, $this->amount); 
      $this->lbs_rack = str_replace($sc_parm1, $sc_parm2, $this->lbs_rack); 
   } 
   function nm_poe_aspas_decimal() 
   { 
      $this->top_cost = "'" . $this->top_cost . "'";
      $this->bot_cost = "'" . $this->bot_cost . "'";
      $this->order_amt = "'" . $this->order_amt . "'";
      $this->lbs = "'" . $this->lbs . "'";
      $this->lbs_open = "'" . $this->lbs_open . "'";
      $this->lbs_dyed = "'" . $this->lbs_dyed . "'";
      $this->adjustment = "'" . $this->adjustment . "'";
      $this->inventory = "'" . $this->inventory . "'";
      $this->pinv = "'" . $this->pinv . "'";
      $this->knit_price = "'" . $this->knit_price . "'";
      $this->cost_lb_k = "'" . $this->cost_lb_k . "'";
      $this->totalkc = "'" . $this->totalkc . "'";
      $this->cost_lb_y = "'" . $this->cost_lb_y . "'";
      $this->cost_lb = "'" . $this->cost_lb . "'";
      $this->amount = "'" . $this->amount . "'";
      $this->lbs_rack = "'" . $this->lbs_rack . "'";
   } 
   function nm_tira_aspas_decimal() 
   { 
      $this->top_cost = str_replace("'", "", $this->top_cost); 
      $this->bot_cost = str_replace("'", "", $this->bot_cost); 
      $this->order_amt = str_replace("'", "", $this->order_amt); 
      $this->lbs = str_replace("'", "", $this->lbs); 
      $this->lbs_open = str_replace("'", "", $this->lbs_open); 
      $this->lbs_dyed = str_replace("'", "", $this->lbs_dyed); 
      $this->adjustment = str_replace("'", "", $this->adjustment); 
      $this->inventory = str_replace("'", "", $this->inventory); 
      $this->pinv = str_replace("'", "", $this->pinv); 
      $this->knit_price = str_replace("'", "", $this->knit_price); 
      $this->cost_lb_k = str_replace("'", "", $this->cost_lb_k); 
      $this->totalkc = str_replace("'", "", $this->totalkc); 
      $this->cost_lb_y = str_replace("'", "", $this->cost_lb_y); 
      $this->cost_lb = str_replace("'", "", $this->cost_lb); 
      $this->amount = str_replace("'", "", $this->amount); 
      $this->lbs_rack = str_replace("'", "", $this->lbs_rack); 
   } 
//----------- 


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

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

   function nm_acessa_banco() 
   { 
      global  $nm_form_submit, $teste_validade, $sc_where;
 
      $NM_val_null = array();
      $NM_val_form = array();
      $this->sc_erro_insert = "";
      $this->sc_erro_update = "";
      $this->sc_erro_delete = "";
      if (!empty($this->sc_force_zero))
      {
          foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
          {
              eval('if ($this->' . $sc_force_zero_field . ' == 0) {$this->' . $sc_force_zero_field . ' = "";}');
          }
      }
      $this->sc_force_zero = array();
      $SC_tem_cmp_update = true; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $salva_opcao = $this->nmgp_opcao; 
      if ($this->sc_evento != "novo") 
      { 
          $this->sc_evento = ""; 
      } 
      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['p_o_number'] = $this->p_o_number;
      $NM_val_form['old_po'] = $this->old_po;
      $NM_val_form['date'] = $this->date;
      $NM_val_form['mill'] = $this->mill;
      $NM_val_form['ship_to'] = $this->ship_to;
      $NM_val_form['style'] = $this->style;
      $NM_val_form['new_style'] = $this->new_style;
      $NM_val_form['desc1'] = $this->desc1;
      $NM_val_form['desc2'] = $this->desc2;
      $NM_val_form['top_p_o_'] = $this->top_p_o_;
      $NM_val_form['top_lbs'] = $this->top_lbs;
      $NM_val_form['top_ship'] = $this->top_ship;
      $NM_val_form['top_cost'] = $this->top_cost;
      $NM_val_form['bot_p_o_'] = $this->bot_p_o_;
      $NM_val_form['bot_lbs'] = $this->bot_lbs;
      $NM_val_form['bot_ship'] = $this->bot_ship;
      $NM_val_form['bot_cost'] = $this->bot_cost;
      $NM_val_form['terms'] = $this->terms;
      $NM_val_form['delivery'] = $this->delivery;
      $NM_val_form['order_amt'] = $this->order_amt;
      $NM_val_form['lbs_ordere'] = $this->lbs_ordere;
      $NM_val_form['lbs'] = $this->lbs;
      $NM_val_form['lbs_open'] = $this->lbs_open;
      $NM_val_form['lbs_dyed'] = $this->lbs_dyed;
      $NM_val_form['adjustment'] = $this->adjustment;
      $NM_val_form['inventory'] = $this->inventory;
      $NM_val_form['pinv'] = $this->pinv;
      $NM_val_form['knit_price'] = $this->knit_price;
      $NM_val_form['cost_lb_k'] = $this->cost_lb_k;
      $NM_val_form['totalkc'] = $this->totalkc;
      $NM_val_form['cost_lb_y'] = $this->cost_lb_y;
      $NM_val_form['cost_lb'] = $this->cost_lb;
      $NM_val_form['status'] = $this->status;
      $NM_val_form['amount'] = $this->amount;
      $NM_val_form['roll_size'] = $this->roll_size;
      $NM_val_form['spec'] = $this->spec;
      $NM_val_form['mach'] = $this->mach;
      $NM_val_form['production'] = $this->production;
      $NM_val_form['ac'] = $this->ac;
      $NM_val_form['lbs_rack'] = $this->lbs_rack;
      if ($this->top_lbs == "")  
      { 
          $this->top_lbs = 0;
          $this->sc_force_zero[] = 'top_lbs';
      } 
      if ($this->top_ship == "")  
      { 
          $this->top_ship = 0;
          $this->sc_force_zero[] = 'top_ship';
      } 
      if ($this->top_cost == "")  
      { 
          $this->top_cost = 0;
          $this->sc_force_zero[] = 'top_cost';
      } 
      if ($this->bot_lbs == "")  
      { 
          $this->bot_lbs = 0;
          $this->sc_force_zero[] = 'bot_lbs';
      } 
      if ($this->bot_ship == "")  
      { 
          $this->bot_ship = 0;
          $this->sc_force_zero[] = 'bot_ship';
      } 
      if ($this->bot_cost == "")  
      { 
          $this->bot_cost = 0;
          $this->sc_force_zero[] = 'bot_cost';
      } 
      if ($this->order_amt == "")  
      { 
          $this->order_amt = 0;
          $this->sc_force_zero[] = 'order_amt';
      } 
      if ($this->lbs_ordere == "")  
      { 
          $this->lbs_ordere = 0;
          $this->sc_force_zero[] = 'lbs_ordere';
      } 
      if ($this->lbs == "")  
      { 
          $this->lbs = 0;
          $this->sc_force_zero[] = 'lbs';
      } 
      if ($this->lbs_open == "")  
      { 
          $this->lbs_open = 0;
          $this->sc_force_zero[] = 'lbs_open';
      } 
      if ($this->lbs_dyed == "")  
      { 
          $this->lbs_dyed = 0;
          $this->sc_force_zero[] = 'lbs_dyed';
      } 
      if ($this->adjustment == "")  
      { 
          $this->adjustment = 0;
          $this->sc_force_zero[] = 'adjustment';
      } 
      if ($this->inventory == "")  
      { 
          $this->inventory = 0;
          $this->sc_force_zero[] = 'inventory';
      } 
      if ($this->pinv == "")  
      { 
          $this->pinv = 0;
          $this->sc_force_zero[] = 'pinv';
      } 
      if ($this->knit_price == "")  
      { 
          $this->knit_price = 0;
          $this->sc_force_zero[] = 'knit_price';
      } 
      if ($this->cost_lb_k == "")  
      { 
          $this->cost_lb_k = 0;
          $this->sc_force_zero[] = 'cost_lb_k';
      } 
      if ($this->totalkc == "")  
      { 
          $this->totalkc = 0;
          $this->sc_force_zero[] = 'totalkc';
      } 
      if ($this->cost_lb_y == "")  
      { 
          $this->cost_lb_y = 0;
          $this->sc_force_zero[] = 'cost_lb_y';
      } 
      if ($this->cost_lb == "")  
      { 
          $this->cost_lb = 0;
          $this->sc_force_zero[] = 'cost_lb';
      } 
      if ($this->amount == "")  
      { 
          $this->amount = 0;
          $this->sc_force_zero[] = 'amount';
      } 
      if ($this->lbs_rack == "")  
      { 
          $this->lbs_rack = 0;
          $this->sc_force_zero[] = 'lbs_rack';
      } 
      $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]['greige_greigepo_greige_form']['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";
          } 
          if ($this->date == "")  
          { 
              $this->date = "null"; 
              $NM_val_null[] = "date";
          } 
          $this->mill = substr($this->Db->qstr($this->mill), 1, -1); 
          if ($this->mill == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->mill = "null"; 
              $NM_val_null[] = "mill";
          } 
          $this->ship_to = substr($this->Db->qstr($this->ship_to), 1, -1); 
          if ($this->ship_to == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->ship_to = "null"; 
              $NM_val_null[] = "ship_to";
          } 
          $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->new_style = substr($this->Db->qstr($this->new_style), 1, -1); 
          if ($this->new_style == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->new_style = "null"; 
              $NM_val_null[] = "new_style";
          } 
          $this->desc1 = substr($this->Db->qstr($this->desc1), 1, -1); 
          if ($this->desc1 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->desc1 = "null"; 
              $NM_val_null[] = "desc1";
          } 
          $this->desc2 = substr($this->Db->qstr($this->desc2), 1, -1); 
          if ($this->desc2 == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->desc2 = "null"; 
              $NM_val_null[] = "desc2";
          } 
          $this->top_p_o_ = substr($this->Db->qstr($this->top_p_o_), 1, -1); 
          if ($this->top_p_o_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->top_p_o_ = "null"; 
              $NM_val_null[] = "top_p_o_";
          } 
          $this->bot_p_o_ = substr($this->Db->qstr($this->bot_p_o_), 1, -1); 
          if ($this->bot_p_o_ == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->bot_p_o_ = "null"; 
              $NM_val_null[] = "bot_p_o_";
          } 
          $this->terms = substr($this->Db->qstr($this->terms), 1, -1); 
          if ($this->terms == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->terms = "null"; 
              $NM_val_null[] = "terms";
          } 
          $this->delivery = substr($this->Db->qstr($this->delivery), 1, -1); 
          if ($this->delivery == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->delivery = "null"; 
              $NM_val_null[] = "delivery";
          } 
          $this->status = substr($this->Db->qstr($this->status), 1, -1); 
          if ($this->status == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->status = "null"; 
              $NM_val_null[] = "status";
          } 
          $this->roll_size = substr($this->Db->qstr($this->roll_size), 1, -1); 
          if ($this->roll_size == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->roll_size = "null"; 
              $NM_val_null[] = "roll_size";
          } 
          $this->spec = substr($this->Db->qstr($this->spec), 1, -1); 
          if ($this->spec == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->spec = "null"; 
              $NM_val_null[] = "spec";
          } 
          $this->mach = substr($this->Db->qstr($this->mach), 1, -1); 
          if ($this->mach == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->mach = "null"; 
              $NM_val_null[] = "mach";
          } 
          $this->production = substr($this->Db->qstr($this->production), 1, -1); 
          if ($this->production == "" && in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))  
          { 
              $this->production = "null"; 
              $NM_val_null[] = "production";
          } 
          $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") 
      {
          $SC_ex_update = true; 
          $SC_ex_upd_or = true; 
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['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 P_O_NUMBER = '$this->p_o_number' ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number' ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number' ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number' ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' ";
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              if ($this->NM_ajax_flag)
              {
                 greige_greigepo_greige_form_pack_ajax_response();
              }
              exit; 
          }  
          $bUpdateOk = true;
          $tmp_result = (int) $rs1->fields[0]; 
          if ($tmp_result != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_nfnd']); 
              $this->nmgp_opcao = "nada"; 
              $bUpdateOk = false;
              $this->sc_evento = 'update';
          } 
          $aUpdateOk = array();
          $bUpdateOk = $bUpdateOk && empty($aUpdateOk);
          if ($bUpdateOk)
          { 
              $rs1->Close(); 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET OLD_PO = '$this->old_po', `DATE` = #$this->date#, MILL = '$this->mill', SHIP_TO = '$this->ship_to', STYLE = '$this->style', NEW_STYLE = '$this->new_style', DESC1 = '$this->desc1', DESC2 = '$this->desc2', TOP_P_O_ = '$this->top_p_o_', TOP_LBS = $this->top_lbs, TOP_SHIP = $this->top_ship, TOP_COST = $this->top_cost, BOT_P_O_ = '$this->bot_p_o_', BOT_LBS = $this->bot_lbs, BOT_SHIP = $this->bot_ship, BOT_COST = $this->bot_cost, TERMS = '$this->terms', DELIVERY = '$this->delivery', ORDER_AMT = $this->order_amt, LBS_ORDERE = $this->lbs_ordere, LBS = $this->lbs, LBS_DYED = $this->lbs_dyed, ADJUSTMENT = $this->adjustment, INVENTORY = $this->inventory, PINV = $this->pinv, KNIT_PRICE = $this->knit_price, COST_LB_K = $this->cost_lb_k, TOTALKC = $this->totalkc, COST_LB_Y = $this->cost_lb_y, COST_LB = $this->cost_lb, STATUS = '$this->status', AMOUNT = $this->amount, ROLL_SIZE = '$this->roll_size', SPEC = '$this->spec', MACH = '$this->mach', PRODUCTION = '$this->production', AC = '$this->ac', LBS_RACK = $this->lbs_rack";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET OLD_PO = '$this->old_po', `DATE` = '$this->date', MILL = '$this->mill', SHIP_TO = '$this->ship_to', STYLE = '$this->style', NEW_STYLE = '$this->new_style', DESC1 = '$this->desc1', DESC2 = '$this->desc2', TOP_P_O_ = '$this->top_p_o_', TOP_LBS = $this->top_lbs, TOP_SHIP = $this->top_ship, TOP_COST = $this->top_cost, BOT_P_O_ = '$this->bot_p_o_', BOT_LBS = $this->bot_lbs, BOT_SHIP = $this->bot_ship, BOT_COST = $this->bot_cost, TERMS = '$this->terms', DELIVERY = '$this->delivery', ORDER_AMT = $this->order_amt, LBS_ORDERE = $this->lbs_ordere, LBS = $this->lbs, LBS_DYED = $this->lbs_dyed, ADJUSTMENT = $this->adjustment, INVENTORY = $this->inventory, PINV = $this->pinv, KNIT_PRICE = $this->knit_price, COST_LB_K = $this->cost_lb_k, TOTALKC = $this->totalkc, COST_LB_Y = $this->cost_lb_y, COST_LB = $this->cost_lb, STATUS = '$this->status', AMOUNT = $this->amount, ROLL_SIZE = '$this->roll_size', SPEC = '$this->spec', MACH = '$this->mach', PRODUCTION = '$this->production', AC = '$this->ac', LBS_RACK = $this->lbs_rack";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET OLD_PO = '$this->old_po', `DATE` = '$this->date', MILL = '$this->mill', SHIP_TO = '$this->ship_to', STYLE = '$this->style', NEW_STYLE = '$this->new_style', DESC1 = '$this->desc1', DESC2 = '$this->desc2', TOP_P_O_ = '$this->top_p_o_', TOP_LBS = $this->top_lbs, TOP_SHIP = $this->top_ship, TOP_COST = $this->top_cost, BOT_P_O_ = '$this->bot_p_o_', BOT_LBS = $this->bot_lbs, BOT_SHIP = $this->bot_ship, BOT_COST = $this->bot_cost, TERMS = '$this->terms', DELIVERY = '$this->delivery', ORDER_AMT = $this->order_amt, LBS_ORDERE = $this->lbs_ordere, LBS = $this->lbs, LBS_DYED = $this->lbs_dyed, ADJUSTMENT = $this->adjustment, INVENTORY = $this->inventory, PINV = $this->pinv, KNIT_PRICE = $this->knit_price, COST_LB_K = $this->cost_lb_k, TOTALKC = $this->totalkc, COST_LB_Y = $this->cost_lb_y, COST_LB = $this->cost_lb, STATUS = '$this->status', AMOUNT = $this->amount, ROLL_SIZE = '$this->roll_size', SPEC = '$this->spec', MACH = '$this->mach', PRODUCTION = '$this->production', AC = '$this->ac', LBS_RACK = $this->lbs_rack";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET OLD_PO = '$this->old_po', `DATE` = EXTEND('$this->date', YEAR TO DAY), MILL = '$this->mill', SHIP_TO = '$this->ship_to', STYLE = '$this->style', NEW_STYLE = '$this->new_style', DESC1 = '$this->desc1', DESC2 = '$this->desc2', TOP_P_O_ = '$this->top_p_o_', TOP_LBS = $this->top_lbs, TOP_SHIP = $this->top_ship, TOP_COST = $this->top_cost, BOT_P_O_ = '$this->bot_p_o_', BOT_LBS = $this->bot_lbs, BOT_SHIP = $this->bot_ship, BOT_COST = $this->bot_cost, TERMS = '$this->terms', DELIVERY = '$this->delivery', ORDER_AMT = $this->order_amt, LBS_ORDERE = $this->lbs_ordere, LBS = $this->lbs, LBS_DYED = $this->lbs_dyed, ADJUSTMENT = $this->adjustment, INVENTORY = $this->inventory, PINV = $this->pinv, KNIT_PRICE = $this->knit_price, COST_LB_K = $this->cost_lb_k, TOTALKC = $this->totalkc, COST_LB_Y = $this->cost_lb_y, COST_LB = $this->cost_lb, STATUS = '$this->status', AMOUNT = $this->amount, ROLL_SIZE = '$this->roll_size', SPEC = '$this->spec', MACH = '$this->mach', PRODUCTION = '$this->production', AC = '$this->ac', LBS_RACK = $this->lbs_rack";  
              } 
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
              { 
                  $comando_oracle = "UPDATE " . $this->Ini->nm_tabela . " SET OLD_PO = '$this->old_po', `DATE` = '$this->date', MILL = '$this->mill', SHIP_TO = '$this->ship_to', STYLE = '$this->style', NEW_STYLE = '$this->new_style', DESC1 = '$this->desc1', DESC2 = '$this->desc2', TOP_P_O_ = '$this->top_p_o_', TOP_LBS = $this->top_lbs, TOP_SHIP = $this->top_ship, TOP_COST = $this->top_cost, BOT_P_O_ = '$this->bot_p_o_', BOT_LBS = $this->bot_lbs, BOT_SHIP = $this->bot_ship, BOT_COST = $this->bot_cost, TERMS = '$this->terms', DELIVERY = '$this->delivery', ORDER_AMT = $this->order_amt, LBS_ORDERE = $this->lbs_ordere, LBS = $this->lbs, LBS_DYED = $this->lbs_dyed, ADJUSTMENT = $this->adjustment, INVENTORY = $this->inventory, PINV = $this->pinv, KNIT_PRICE = $this->knit_price, COST_LB_K = $this->cost_lb_k, TOTALKC = $this->totalkc, COST_LB_Y = $this->cost_lb_y, COST_LB = $this->cost_lb, STATUS = '$this->status', AMOUNT = $this->amount, ROLL_SIZE = '$this->roll_size', SPEC = '$this->spec', MACH = '$this->mach', PRODUCTION = '$this->production', AC = '$this->ac', LBS_RACK = $this->lbs_rack";  
              } 
              else 
              { 
                  $comando = "UPDATE " . $this->Ini->nm_tabela . " SET OLD_PO = '$this->old_po', `DATE` = '$this->date', MILL = '$this->mill', SHIP_TO = '$this->ship_to', STYLE = '$this->style', NEW_STYLE = '$this->new_style', DESC1 = '$this->desc1', DESC2 = '$this->desc2', TOP_P_O_ = '$this->top_p_o_', TOP_LBS = $this->top_lbs, TOP_SHIP = $this->top_ship, TOP_COST = $this->top_cost, BOT_P_O_ = '$this->bot_p_o_', BOT_LBS = $this->bot_lbs, BOT_SHIP = $this->bot_ship, BOT_COST = $this->bot_cost, TERMS = '$this->terms', DELIVERY = '$this->delivery', ORDER_AMT = $this->order_amt, LBS_ORDERE = $this->lbs_ordere, LBS = $this->lbs, LBS_DYED = $this->lbs_dyed, ADJUSTMENT = $this->adjustment, INVENTORY = $this->inventory, PINV = $this->pinv, KNIT_PRICE = $this->knit_price, COST_LB_K = $this->cost_lb_k, TOTALKC = $this->totalkc, COST_LB_Y = $this->cost_lb_y, COST_LB = $this->cost_lb, STATUS = '$this->status', AMOUNT = $this->amount, ROLL_SIZE = '$this->roll_size', SPEC = '$this->spec', MACH = '$this->mach', PRODUCTION = '$this->production', AC = '$this->ac', LBS_RACK = $this->lbs_rack";  
              } 
              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 P_O_NUMBER = '$this->p_o_number' ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $comando .= " WHERE P_O_NUMBER = '$this->p_o_number' ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $comando .= " WHERE P_O_NUMBER = '$this->p_o_number' ";  
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $comando .= " WHERE P_O_NUMBER = '$this->p_o_number' ";  
              }  
              else  
              {
                  $comando .= " WHERE P_O_NUMBER = '$this->p_o_number' ";  
              }  
              $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)
                              {
                                  greige_greigepo_greige_form_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;
              }

              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['db_changed'] = 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['old_po'])) { $this->old_po = $NM_val_form['old_po']; }
              elseif (isset($this->old_po)) { $this->nm_limpa_alfa($this->old_po); }
              if     (isset($NM_val_form) && isset($NM_val_form['mill'])) { $this->mill = $NM_val_form['mill']; }
              elseif (isset($this->mill)) { $this->nm_limpa_alfa($this->mill); }
              if     (isset($NM_val_form) && isset($NM_val_form['ship_to'])) { $this->ship_to = $NM_val_form['ship_to']; }
              elseif (isset($this->ship_to)) { $this->nm_limpa_alfa($this->ship_to); }
              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['new_style'])) { $this->new_style = $NM_val_form['new_style']; }
              elseif (isset($this->new_style)) { $this->nm_limpa_alfa($this->new_style); }
              if     (isset($NM_val_form) && isset($NM_val_form['desc1'])) { $this->desc1 = $NM_val_form['desc1']; }
              elseif (isset($this->desc1)) { $this->nm_limpa_alfa($this->desc1); }
              if     (isset($NM_val_form) && isset($NM_val_form['desc2'])) { $this->desc2 = $NM_val_form['desc2']; }
              elseif (isset($this->desc2)) { $this->nm_limpa_alfa($this->desc2); }
              if     (isset($NM_val_form) && isset($NM_val_form['top_p_o_'])) { $this->top_p_o_ = $NM_val_form['top_p_o_']; }
              elseif (isset($this->top_p_o_)) { $this->nm_limpa_alfa($this->top_p_o_); }
              if     (isset($NM_val_form) && isset($NM_val_form['top_lbs'])) { $this->top_lbs = $NM_val_form['top_lbs']; }
              elseif (isset($this->top_lbs)) { $this->nm_limpa_alfa($this->top_lbs); }
              if     (isset($NM_val_form) && isset($NM_val_form['top_ship'])) { $this->top_ship = $NM_val_form['top_ship']; }
              elseif (isset($this->top_ship)) { $this->nm_limpa_alfa($this->top_ship); }
              if     (isset($NM_val_form) && isset($NM_val_form['top_cost'])) { $this->top_cost = $NM_val_form['top_cost']; }
              elseif (isset($this->top_cost)) { $this->nm_limpa_alfa($this->top_cost); }
              if     (isset($NM_val_form) && isset($NM_val_form['bot_p_o_'])) { $this->bot_p_o_ = $NM_val_form['bot_p_o_']; }
              elseif (isset($this->bot_p_o_)) { $this->nm_limpa_alfa($this->bot_p_o_); }
              if     (isset($NM_val_form) && isset($NM_val_form['bot_lbs'])) { $this->bot_lbs = $NM_val_form['bot_lbs']; }
              elseif (isset($this->bot_lbs)) { $this->nm_limpa_alfa($this->bot_lbs); }
              if     (isset($NM_val_form) && isset($NM_val_form['bot_ship'])) { $this->bot_ship = $NM_val_form['bot_ship']; }
              elseif (isset($this->bot_ship)) { $this->nm_limpa_alfa($this->bot_ship); }
              if     (isset($NM_val_form) && isset($NM_val_form['bot_cost'])) { $this->bot_cost = $NM_val_form['bot_cost']; }
              elseif (isset($this->bot_cost)) { $this->nm_limpa_alfa($this->bot_cost); }
              if     (isset($NM_val_form) && isset($NM_val_form['terms'])) { $this->terms = $NM_val_form['terms']; }
              elseif (isset($this->terms)) { $this->nm_limpa_alfa($this->terms); }
              if     (isset($NM_val_form) && isset($NM_val_form['delivery'])) { $this->delivery = $NM_val_form['delivery']; }
              elseif (isset($this->delivery)) { $this->nm_limpa_alfa($this->delivery); }
              if     (isset($NM_val_form) && isset($NM_val_form['order_amt'])) { $this->order_amt = $NM_val_form['order_amt']; }
              elseif (isset($this->order_amt)) { $this->nm_limpa_alfa($this->order_amt); }
              if     (isset($NM_val_form) && isset($NM_val_form['lbs_ordere'])) { $this->lbs_ordere = $NM_val_form['lbs_ordere']; }
              elseif (isset($this->lbs_ordere)) { $this->nm_limpa_alfa($this->lbs_ordere); }
              if     (isset($NM_val_form) && isset($NM_val_form['lbs'])) { $this->lbs = $NM_val_form['lbs']; }
              elseif (isset($this->lbs)) { $this->nm_limpa_alfa($this->lbs); }
              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['lbs_dyed'])) { $this->lbs_dyed = $NM_val_form['lbs_dyed']; }
              elseif (isset($this->lbs_dyed)) { $this->nm_limpa_alfa($this->lbs_dyed); }
              if     (isset($NM_val_form) && isset($NM_val_form['adjustment'])) { $this->adjustment = $NM_val_form['adjustment']; }
              elseif (isset($this->adjustment)) { $this->nm_limpa_alfa($this->adjustment); }
              if     (isset($NM_val_form) && isset($NM_val_form['inventory'])) { $this->inventory = $NM_val_form['inventory']; }
              elseif (isset($this->inventory)) { $this->nm_limpa_alfa($this->inventory); }
              if     (isset($NM_val_form) && isset($NM_val_form['pinv'])) { $this->pinv = $NM_val_form['pinv']; }
              elseif (isset($this->pinv)) { $this->nm_limpa_alfa($this->pinv); }
              if     (isset($NM_val_form) && isset($NM_val_form['knit_price'])) { $this->knit_price = $NM_val_form['knit_price']; }
              elseif (isset($this->knit_price)) { $this->nm_limpa_alfa($this->knit_price); }
              if     (isset($NM_val_form) && isset($NM_val_form['cost_lb_k'])) { $this->cost_lb_k = $NM_val_form['cost_lb_k']; }
              elseif (isset($this->cost_lb_k)) { $this->nm_limpa_alfa($this->cost_lb_k); }
              if     (isset($NM_val_form) && isset($NM_val_form['totalkc'])) { $this->totalkc = $NM_val_form['totalkc']; }
              elseif (isset($this->totalkc)) { $this->nm_limpa_alfa($this->totalkc); }
              if     (isset($NM_val_form) && isset($NM_val_form['cost_lb_y'])) { $this->cost_lb_y = $NM_val_form['cost_lb_y']; }
              elseif (isset($this->cost_lb_y)) { $this->nm_limpa_alfa($this->cost_lb_y); }
              if     (isset($NM_val_form) && isset($NM_val_form['cost_lb'])) { $this->cost_lb = $NM_val_form['cost_lb']; }
              elseif (isset($this->cost_lb)) { $this->nm_limpa_alfa($this->cost_lb); }
              if     (isset($NM_val_form) && isset($NM_val_form['status'])) { $this->status = $NM_val_form['status']; }
              elseif (isset($this->status)) { $this->nm_limpa_alfa($this->status); }
              if     (isset($NM_val_form) && isset($NM_val_form['amount'])) { $this->amount = $NM_val_form['amount']; }
              elseif (isset($this->amount)) { $this->nm_limpa_alfa($this->amount); }
              if     (isset($NM_val_form) && isset($NM_val_form['roll_size'])) { $this->roll_size = $NM_val_form['roll_size']; }
              elseif (isset($this->roll_size)) { $this->nm_limpa_alfa($this->roll_size); }
              if     (isset($NM_val_form) && isset($NM_val_form['spec'])) { $this->spec = $NM_val_form['spec']; }
              elseif (isset($this->spec)) { $this->nm_limpa_alfa($this->spec); }
              if     (isset($NM_val_form) && isset($NM_val_form['mach'])) { $this->mach = $NM_val_form['mach']; }
              elseif (isset($this->mach)) { $this->nm_limpa_alfa($this->mach); }
              if     (isset($NM_val_form) && isset($NM_val_form['production'])) { $this->production = $NM_val_form['production']; }
              elseif (isset($this->production)) { $this->nm_limpa_alfa($this->production); }
              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['lbs_rack'])) { $this->lbs_rack = $NM_val_form['lbs_rack']; }
              elseif (isset($this->lbs_rack)) { $this->nm_limpa_alfa($this->lbs_rack); }

              $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('p_o_number', 'old_po', 'date', 'mill', 'ship_to', 'style', 'new_style', 'desc1', 'desc2', 'top_p_o_', 'top_lbs', 'top_ship', 'top_cost', 'bot_p_o_', 'bot_lbs', 'bot_ship', 'bot_cost', 'terms', 'delivery', 'order_amt', 'lbs_ordere', 'lbs', 'lbs_open', 'lbs_dyed', 'adjustment', 'inventory', 'pinv', 'knit_price', 'cost_lb_k', 'totalkc', 'cost_lb_y', 'cost_lb', 'status', 'amount', 'roll_size', 'spec', 'mach', 'production', 'ac', 'lbs_rack');
              $this->ajax_return_values();
              $this->nmgp_refresh_fields = $aOldRefresh;

              $this->nm_tira_formatacao();
              $this->nm_converte_datas();
          }  
      }  
      if ($this->nmgp_opcao == "incluir") 
      { 
          $NM_cmp_auto = "";
          $NM_seq_auto = "";
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['decimal_db'] == ",") 
          {
              $this->nm_poe_aspas_decimal();
          }
          $bInsertOk = true;
          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 P_O_NUMBER = '$this->p_o_number' "; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number' "; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number' "; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number' "; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 != 0) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_pkey']); 
              $this->nmgp_opcao = "nada"; 
              $GLOBALS["erro_incl"] = 1; 
              $bInsertOk = false;
              $this->sc_evento = 'insert';
          } 
          $rs1->Close(); 
          $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, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK) VALUES ('$this->p_o_number', '$this->old_po', #$this->date#, '$this->mill', '$this->ship_to', '$this->style', '$this->new_style', '$this->desc1', '$this->desc2', '$this->top_p_o_', $this->top_lbs, $this->top_ship, $this->top_cost, '$this->bot_p_o_', $this->bot_lbs, $this->bot_ship, $this->bot_cost, '$this->terms', '$this->delivery', $this->order_amt, $this->lbs_ordere, $this->lbs, $this->lbs_dyed, $this->adjustment, $this->inventory, $this->pinv, $this->knit_price, $this->cost_lb_k, $this->totalkc, $this->cost_lb_y, $this->cost_lb, '$this->status', $this->amount, '$this->roll_size', '$this->spec', '$this->mach', '$this->production', '$this->ac', $this->lbs_rack)"; 
              }
              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, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK) VALUES (" . $NM_seq_auto . "'$this->p_o_number', '$this->old_po', '$this->date', '$this->mill', '$this->ship_to', '$this->style', '$this->new_style', '$this->desc1', '$this->desc2', '$this->top_p_o_', $this->top_lbs, $this->top_ship, $this->top_cost, '$this->bot_p_o_', $this->bot_lbs, $this->bot_ship, $this->bot_cost, '$this->terms', '$this->delivery', $this->order_amt, $this->lbs_ordere, $this->lbs, $this->lbs_dyed, $this->adjustment, $this->inventory, $this->pinv, $this->knit_price, $this->cost_lb_k, $this->totalkc, $this->cost_lb_y, $this->cost_lb, '$this->status', $this->amount, '$this->roll_size', '$this->spec', '$this->mach', '$this->production', '$this->ac', $this->lbs_rack)"; 
              }
              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, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK) VALUES (" . $NM_seq_auto . "'$this->p_o_number', '$this->old_po', '$this->date', '$this->mill', '$this->ship_to', '$this->style', '$this->new_style', '$this->desc1', '$this->desc2', '$this->top_p_o_', $this->top_lbs, $this->top_ship, $this->top_cost, '$this->bot_p_o_', $this->bot_lbs, $this->bot_ship, $this->bot_cost, '$this->terms', '$this->delivery', $this->order_amt, $this->lbs_ordere, $this->lbs, $this->lbs_dyed, $this->adjustment, $this->inventory, $this->pinv, $this->knit_price, $this->cost_lb_k, $this->totalkc, $this->cost_lb_y, $this->cost_lb, '$this->status', $this->amount, '$this->roll_size', '$this->spec', '$this->mach', '$this->production', '$this->ac', $this->lbs_rack)"; 
              }
              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, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK) VALUES (" . $NM_seq_auto . "'$this->p_o_number', '$this->old_po', EXTEND('$this->date', YEAR TO DAY), '$this->mill', '$this->ship_to', '$this->style', '$this->new_style', '$this->desc1', '$this->desc2', '$this->top_p_o_', $this->top_lbs, $this->top_ship, $this->top_cost, '$this->bot_p_o_', $this->bot_lbs, $this->bot_ship, $this->bot_cost, '$this->terms', '$this->delivery', $this->order_amt, $this->lbs_ordere, $this->lbs, $this->lbs_dyed, $this->adjustment, $this->inventory, $this->pinv, $this->knit_price, $this->cost_lb_k, $this->totalkc, $this->cost_lb_y, $this->cost_lb, '$this->status', $this->amount, '$this->roll_size', '$this->spec', '$this->mach', '$this->production', '$this->ac', $this->lbs_rack)"; 
              }
              else
              {
                  $comando = "INSERT INTO " . $this->Ini->nm_tabela . " (" . $NM_cmp_auto . "P_O_NUMBER, OLD_PO, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK) VALUES (" . $NM_seq_auto . "'$this->p_o_number', '$this->old_po', '$this->date', '$this->mill', '$this->ship_to', '$this->style', '$this->new_style', '$this->desc1', '$this->desc2', '$this->top_p_o_', $this->top_lbs, $this->top_ship, $this->top_cost, '$this->bot_p_o_', $this->bot_lbs, $this->bot_ship, $this->bot_cost, '$this->terms', '$this->delivery', $this->order_amt, $this->lbs_ordere, $this->lbs, $this->lbs_dyed, $this->adjustment, $this->inventory, $this->pinv, $this->knit_price, $this->cost_lb_k, $this->totalkc, $this->cost_lb_y, $this->cost_lb, '$this->status', $this->amount, '$this->roll_size', '$this->spec', '$this->mach', '$this->production', '$this->ac', $this->lbs_rack)"; 
              }
              $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)
                          {
                              greige_greigepo_greige_form_pack_ajax_response();
                              exit; 
                          }
                      }  
                  }  
              }  
              if ('refresh_insert' != $this->nmgp_opcao)
              {
              }

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

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

              $this->sc_evento = "insert"; 
              $this->sc_insert_on = true; 
              if ('refresh_insert' != $this->nmgp_opcao && (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['sc_redir_insert']) || $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['decimal_db'] == ",") 
      {
          $this->nm_tira_aspas_decimal();
      }
      if ($this->nmgp_opcao == "excluir") 
      { 
          $this->p_o_number = substr($this->Db->qstr($this->p_o_number), 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 P_O_NUMBER = '$this->p_o_number'"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number'"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number'"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          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 P_O_NUMBER = '$this->p_o_number'"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          else  
          {
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number'"; 
              $rs1 = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              exit; 
          }  
          if ($rs1 === false)  
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dbas'], $this->Db->ErrorMsg()); 
              exit; 
          }  
          $tmp_result = (int) $rs1->fields[0]; 
          if ($tmp_result != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_dele_nfnd']); 
              $this->nmgp_opcao = "nada"; 
              $this->sc_evento = 'delete';
          } 
          else 
          { 
              $rs1->Close(); 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
              }  
              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 P_O_NUMBER = '$this->p_o_number' "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
              }  
              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 P_O_NUMBER = '$this->p_o_number' "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
              }  
              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 P_O_NUMBER = '$this->p_o_number' "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
              }  
              else  
              {
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = "DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "; 
                  $rs = $this->Db->Execute("DELETE FROM " . $this->Ini->nm_tabela . " where P_O_NUMBER = '$this->p_o_number' "); 
              }  
              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)
                      {
                          greige_greigepo_greige_form_pack_ajax_response();
                          exit; 
                      }
                  } 
              } 
              $this->sc_evento = "delete"; 
              $this->nmgp_opcao = "avanca"; 
              $this->nm_flag_iframe = true;
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start']--; 
              if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] < 0)
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = 0; 
              }

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

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

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

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

      }  
      if (!empty($this->sc_force_zero))
      {
          foreach ($this->sc_force_zero as $i_force_zero => $sc_force_zero_field)
          {
              eval('if ($this->' . $sc_force_zero_field . ' == 0) {$this->' . $sc_force_zero_field . ' = "";}');
          }
      }
      $this->sc_force_zero = array();
      if (!empty($NM_val_null))
      {
          foreach ($NM_val_null as $i_val_null => $sc_val_null_field)
          {
              eval('$this->' . $sc_val_null_field . ' = "";');
          }
      }
      if ($salva_opcao == "incluir" && $GLOBALS["erro_incl"] != 1) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['parms'] = "p_o_number?#?$this->p_o_number?@?"; 
      }
      $this->NM_commit_db(); 
      if ($this->sc_evento != "insert" && $this->sc_evento != "update" && $this->sc_evento != "delete")
      { 
          $this->p_o_number = substr($this->Db->qstr($this->p_o_number), 1, -1); 
      } 
      if (isset($this->NM_where_filter))
      {
          $this->NM_where_filter = str_replace("@percent@", "%", $this->NM_where_filter);
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter'] = trim($this->NM_where_filter);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total']))
          {
              unset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total']);
          }
      }
      $sc_where_filter = '';
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter_form']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter_form'])
      {
          $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter_form'];
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter']) && '' != $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter'])
      {
          if (empty($sc_where_filter))
          {
              $sc_where_filter = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter'];
          }
          else
          {
              $sc_where_filter .= " and (" . $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter'] . ")";
          }
      }
//------------ 
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "R")
      {
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['iframe_evento'] == "insert") 
          { 
               $this->nmgp_opcao = "novo"; 
               $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['select'] = "";
          } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['iframe_evento'] = $this->sc_evento; 
      } 
      if (!isset($this->nmgp_opcao) || empty($this->nmgp_opcao)) 
      { 
          if (empty($this->p_o_number)) 
          { 
              $this->nmgp_opcao = "inicio"; 
          } 
          else 
          { 
              $this->nmgp_opcao = "igual"; 
          } 
      } 
      if (isset($_POST['master_nav']) && 'on' == $_POST['master_nav']) 
      { 
          $this->nmgp_opcao = "inicio";
      } 
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
      { 
          $GLOBALS["NM_ERRO_IBASE"] = 1;  
      } 
      if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "F" && $this->sc_evento == "insert")
      {
          $this->nmgp_opcao = "final";
      }
      $sc_where = trim("");
      if (substr(strtolower($sc_where), 0, 5) == "where")
      {
          $sc_where  = substr($sc_where , 5);
      }
      if (!empty($sc_where))
      {
          $sc_where = " where " . $sc_where . " ";
      }
      if ('' != $sc_where_filter)
      {
          $sc_where = ('' != $sc_where) ? $sc_where . ' and (' . $sc_where_filter . ')' : ' where ' . $sc_where_filter;
      }
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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_greige_greigepo_greige_form = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total'] = $qt_geral_reg_greige_greigepo_greige_form;
          $rt->Close(); 
          if ($this->nmgp_opcao == "igual" && isset($this->NM_btn_navega) && 'S' == $this->NM_btn_navega && !empty($this->p_o_number))
          {
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $Key_Where = "P_O_NUMBER < '$this->p_o_number' "; 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $Key_Where = "P_O_NUMBER < '$this->p_o_number' "; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $Key_Where = "P_O_NUMBER < '$this->p_o_number' "; 
              }
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $Key_Where = "P_O_NUMBER < '$this->p_o_number' "; 
              }
              else  
              {
                  $Key_Where = "P_O_NUMBER < '$this->p_o_number' "; 
              }
              $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]['greige_greigepo_greige_form']['reg_start'] = $rt->fields[0];
              $rt->Close(); 
          }
      } 
      else 
      { 
          $qt_geral_reg_greige_greigepo_greige_form = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total'];
      } 
      if ($this->nmgp_opcao == "inicio") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = 0; 
      } 
      if ($this->nmgp_opcao == "avanca")  
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start']++; 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] > $qt_geral_reg_greige_greigepo_greige_form)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = $qt_geral_reg_greige_greigepo_greige_form; 
          }
      } 
      if ($this->nmgp_opcao == "retorna") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start']--; 
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] < 0)
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = 0; 
          }
      } 
      if ($this->nmgp_opcao == "final") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = $qt_geral_reg_greige_greigepo_greige_form; 
      } 
      if ($this->nmgp_opcao == "navpage" && ($this->nmgp_ordem - 1) <= $qt_geral_reg_greige_greigepo_greige_form) 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = $this->nmgp_ordem - 1; 
      } 
      if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start']) || empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start']))
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] = 0;
      }
      $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] + 1;
      $this->NM_ajax_info['navSummary']['reg_ini'] = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] + 1; 
      $this->NM_ajax_info['navSummary']['reg_qtd'] = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_qtd']; 
      $this->NM_ajax_info['navSummary']['reg_tot'] = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total'] + 1; 
      $this->NM_gera_nav_page(); 
      $this->NM_ajax_info['navPage'] = $this->SC_nav_page; 
      $GLOBALS["NM_ERRO_IBASE"] = 0;  
//---------- 
      if ($this->nmgp_opcao != "novo" && $this->nmgp_opcao != "nada" && $this->nmgp_opcao != "refresh_insert") 
      { 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['parms'] = ""; 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase))
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 1;  
          } 
          if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
          { 
              $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, str_replace (convert(char(10),`DATE`,102), '.', '-') + ' ' + convert(char(8),`DATE`,20), MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_OPEN, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK from " . $this->Ini->nm_tabela ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          { 
              $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, convert(char(23),`DATE`,121), MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_OPEN, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK from " . $this->Ini->nm_tabela ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
          { 
              $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_OPEN, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK from " . $this->Ini->nm_tabela ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
          { 
              $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, EXTEND(`DATE`, YEAR TO DAY), MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_OPEN, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK from " . $this->Ini->nm_tabela ; 
          } 
          else 
          { 
              $nmgp_select = "SELECT P_O_NUMBER, OLD_PO, `DATE`, MILL, SHIP_TO, STYLE, NEW_STYLE, DESC1, DESC2, TOP_P_O_, TOP_LBS, TOP_SHIP, TOP_COST, BOT_P_O_, BOT_LBS, BOT_SHIP, BOT_COST, TERMS, DELIVERY, ORDER_AMT, LBS_ORDERE, LBS, LBS_OPEN, LBS_DYED, ADJUSTMENT, INVENTORY, PINV, KNIT_PRICE, COST_LB_K, TOTALKC, COST_LB_Y, COST_LB, STATUS, AMOUNT, ROLL_SIZE, SPEC, MACH, PRODUCTION, AC, LBS_RACK from " . $this->Ini->nm_tabela ; 
          } 
          $aWhere = array();
          $aWhere[] = $sc_where_filter;
          if ($this->nmgp_opcao == "igual" || (($_SESSION['sc_session'][$this->Ini->sc_page]['form_adm_clientes']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['form_adm_clientes']['run_iframe'] == "R") && ($this->sc_evento == "insert" || $this->sc_evento == "update")) )
          { 
              if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
              {
                  $aWhere[] = "P_O_NUMBER = '$this->p_o_number'"; 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
              {
                  $aWhere[] = "P_O_NUMBER = '$this->p_o_number'"; 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
              {
                  $aWhere[] = "P_O_NUMBER = '$this->p_o_number'"; 
              }  
              elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
              {
                  $aWhere[] = "P_O_NUMBER = '$this->p_o_number'"; 
              }  
              else  
              {
                  $aWhere[] = "P_O_NUMBER = '$this->p_o_number'"; 
              }  
              if (!empty($sc_where_filter))  
              {
                  $teste_select = $nmgp_select . $this->returnWhere($aWhere);
                  $_SESSION['scriptcase']['sc_sql_ult_comando'] = $teste_select; 
                  $rs = $this->Db->Execute($teste_select); 
                  if ($rs->EOF)
                  {
                     $aWhere = array($sc_where_filter);
                  }  
                  $rs->Close(); 
              }  
          } 
          $nmgp_select .= $this->returnWhere($aWhere) . ' ';
          $sc_order_by = "";
          $sc_order_by = "P_O_NUMBER";
          $sc_order_by = str_replace("order by ", "", $sc_order_by);
          $sc_order_by = str_replace("ORDER BY ", "", trim($sc_order_by));
          if (!empty($sc_order_by))
          {
              $nmgp_select .= " order by $sc_order_by "; 
          }
          if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "R")
          {
              if ($this->sc_evento == "update")
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['select'] = $nmgp_select;
                  $this->nm_gera_html();
              } 
              elseif (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['select']))
              { 
                  $nmgp_select = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['select'];
                  $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['select'] = ""; 
              } 
          } 
          if ($this->nmgp_opcao == "igual") 
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
              $rs = $this->Db->Execute($nmgp_select) ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_postgres) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_ibase) || in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_db2))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start']) ; 
          } 
          elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
          { 
              $_SESSION['scriptcase']['sc_sql_ult_comando'] = "SelectLimit($nmgp_select, 1, " . $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] . ")" ; 
              $rs = $this->Db->SelectLimit($nmgp_select, 1, $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['reg_start']) ;  
              } 
          } 
          if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
          { 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
              exit ; 
          }  
          if ($rs === false && $GLOBALS["NM_ERRO_IBASE"] == 1) 
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_nfnd_extr'], $this->Db->ErrorMsg()); 
              exit ; 
          }  
          if ($rs->EOF) 
          { 
              if ($this->nmgp_botoes['insert'] != "on")
              {
                  $this->nmgp_form_empty        = true;
                  $this->nmgp_botoes['first']   = "off";
                  $this->nmgp_botoes['back']    = "off";
                  $this->nmgp_botoes['forward'] = "off";
                  $this->nmgp_botoes['last']    = "off";
              }
              $this->nmgp_opcao = "novo"; 
              $this->nm_flag_saida_novo = "S"; 
              $rs->Close(); 
              if ($this->aba_iframe)
              {
                  $this->nmgp_botoes['exit'] = 'off';
              }
          } 
          if ($rs === false && $GLOBALS["NM_ERRO_IBASE"] == 1) 
          { 
              $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->Erro->mensagem (__FILE__, __LINE__, "critica", $this->Ini->Nm_lang['lang_errm_nfnd_extr']); 
              $this->nmgp_opcao = "novo"; 
          }  
          if ($this->nmgp_opcao != "novo") 
          { 
              $this->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->date = $rs->fields[2] ; 
              $this->nmgp_dados_select['date'] = $this->date;
              $this->mill = $rs->fields[3] ; 
              $this->nmgp_dados_select['mill'] = $this->mill;
              $this->ship_to = $rs->fields[4] ; 
              $this->nmgp_dados_select['ship_to'] = $this->ship_to;
              $this->style = $rs->fields[5] ; 
              $this->nmgp_dados_select['style'] = $this->style;
              $this->new_style = $rs->fields[6] ; 
              $this->nmgp_dados_select['new_style'] = $this->new_style;
              $this->desc1 = $rs->fields[7] ; 
              $this->nmgp_dados_select['desc1'] = $this->desc1;
              $this->desc2 = $rs->fields[8] ; 
              $this->nmgp_dados_select['desc2'] = $this->desc2;
              $this->top_p_o_ = $rs->fields[9] ; 
              $this->nmgp_dados_select['top_p_o_'] = $this->top_p_o_;
              $this->top_lbs = trim($rs->fields[10]) ; 
              $this->nmgp_dados_select['top_lbs'] = $this->top_lbs;
              $this->top_ship = trim($rs->fields[11]) ; 
              $this->nmgp_dados_select['top_ship'] = $this->top_ship;
              $this->top_cost = trim($rs->fields[12]) ; 
              $this->nmgp_dados_select['top_cost'] = $this->top_cost;
              $this->bot_p_o_ = $rs->fields[13] ; 
              $this->nmgp_dados_select['bot_p_o_'] = $this->bot_p_o_;
              $this->bot_lbs = trim($rs->fields[14]) ; 
              $this->nmgp_dados_select['bot_lbs'] = $this->bot_lbs;
              $this->bot_ship = trim($rs->fields[15]) ; 
              $this->nmgp_dados_select['bot_ship'] = $this->bot_ship;
              $this->bot_cost = trim($rs->fields[16]) ; 
              $this->nmgp_dados_select['bot_cost'] = $this->bot_cost;
              $this->terms = $rs->fields[17] ; 
              $this->nmgp_dados_select['terms'] = $this->terms;
              $this->delivery = $rs->fields[18] ; 
              $this->nmgp_dados_select['delivery'] = $this->delivery;
              $this->order_amt = trim($rs->fields[19]) ; 
              $this->nmgp_dados_select['order_amt'] = $this->order_amt;
              $this->lbs_ordere = $rs->fields[20] ; 
              $this->nmgp_dados_select['lbs_ordere'] = $this->lbs_ordere;
              $this->lbs = trim($rs->fields[21]) ; 
              $this->nmgp_dados_select['lbs'] = $this->lbs;
              $this->lbs_open = $rs->fields[22] ; 
              $this->nmgp_dados_select['lbs_open'] = $this->lbs_open;
              $this->lbs_dyed = trim($rs->fields[23]) ; 
              $this->nmgp_dados_select['lbs_dyed'] = $this->lbs_dyed;
              $this->adjustment = trim($rs->fields[24]) ; 
              $this->nmgp_dados_select['adjustment'] = $this->adjustment;
              $this->inventory = trim($rs->fields[25]) ; 
              $this->nmgp_dados_select['inventory'] = $this->inventory;
              $this->pinv = trim($rs->fields[26]) ; 
              $this->nmgp_dados_select['pinv'] = $this->pinv;
              $this->knit_price = trim($rs->fields[27]) ; 
              $this->nmgp_dados_select['knit_price'] = $this->knit_price;
              $this->cost_lb_k = trim($rs->fields[28]) ; 
              $this->nmgp_dados_select['cost_lb_k'] = $this->cost_lb_k;
              $this->totalkc = trim($rs->fields[29]) ; 
              $this->nmgp_dados_select['totalkc'] = $this->totalkc;
              $this->cost_lb_y = trim($rs->fields[30]) ; 
              $this->nmgp_dados_select['cost_lb_y'] = $this->cost_lb_y;
              $this->cost_lb = trim($rs->fields[31]) ; 
              $this->nmgp_dados_select['cost_lb'] = $this->cost_lb;
              $this->status = $rs->fields[32] ; 
              $this->nmgp_dados_select['status'] = $this->status;
              $this->amount = trim($rs->fields[33]) ; 
              $this->nmgp_dados_select['amount'] = $this->amount;
              $this->roll_size = $rs->fields[34] ; 
              $this->nmgp_dados_select['roll_size'] = $this->roll_size;
              $this->spec = $rs->fields[35] ; 
              $this->nmgp_dados_select['spec'] = $this->spec;
              $this->mach = $rs->fields[36] ; 
              $this->nmgp_dados_select['mach'] = $this->mach;
              $this->production = $rs->fields[37] ; 
              $this->nmgp_dados_select['production'] = $this->production;
              $this->ac = $rs->fields[38] ; 
              $this->nmgp_dados_select['ac'] = $this->ac;
              $this->lbs_rack = trim($rs->fields[39]) ; 
              $this->nmgp_dados_select['lbs_rack'] = $this->lbs_rack;
          $GLOBALS["NM_ERRO_IBASE"] = 0; 
              $this->nm_troca_decimal(",", ".");
              $this->top_lbs = (strpos(strtolower($this->top_lbs), "e")) ? (float)$this->top_lbs : $this->top_lbs; 
              $this->top_lbs = (string)$this->top_lbs; 
              $this->top_ship = (strpos(strtolower($this->top_ship), "e")) ? (float)$this->top_ship : $this->top_ship; 
              $this->top_ship = (string)$this->top_ship; 
              $this->top_cost = (strpos(strtolower($this->top_cost), "e")) ? (float)$this->top_cost : $this->top_cost; 
              $this->top_cost = (string)$this->top_cost; 
              $this->bot_lbs = (strpos(strtolower($this->bot_lbs), "e")) ? (float)$this->bot_lbs : $this->bot_lbs; 
              $this->bot_lbs = (string)$this->bot_lbs; 
              $this->bot_ship = (strpos(strtolower($this->bot_ship), "e")) ? (float)$this->bot_ship : $this->bot_ship; 
              $this->bot_ship = (string)$this->bot_ship; 
              $this->bot_cost = (strpos(strtolower($this->bot_cost), "e")) ? (float)$this->bot_cost : $this->bot_cost; 
              $this->bot_cost = (string)$this->bot_cost; 
              $this->order_amt = (strpos(strtolower($this->order_amt), "e")) ? (float)$this->order_amt : $this->order_amt; 
              $this->order_amt = (string)$this->order_amt; 
              $this->lbs_ordere = (string)$this->lbs_ordere; 
              $this->lbs = (strpos(strtolower($this->lbs), "e")) ? (float)$this->lbs : $this->lbs; 
              $this->lbs = (string)$this->lbs; 
              $this->lbs_open = (string)$this->lbs_open; 
              $this->lbs_dyed = (strpos(strtolower($this->lbs_dyed), "e")) ? (float)$this->lbs_dyed : $this->lbs_dyed; 
              $this->lbs_dyed = (string)$this->lbs_dyed; 
              $this->adjustment = (strpos(strtolower($this->adjustment), "e")) ? (float)$this->adjustment : $this->adjustment; 
              $this->adjustment = (string)$this->adjustment; 
              $this->inventory = (strpos(strtolower($this->inventory), "e")) ? (float)$this->inventory : $this->inventory; 
              $this->inventory = (string)$this->inventory; 
              $this->pinv = (strpos(strtolower($this->pinv), "e")) ? (float)$this->pinv : $this->pinv; 
              $this->pinv = (string)$this->pinv; 
              $this->knit_price = (strpos(strtolower($this->knit_price), "e")) ? (float)$this->knit_price : $this->knit_price; 
              $this->knit_price = (string)$this->knit_price; 
              $this->cost_lb_k = (strpos(strtolower($this->cost_lb_k), "e")) ? (float)$this->cost_lb_k : $this->cost_lb_k; 
              $this->cost_lb_k = (string)$this->cost_lb_k; 
              $this->totalkc = (strpos(strtolower($this->totalkc), "e")) ? (float)$this->totalkc : $this->totalkc; 
              $this->totalkc = (string)$this->totalkc; 
              $this->cost_lb_y = (strpos(strtolower($this->cost_lb_y), "e")) ? (float)$this->cost_lb_y : $this->cost_lb_y; 
              $this->cost_lb_y = (string)$this->cost_lb_y; 
              $this->cost_lb = (strpos(strtolower($this->cost_lb), "e")) ? (float)$this->cost_lb : $this->cost_lb; 
              $this->cost_lb = (string)$this->cost_lb; 
              $this->amount = (strpos(strtolower($this->amount), "e")) ? (float)$this->amount : $this->amount; 
              $this->amount = (string)$this->amount; 
              $this->lbs_rack = (strpos(strtolower($this->lbs_rack), "e")) ? (float)$this->lbs_rack : $this->lbs_rack; 
              $this->lbs_rack = (string)$this->lbs_rack; 
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['parms'] = "p_o_number?#?$this->p_o_number?@?";
          } 
          $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['dados_select'] = $this->nmgp_dados_select;
          if (!$this->NM_ajax_flag || 'backup_line' != $this->NM_ajax_opcao)
          {
              $this->Nav_permite_ret = 0 != $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'];
              $this->Nav_permite_ava = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] < $qt_geral_reg_greige_greigepo_greige_form;
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['opcao']   = '';
          }
      } 
      if ($this->nmgp_opcao == "novo" || $this->nmgp_opcao == "refresh_insert") 
      { 
          $this->sc_evento_old = $this->sc_evento;
          $this->sc_evento = "novo";
          if ('refresh_insert' == $this->nmgp_opcao)
          {
              $this->nmgp_opcao = 'novo';
          }
          else
          {
              $this->nm_formatar_campos();
              $this->p_o_number = "" ;  
              $this->old_po = "" ;  
              $this->date = "" ;  
              $this->date_hora = "" ;  
              $this->mill = "" ;  
              $this->ship_to = "" ;  
              $this->style = "" ;  
              $this->new_style = "" ;  
              $this->desc1 = "" ;  
              $this->desc2 = "" ;  
              $this->top_p_o_ = "" ;  
              $this->top_lbs = "" ;  
              $this->top_ship = "" ;  
              $this->top_cost = "" ;  
              $this->bot_p_o_ = "" ;  
              $this->bot_lbs = "" ;  
              $this->bot_ship = "" ;  
              $this->bot_cost = "" ;  
              $this->terms = "" ;  
              $this->delivery = "" ;  
              $this->order_amt = "" ;  
              $this->lbs_ordere = "" ;  
              $this->lbs = "" ;  
              $this->lbs_open = "" ;  
              $this->lbs_dyed = "" ;  
              $this->adjustment = "" ;  
              $this->inventory = "" ;  
              $this->pinv = "" ;  
              $this->knit_price = "" ;  
              $this->cost_lb_k = "" ;  
              $this->totalkc = "" ;  
              $this->cost_lb_y = "" ;  
              $this->cost_lb = "" ;  
              $this->status = "" ;  
              $this->amount = "" ;  
              $this->roll_size = "" ;  
              $this->spec = "" ;  
              $this->mach = "" ;  
              $this->production = "" ;  
              $this->ac = "" ;  
              $this->lbs_rack = "" ;  
              $this->formatado = false;
          }
          if (($this->Embutida_form || $this->Embutida_multi) && isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key']))
          {
              foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['foreign_key'] as $sFKName => $sFKValue)
              {
                   if (isset($this->sc_conv_var[$sFKName]))
                   {
                       $sFKName = $this->sc_conv_var[$sFKName];
                   }
                  eval("\$this->" . $sFKName . " = \"" . $sFKValue . "\";");
              }
          }
      }  
//
//
//-- 
      if ($this->nmgp_opcao != "novo") 
      {
      }
      $this->nm_proc_onload();
  }
// 
//-- 
   function nm_db_retorna($str_where_param = '') 
   {  
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $str_where_filter = ('' != $str_where_param) ? ' and ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER < '$this->p_o_number'" . $str_where_filter); 
     }  
     if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
     { 
         $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
         exit ; 
     }  
     if (isset($rs->fields[0]) && $rs->fields[0] != "") 
     { 
         $this->p_o_number = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
         $rs->Close();  
         $this->nmgp_opcao = "igual";  
         return ;  
     } 
     else 
     { 
        $this->nmgp_opcao = "inicio";  
        $rs->Close();  
        return ; 
     } 
   } 
// 
//-- 
   function nm_db_avanca($str_where_param = '') 
   {  
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $str_where_filter = ('' != $str_where_param) ? ' and ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " where P_O_NUMBER > '$this->p_o_number'" . $str_where_filter); 
     }  
     if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
     { 
         $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
         exit ; 
     }  
     if (isset($rs->fields[0]) && $rs->fields[0] != "") 
     { 
         $this->p_o_number = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
         $rs->Close();  
         $this->nmgp_opcao = "igual";  
         return ;  
     } 
     else 
     { 
        $this->nmgp_opcao = "final";  
        $rs->Close();  
        return ; 
     } 
   } 
// 
//-- 
   function nm_db_inicio($str_where_param = '') 
   {   
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select count(*) from " . $this->Ini->nm_tabela; 
     $rs = $this->Db->Execute("select count(*) from " . $this->Ini->nm_tabela);
     if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
     { 
         $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
         exit ; 
     }  
     if ($rs->fields[0] == 0) 
     { 
         $this->nmgp_opcao = "novo"; 
         $this->nm_flag_saida_novo = "S"; 
         $rs->Close(); 
         if ($this->aba_iframe)
         {
             $this->nmgp_botoes['exit'] = 'off';
         }
         return;
     }
     $str_where_filter = ('' != $str_where_param) ? ' where ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select min(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
     { 
         $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
         exit ; 
     }  
     if (!isset($rs->fields[0]) || $rs->EOF) 
     { 
         $this->nm_flag_saida_novo = "S"; 
         $this->nmgp_opcao = "novo";  
         $rs->Close();  
         if ($this->aba_iframe)
         {
             $this->nmgp_botoes['exit'] = 'off';
         }
         return ; 
     } 
     $this->p_o_number = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
     $rs->Close();  
     $this->nmgp_opcao = "igual";  
     return ;  
   } 
// 
//-- 
   function nm_db_final($str_where_param = '') 
   { 
     $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
     $str_where_filter = ('' != $str_where_param) ? ' where ' . $str_where_param : '';
     if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_access))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     else  
     {
         $_SESSION['scriptcase']['sc_sql_ult_comando'] = "select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter; 
         $rs = $this->Db->Execute("select max(P_O_NUMBER) from " . $this->Ini->nm_tabela . " " . $str_where_filter); 
     }  
     if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
     { 
         $this->Erro->mensagem (__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
         exit ; 
     }  
     if (!isset($rs->fields[0]) || $rs->EOF) 
     { 
         $this->nm_flag_saida_novo = "S"; 
         $this->nmgp_opcao = "novo";  
         $rs->Close();  
         if ($this->aba_iframe)
         {
             $this->nmgp_botoes['exit'] = 'off';
         }
         return ; 
     } 
     $this->p_o_number = substr($this->Db->qstr($rs->fields[0]), 1, -1); 
     $rs->Close();  
     $this->nmgp_opcao = "igual";  
     return ;  
   } 
   function NM_gera_nav_page() 
   {
       $this->SC_nav_page = "";
       $Reg_Page   = 1;
       $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]['greige_greigepo_greige_form']['total'] + 1;
       $rec_fim    = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['reg_start'] + 1;
       $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]['greige_greigepo_greige_form']['botoes'] = $this->nmgp_botoes;
     if ($this->nmgp_opcao != "recarga" && $this->nmgp_opcao != "muda_form")
     {
         $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['run_iframe'] == "F" || $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "R") && $this->nm_flag_iframe && empty($this->nm_todas_criticas))
     {
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe_ajax']))
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['retorno_edit'] = array("edit", "");
          }
          else
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['retorno_edit'] .= "&nmgp_opcao=edit";
          }
          if ($this->sc_evento == "insert" && $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe'] == "F")
          {
              if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['run_iframe_ajax']))
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['retorno_edit'] = array("edit", "fim");
              }
              else
              {
                  $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['run_iframe_ajax']))
              {
                  $this->NM_ajax_info['ajaxJavascript'][] = array("parent.ajax_navigate", $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['retorno_edit'];
                  $this->NM_ajax_info['redir']['target'] = $sJsParent;
              }
              greige_greigepo_greige_form_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]['greige_greigepo_greige_form']['run_iframe_ajax']))
    {
        $opc = ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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]['greige_greigepo_greige_form']['retorno_edit'] . "';";
    }
?>
         </script>
         </body></html>
<?php
         exit;
     }
    include_once("greige_greigepo_greige_form_form0.php");
 }
   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]['greige_greigepo_greige_form']['where_filter']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total']);
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['fast_search']);
          if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_detal'])) 
          {
              $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter'] = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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, "P_O_NUMBER", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "OLD_PO", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "MILL", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "SHIP_TO", $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, "NEW_STYLE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "DESC1", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "DESC2", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TOP_P_O_", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TOP_LBS", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TOP_SHIP", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TOP_COST", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "BOT_P_O_", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "BOT_LBS", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "BOT_SHIP", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "BOT_COST", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TERMS", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "DELIVERY", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "ORDER_AMT", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "LBS_ORDERE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "LBS", $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, "LBS_DYED", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "ADJUSTMENT", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "INVENTORY", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "PINV", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "KNIT_PRICE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "COST_LB_K", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "TOTALKC", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "COST_LB_Y", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "COST_LB", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "STATUS", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "AMOUNT", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "ROLL_SIZE", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "SPEC", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "MACH", $arg_search, $data_search);
      }
      if ($field == "SC_all_Cmp") 
      {
          $this->SC_monta_condicao($comando, "PRODUCTION", $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, "LBS_RACK", $arg_search, $data_search);
      }
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_detal']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_detal']) && !empty($comando)) 
      {
          $comando = $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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_greige_greigepo_greige_form = isset($rt->fields[0]) ? $rt->fields[0] - 1 : 0; 
     $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['total'] = $qt_geral_reg_greige_greigepo_greige_form;
      $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['where_filter'] = $comando;
      $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['fast_search'][0] = $field;
      $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['fast_search'][1] = $arg_search;
      $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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[] = "top_lbs";$nm_numeric[] = "top_ship";$nm_numeric[] = "top_cost";$nm_numeric[] = "bot_lbs";$nm_numeric[] = "bot_ship";$nm_numeric[] = "bot_cost";$nm_numeric[] = "order_amt";$nm_numeric[] = "lbs_ordere";$nm_numeric[] = "lbs";$nm_numeric[] = "lbs_open";$nm_numeric[] = "lbs_dyed";$nm_numeric[] = "adjustment";$nm_numeric[] = "inventory";$nm_numeric[] = "pinv";$nm_numeric[] = "knit_price";$nm_numeric[] = "cost_lb_k";$nm_numeric[] = "totalkc";$nm_numeric[] = "cost_lb_y";$nm_numeric[] = "cost_lb";$nm_numeric[] = "amount";$nm_numeric[] = "lbs_rack";
      if (in_array($campo_join, $nm_numeric))
      {
         if ($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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[] = "date";
          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]['greige_greigepo_greige_form']['sc_outra_jan']) && $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['sc_outra_jan'])
   {
       $nmgp_saida_form = "greige_greigepo_greige_form_fim.php";
   }
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['redir']) && $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['redir'] == 'redir')
   {
       unset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']);
   }
   unset($_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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;
       }
       greige_greigepo_greige_form_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]['greige_greigepo_greige_form']['sc_modal']) && $_SESSION['sc_session'][$this->Ini->sc_page]['greige_greigepo_greige_form']['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;
}
}
?>
