<?php
class billing_invoice_pdf_grid
{
   var $Ini;
   var $Erro;
   var $Pdf;
   var $Db;
   var $rs_grid;
   var $nm_grid_sem_reg;
   var $SC_seq_register;
   var $nm_location;
   var $nm_data;
   var $nm_cod_barra;
   var $sc_proc_grid; 
   var $nmgp_botoes = array();
   var $Campos_Mens_erro;
   var $NM_raiz_img; 
   var $Font_ttf; 
   var $items = array();
   var $items_item = array();
   var $items_lin = array();
   var $items_sq = array();
   var $items_style = array();
   var $items_width = array();
   var $items_color = array();
   var $items_cust_order = array();
   var $items_our_order = array();
   var $items_price = array();
   var $items_unit = array();
   var $items_amount = array();
   var $items_descrip = array();
   var $items_dye_order = array();
   var $items_dye_lot = array();
   var $items_cases = array();
   var $items_invoice = array();
   var $items_date = array();
   var $items_bcode = array();
   var $items_cost = array();
   var $items_cost_yd = array();
   var $items_gp = array();
   var $items_gp_yd = array();
   var $items_pc = array();
   var $items_adate = array();
   var $items_edate = array();
   var $items_smit = array();
   var $items_memo = array();
   var $items_id2 = array();
   var $address1 = array();
   var $name = array();
   var $address2 = array();
   var $city = array();
   var $state = array();
   var $zip = array();
   var $country = array();
   var $sname = array();
   var $saddress1 = array();
   var $saddress2 = array();
   var $scity = array();
   var $sstate = array();
   var $szip = array();
   var $scountry = array();
   var $invoice = array();
   var $date = array();
   var $bcode = array();
   var $scode = array();
   var $salesman = array();
   var $terms = array();
   var $terms2 = array();
   var $bill_ladin = array();
   var $cases = array();
   var $add_ons = array();
   var $add_charge = array();
   var $message = array();
   var $shippedvia = array();
   var $amount = array();
   var $void = array();
   var $cost = array();
   var $gp = array();
   var $factored = array();
   var $adate = array();
   var $edate = array();
   var $appno = array();
   var $postedar = array();
   var $dday = array();
//--- 
 function monta_grid($linhas = 0)
 {

   clearstatcache();
   $this->inicializa();
   $this->grid();
 }
//--- 
 function inicializa()
 {
   global $nm_saida, 
   $rec, $nmgp_chave, $nmgp_opcao, $nmgp_ordem, $nmgp_chave_det, 
   $nmgp_quant_linhas, $nmgp_quant_colunas, $nmgp_url_saida, $nmgp_parms;
//
   $this->nm_data = new nm_data("en_us");
   $this->default_font = 'Courier';
   $this->default_font_sr  = 'Arial';
   $this->default_style    = '';
   $this->default_style_sr = 'B';
   $Tp_papel = "Letter";
   $old_dir = getcwd();
   $File_font_ttf = "";
   $this->Font_ttf = false;
   if (in_array(trim($this->Ini->str_lang), $this->Ini->nm_font_ttf) && is_dir($this->Ini->path_third . "/tfpdf/"))
   {
       if (in_array(trim($this->Ini->str_lang), $this->Ini->nm_ttf_arab))
       {
           $this->default_font    = "Simplified Arabic";
           $this->default_font_sr = "Simplified Arabic";
           $File_font_ttf         = "simpo.ttf";
       }
       if (in_array(trim($this->Ini->str_lang), $this->Ini->nm_ttf_jap))
       {
           $this->default_font    = "IPAGothic";
           $this->default_font_sr = "IPAGothic";
           $File_font_ttf         = "ipag.ttf";
       }
       if (in_array(trim($this->Ini->str_lang), $this->Ini->nm_ttf_rus))
       {
           $this->default_font    = "Gentium";
           $this->default_font_sr = "Gentium";
           $File_font_ttf         = "GenR102.TTF";
       }
       if (in_array(trim($this->Ini->str_lang), $this->Ini->nm_ttf_chi))
       {
           $this->default_font    = "HanWangMingMedium";
           $this->default_font_sr = "HanWangMingMedium";
           $File_font_ttf         = "wt002.ttf";
       }
       if (in_array(trim($this->Ini->str_lang), $this->Ini->nm_ttf_thai))
       {
           $this->default_font    = "Courpro";
           $this->default_font_sr = "Courpro";
           $File_font_ttf         = "courpro.ttf";
       }
       $this->default_style    = '';
       $this->default_style_sr = '';
       chdir($this->Ini->path_third . "/tfpdf/");
   }
   else
   {
       chdir($this->Ini->path_third . "/fpdf/");
   }
   include_once("visibility.php");
   chdir($old_dir);
   $this->Pdf = new PDF_Visibility('P', 'mm', $Tp_papel);
   if (!empty($File_font_ttf))
   {
       $this->Font_ttf = true;
       $this->Pdf->AddFont($this->default_font, '', $File_font_ttf, true);
   }
   $_SESSION['billing_invoice_pdf']['Font_ttf'] = $this->Font_ttf;
   $this->Pdf->SetDisplayMode('real');
   $this->Pdf->AliasNbPages();
   $this->aba_iframe = false;
   if (isset($_SESSION['scriptcase']['sc_aba_iframe']))
   {
       foreach ($_SESSION['scriptcase']['sc_aba_iframe'] as $aba => $apls_aba)
       {
           if (in_array("billing_invoice_pdf", $apls_aba))
           {
               $this->aba_iframe = true;
               break;
           }
       }
   }
   if ($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['iframe_menu'] && (!isset($_SESSION['scriptcase']['menu_mobile']) || empty($_SESSION['scriptcase']['menu_mobile'])))
   {
       $this->aba_iframe = true;
   }
   $this->nmgp_botoes['exit'] = "on";
   $this->sc_proc_grid = false; 
   $this->NM_raiz_img = $this->Ini->root;
   $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
   $this->nm_where_dinamico = "";
   $this->nm_grid_colunas = 0;
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']))
   { 
       $this->invoice[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']['invoice']; 
       $tmp_pos = strpos($this->invoice[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->invoice[0] = substr($this->invoice[0], 0, $tmp_pos);
       }
       $this->date[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']['date']; 
       $tmp_pos = strpos($this->date[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->date[0] = substr($this->date[0], 0, $tmp_pos);
       }
       $this->bcode[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']['bcode']; 
       $tmp_pos = strpos($this->bcode[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->bcode[0] = substr($this->bcode[0], 0, $tmp_pos);
       }
       $this->scode[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']['scode']; 
       $tmp_pos = strpos($this->scode[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->scode[0] = substr($this->scode[0], 0, $tmp_pos);
       }
       $this->dday[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['campos_busca']['dday']; 
       $tmp_pos = strpos($this->dday[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->dday[0] = substr($this->dday[0], 0, $tmp_pos);
       }
   } 
   $this->nm_field_dinamico = array();
   $this->nm_order_dinamico = array();
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq_filtro'];
   $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['scriptcase']['contr_link_emb'] = $this->nm_location;
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['qt_col_grid'] = 1 ;  
   if (isset($_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['cols']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['cols']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['qt_col_grid'] = $_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['cols'];  
       unset($_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['cols']);
   }
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_select']))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_select'] = array(); 
   } 
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_quebra']))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_grid'] = "" ; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_ant']  = ""; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_desc'] = "" ; 
   }   
   if (!empty($nmgp_parms) && $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['opcao'] != "pdf")   
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['opcao'] = "igual";
       $rec = "ini";
   }
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig']) || $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['prim_cons'] || !empty($nmgp_parms))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['prim_cons'] = false;  
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig'] = " where invoice='" . $_SESSION['var_invoice'] . "'";  
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq']        = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig'];  
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq_ant']    = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig'];  
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['cond_pesq']         = ""; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq_filtro'] = "";
   }   
   if  (!empty($this->nm_where_dinamico)) 
   {   
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq'] .= $this->nm_where_dinamico;
   }   
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq_filtro'];
//
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['tot_geral'][1])) 
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['total'] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['tot_geral'][1] ;  
   }
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq_ant'] = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq'];  
//----- 
   if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
   { 
       $nmgp_select = "SELECT INVOICE, str_replace (convert(char(10),`DATE`,102), '.', '-') + ' ' + convert(char(8),`DATE`,20) as sc_def_col_1, BCODE, SCODE, SALESMAN, TERMS, TERMS2, BILL_LADIN, CASES, ADD_ONS, ADD_CHARGE, MESSAGE, SHIPPEDVIA, AMOUNT, VOID, COST, GP, FACTORED, str_replace (convert(char(10),ADATE,102), '.', '-') + ' ' + convert(char(8),ADATE,20), str_replace (convert(char(10),EDATE,102), '.', '-') + ' ' + convert(char(8),EDATE,20), APPNO, POSTEDAR, DDAY from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
   { 
       $nmgp_select = "SELECT INVOICE, `DATE` as sc_def_col_1, BCODE, SCODE, SALESMAN, TERMS, TERMS2, BILL_LADIN, CASES, ADD_ONS, ADD_CHARGE, MESSAGE, SHIPPEDVIA, AMOUNT, VOID, COST, GP, FACTORED, ADATE, EDATE, APPNO, POSTEDAR, DDAY from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
   { 
       $nmgp_select = "SELECT INVOICE, convert(char(23),`DATE`,121) as sc_def_col_1, BCODE, SCODE, SALESMAN, TERMS, TERMS2, BILL_LADIN, CASES, ADD_ONS, ADD_CHARGE, MESSAGE, SHIPPEDVIA, AMOUNT, VOID, COST, GP, FACTORED, convert(char(23),ADATE,121), convert(char(23),EDATE,121), APPNO, POSTEDAR, DDAY from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
   { 
       $nmgp_select = "SELECT INVOICE, `DATE` as sc_def_col_1, BCODE, SCODE, SALESMAN, TERMS, TERMS2, BILL_LADIN, CASES, ADD_ONS, ADD_CHARGE, MESSAGE, SHIPPEDVIA, AMOUNT, VOID, COST, GP, FACTORED, ADATE, EDATE, APPNO, POSTEDAR, DDAY from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
   { 
       $nmgp_select = "SELECT INVOICE, EXTEND(`DATE`, YEAR TO DAY) as sc_def_col_1, BCODE, SCODE, SALESMAN, TERMS, TERMS2, BILL_LADIN, CASES, ADD_ONS, ADD_CHARGE, MESSAGE, SHIPPEDVIA, AMOUNT, VOID, COST, GP, FACTORED, EXTEND(ADATE, YEAR TO DAY), EXTEND(EDATE, YEAR TO DAY), APPNO, POSTEDAR, DDAY from " . $this->Ini->nm_tabela; 
   } 
   else 
   { 
       $nmgp_select = "SELECT INVOICE, `DATE` as sc_def_col_1, BCODE, SCODE, SALESMAN, TERMS, TERMS2, BILL_LADIN, CASES, ADD_ONS, ADD_CHARGE, MESSAGE, SHIPPEDVIA, AMOUNT, VOID, COST, GP, FACTORED, ADATE, EDATE, APPNO, POSTEDAR, DDAY from " . $this->Ini->nm_tabela; 
   } 
   $nmgp_select .= " " . $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq']; 
   $nmgp_order_by = ""; 
   $campos_order_select = "";
   foreach($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_select'] as $campo => $ordem) 
   {
        if ($campo != $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_grid']) 
        {
           if (!empty($campos_order_select)) 
           {
               $campos_order_select .= ", ";
           }
           $campos_order_select .= $campo . " " . $ordem;
        }
   }
   if (!empty($_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_grid'])) 
   { 
       $nmgp_order_by = " order by " . $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_grid'] . $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['ordem_desc']; 
   } 
   if (!empty($campos_order_select)) 
   { 
       if (!empty($nmgp_order_by)) 
       { 
          $nmgp_order_by .= ", " . $campos_order_select; 
       } 
       else 
       { 
          $nmgp_order_by = " order by $campos_order_select"; 
       } 
   } 
   $nmgp_select .= $nmgp_order_by; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['order_grid'] = $nmgp_order_by;
   $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select; 
   $this->rs_grid = $this->Db->Execute($nmgp_select) ; 
   if ($this->rs_grid === false && !$this->rs_grid->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1) 
   { 
       $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg()); 
       exit ; 
   }  
   if ($this->rs_grid->EOF || ($this->rs_grid === false && $GLOBALS["NM_ERRO_IBASE"] == 1)) 
   { 
       $this->nm_grid_sem_reg = $this->Ini->Nm_lang['lang_errm_empt']; 
   }  
// 
 }  
// 
 function Pdf_init()
 {
   $this->Pdf->SetLeftMargin(0);
   $this->Pdf->SetFont($this->default_font, $this->default_style, 8);
   $this->Pdf->SetTextColor(0, 0, 0);
 }
// 
 function Pdf_scale()
 {
//   $this->Pdf->SetVisibility('screen');
   $NM_cont  = 0;
   $NM_num_h = 0;
   $NM_num_v = 0;
   $this->Pdf->SetFont('Arial', '', 6);
   $this->Pdf->SetLineWidth(0.4);
   for ($i = 3; $i < 215.9; $i += 1)
   {
      $NM_cont++;
      if ($NM_cont % 10 == 0)
      {
          $NM_num_h++;
          $NM_num_h = ($NM_num_h == 10) ? 0 : $NM_num_h;
          $this->Pdf->Text($i, 2, $NM_num_h);
          $this->Pdf->Line($i, 3, $i, 5);
          $this->Pdf->Line($i, 272.4, $i, 274.4);
          $this->Pdf->Text($i, 276.4, $NM_num_h);
      }
      elseif ($NM_cont % 5 == 0)
      {
          $this->Pdf->Line($i, 3.5, $i, 5);
          $this->Pdf->Line($i, 272.4, $i, 273.9);
      }
      else
      {
          $this->Pdf->Line($i, 4, $i, 5);
          $this->Pdf->Line($i, 272.4, $i, 273.4);
      }
   }
   $NM_cont = 0;
   for ($i = 1; $i < 279.4; $i += 1)
   {
      $NM_cont++;
      if ($NM_cont % 10 == 0)
      {
          $NM_num_v++;
          $NM_num_v = ($NM_num_v == 10) ? 0 : $NM_num_v;
          $this->Pdf->Text(1, $i, $NM_num_v);
          $this->Pdf->Line(3, $i, 5, $i);
          $this->Pdf->Line(207.9, $i, 209.9, $i);
          $this->Pdf->Text(210.9, $i, $NM_num_v);
      }
      elseif ($NM_cont % 5 == 0)
      {
          $this->Pdf->Line(3.5, $i, 5, $i);
          $this->Pdf->Line(207.9, $i, 209.4, $i);
      }
      else
      {
          $this->Pdf->Line(4, $i, 5, $i);
          $this->Pdf->Line(207.9, $i, 208.9, $i);
      }
   }
//   $this->Pdf->SetVisibility('all');
 }
// 
 function Pdf_image()
 {
   $this->Pdf->Image($this->NM_raiz_img . $this->Ini->path_img_global . "/sys__NM__invoice.jpg", 1, 1, 210, 265);
 }
// 
//----- 
 function grid($linhas = 0)
 {
    global 
           $nm_saida, $nm_url_saida;
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['invoice'] = "INVOICE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['date'] = "DATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['bcode'] = "BCODE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['scode'] = "SCODE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['salesman'] = "SALESMAN";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['terms'] = "TERMS";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['terms2'] = "TERMS2";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['bill_ladin'] = "BILL LADIN";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['cases'] = "CASES";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['add_ons'] = "ADD ONS";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['add_charge'] = "ADD CHARGE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['message'] = "MESSAGE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['shippedvia'] = "SHIPPEDVIA";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['amount'] = "AMOUNT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['void'] = "VOID";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['cost'] = "COST";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['gp'] = "GP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['factored'] = "FACTORED";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['adate'] = "ADATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['edate'] = "EDATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['appno'] = "APPNO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['postedar'] = "POSTEDAR";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['dday'] = "DDAY";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items'] = "Items";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_item'] = "ITEM";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_lin'] = "LIN";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_sq'] = "SQ";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_style'] = "STYLE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_width'] = "WIDTH";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_color'] = "COLOR";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_cust_order'] = "CUST ORDER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_our_order'] = "OUR ORDER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_price'] = "PRICE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_unit'] = "UNIT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_amount'] = "AMOUNT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_descrip'] = "DESCRIP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_dye_order'] = "DYE ORDER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_dye_lot'] = "DYE LOT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_cases'] = "CASES";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_invoice'] = "INVOICE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_date'] = "DATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_bcode'] = "BCODE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_cost'] = "COST";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_cost_yd'] = "COST YD";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_gp'] = "GP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_gp_yd'] = "GP YD";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_pc'] = "PC";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_adate'] = "ADATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_edate'] = "EDATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_smit'] = "SMIT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_memo'] = "MEMO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['items_id2'] = "ID2";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['address1'] = "Address1";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['name'] = "Name";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['address2'] = "Address2";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['city'] = "City";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['state'] = "State";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['zip'] = "Zip";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['country'] = "Country";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['sname'] = "Sname";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['saddress1'] = "SAddress1";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['saddress2'] = "SAddress2";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['scity'] = "SCity";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['sstate'] = "SState";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['szip'] = "SZip";
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['labels']['scountry'] = "SCountry";
   $HTTP_REFERER = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ""; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['seq_dir'] = 0; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['sub_dir'] = array(); 
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['where_pesq_filtro'];
   if (isset($_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['lig_edit']) && $_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['lig_edit'] != '')
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['mostra_edit'] = $_SESSION['scriptcase']['sc_apl_conf']['billing_invoice_pdf']['lig_edit'];
   }
   if (!empty($this->nm_grid_sem_reg))
   {
       $this->Pdf_init();
       $this->Pdf->AddPage();
       $this->Pdf->SetFont($this->default_font_sr, 'B', 12);
       $this->Pdf->SetTextColor(0, 0, 0);
       $this->Pdf->Text(10, 10, html_entity_decode($this->nm_grid_sem_reg));
       $this->Pdf->Output($this->Ini->root . $this->Ini->nm_path_pdf);
       return;
   }
// 
   $Init_Pdf = true;
   $this->SC_seq_register = 0; 
   while (!$this->rs_grid->EOF) 
   {  
      $this->nm_grid_colunas = 0; 
      $nm_quant_linhas = 0;
      $this->Pdf->AddPage();
      $this->Pdf_init();
      $this->Pdf_image();
      $this->Pdf_scale();
      $this->Pdf_init();
      while (!$this->rs_grid->EOF && $nm_quant_linhas < $_SESSION['sc_session'][$this->Ini->sc_page]['billing_invoice_pdf']['qt_col_grid']) 
      {  
          $this->sc_proc_grid = true;
          $this->SC_seq_register++; 
          $this->invoice[$this->nm_grid_colunas] = $this->rs_grid->fields[0] ;  
          $this->date[$this->nm_grid_colunas] = $this->rs_grid->fields[1] ;  
          $this->bcode[$this->nm_grid_colunas] = $this->rs_grid->fields[2] ;  
          $this->scode[$this->nm_grid_colunas] = $this->rs_grid->fields[3] ;  
          $this->salesman[$this->nm_grid_colunas] = $this->rs_grid->fields[4] ;  
          $this->terms[$this->nm_grid_colunas] = $this->rs_grid->fields[5] ;  
          $this->terms2[$this->nm_grid_colunas] = $this->rs_grid->fields[6] ;  
          $this->bill_ladin[$this->nm_grid_colunas] = $this->rs_grid->fields[7] ;  
          $this->cases[$this->nm_grid_colunas] = $this->rs_grid->fields[8] ;  
          $this->add_ons[$this->nm_grid_colunas] = $this->rs_grid->fields[9] ;  
          $this->add_charge[$this->nm_grid_colunas] = $this->rs_grid->fields[10] ;  
          $this->add_charge[$this->nm_grid_colunas] =  str_replace(",", ".", $this->add_charge[$this->nm_grid_colunas]);
          $this->add_charge[$this->nm_grid_colunas] = (strpos(strtolower($this->add_charge[$this->nm_grid_colunas]), "e")) ? (float)$this->add_charge[$this->nm_grid_colunas] : $this->add_charge[$this->nm_grid_colunas]; 
          $this->add_charge[$this->nm_grid_colunas] = (string)$this->add_charge[$this->nm_grid_colunas];
          $this->message[$this->nm_grid_colunas] = $this->rs_grid->fields[11] ;  
          $this->shippedvia[$this->nm_grid_colunas] = $this->rs_grid->fields[12] ;  
          $this->amount[$this->nm_grid_colunas] = $this->rs_grid->fields[13] ;  
          $this->amount[$this->nm_grid_colunas] =  str_replace(",", ".", $this->amount[$this->nm_grid_colunas]);
          $this->amount[$this->nm_grid_colunas] = (strpos(strtolower($this->amount[$this->nm_grid_colunas]), "e")) ? (float)$this->amount[$this->nm_grid_colunas] : $this->amount[$this->nm_grid_colunas]; 
          $this->amount[$this->nm_grid_colunas] = (string)$this->amount[$this->nm_grid_colunas];
          $this->void[$this->nm_grid_colunas] = $this->rs_grid->fields[14] ;  
          $this->cost[$this->nm_grid_colunas] = $this->rs_grid->fields[15] ;  
          $this->cost[$this->nm_grid_colunas] =  str_replace(",", ".", $this->cost[$this->nm_grid_colunas]);
          $this->cost[$this->nm_grid_colunas] = (strpos(strtolower($this->cost[$this->nm_grid_colunas]), "e")) ? (float)$this->cost[$this->nm_grid_colunas] : $this->cost[$this->nm_grid_colunas]; 
          $this->cost[$this->nm_grid_colunas] = (string)$this->cost[$this->nm_grid_colunas];
          $this->gp[$this->nm_grid_colunas] = $this->rs_grid->fields[16] ;  
          $this->gp[$this->nm_grid_colunas] =  str_replace(",", ".", $this->gp[$this->nm_grid_colunas]);
          $this->gp[$this->nm_grid_colunas] = (strpos(strtolower($this->gp[$this->nm_grid_colunas]), "e")) ? (float)$this->gp[$this->nm_grid_colunas] : $this->gp[$this->nm_grid_colunas]; 
          $this->gp[$this->nm_grid_colunas] = (string)$this->gp[$this->nm_grid_colunas];
          $this->factored[$this->nm_grid_colunas] = $this->rs_grid->fields[17] ;  
          $this->adate[$this->nm_grid_colunas] = $this->rs_grid->fields[18] ;  
          $this->edate[$this->nm_grid_colunas] = $this->rs_grid->fields[19] ;  
          $this->appno[$this->nm_grid_colunas] = $this->rs_grid->fields[20] ;  
          $this->postedar[$this->nm_grid_colunas] = $this->rs_grid->fields[21] ;  
          $this->dday[$this->nm_grid_colunas] = $this->rs_grid->fields[22] ;  
          $this->dday[$this->nm_grid_colunas] = (string)$this->dday[$this->nm_grid_colunas];
          $this->items_item[$this->nm_grid_colunas] = array();
          $this->items_lin[$this->nm_grid_colunas] = array();
          $this->items_sq[$this->nm_grid_colunas] = array();
          $this->items_style[$this->nm_grid_colunas] = array();
          $this->items_width[$this->nm_grid_colunas] = array();
          $this->items_color[$this->nm_grid_colunas] = array();
          $this->items_cust_order[$this->nm_grid_colunas] = array();
          $this->items_our_order[$this->nm_grid_colunas] = array();
          $this->items_price[$this->nm_grid_colunas] = array();
          $this->items_unit[$this->nm_grid_colunas] = array();
          $this->items_amount[$this->nm_grid_colunas] = array();
          $this->items_descrip[$this->nm_grid_colunas] = array();
          $this->items_dye_order[$this->nm_grid_colunas] = array();
          $this->items_dye_lot[$this->nm_grid_colunas] = array();
          $this->items_cases[$this->nm_grid_colunas] = array();
          $this->items_invoice[$this->nm_grid_colunas] = array();
          $this->items_date[$this->nm_grid_colunas] = array();
          $this->items_bcode[$this->nm_grid_colunas] = array();
          $this->items_cost[$this->nm_grid_colunas] = array();
          $this->items_cost_yd[$this->nm_grid_colunas] = array();
          $this->items_gp[$this->nm_grid_colunas] = array();
          $this->items_gp_yd[$this->nm_grid_colunas] = array();
          $this->items_pc[$this->nm_grid_colunas] = array();
          $this->items_adate[$this->nm_grid_colunas] = array();
          $this->items_edate[$this->nm_grid_colunas] = array();
          $this->items_smit[$this->nm_grid_colunas] = array();
          $this->items_memo[$this->nm_grid_colunas] = array();
          $this->items_id2[$this->nm_grid_colunas] = array();
          $this->Lookup->lookup_items($this->items[$this->nm_grid_colunas] , $_SESSION['var_invoice'], $array_items); 
          $NM_ind = 0;
          $this->items = array();
          foreach ($array_items as $cada_subselect) 
          {
              $this->items[$this->nm_grid_colunas][$NM_ind] = "";
              $this->items_invoice[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[0];
              $this->items_item[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[1];
              $this->items_date[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[2];
              $this->items_bcode[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[3];
              $this->items_lin[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[4];
              $this->items_sq[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[5];
              $this->items_style[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[6];
              $this->items_width[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[7];
              $this->items_color[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[8];
              $this->items_cust_order[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[9];
              $this->items_our_order[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[10];
              $this->items_price[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[11];
              $this->items_unit[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[12];
              $this->items_amount[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[13];
              $this->items_descrip[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[14];
              $this->items_dye_order[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[15];
              $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[16];
              $this->items_cases[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[17];
              $this->items_cost[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[18];
              $this->items_cost_yd[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[19];
              $this->items_gp[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[20];
              $this->items_gp_yd[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[21];
              $this->items_pc[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[22];
              $this->items_adate[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[23];
              $this->items_edate[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[24];
              $this->items_smit[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[25];
              $this->items_memo[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[26];
              $this->items_id2[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[27];
              $NM_ind++;
          }
          $this->address1[$this->nm_grid_colunas] = "";
          $this->name[$this->nm_grid_colunas] = "";
          $this->address2[$this->nm_grid_colunas] = "";
          $this->city[$this->nm_grid_colunas] = "";
          $this->state[$this->nm_grid_colunas] = "";
          $this->zip[$this->nm_grid_colunas] = "";
          $this->country[$this->nm_grid_colunas] = "";
          $this->sname[$this->nm_grid_colunas] = "";
          $this->saddress1[$this->nm_grid_colunas] = "";
          $this->saddress2[$this->nm_grid_colunas] = "";
          $this->scity[$this->nm_grid_colunas] = "";
          $this->sstate[$this->nm_grid_colunas] = "";
          $this->szip[$this->nm_grid_colunas] = "";
          $this->scountry[$this->nm_grid_colunas] = "";
          $this->invoice[$this->nm_grid_colunas] = $this->invoice[$this->nm_grid_colunas];
          if ($this->invoice[$this->nm_grid_colunas] === "") 
          { 
              $this->invoice[$this->nm_grid_colunas] = "" ;  
          } 
          $this->invoice[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->invoice[$this->nm_grid_colunas]);
          $this->date[$this->nm_grid_colunas] = $this->date[$this->nm_grid_colunas];
          if ($this->date[$this->nm_grid_colunas] === "") 
          { 
              $this->date[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
               $date_x =  $this->date[$this->nm_grid_colunas];
               nm_conv_limpa_dado($date_x, "YYYY-MM-DD");
               if (is_numeric($date_x) && $date_x > 0) 
               { 
                   $this->nm_data->SetaData($this->date[$this->nm_grid_colunas], "YYYY-MM-DD");
                   $this->date[$this->nm_grid_colunas] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
          $this->date[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->date[$this->nm_grid_colunas]);
          $this->bcode[$this->nm_grid_colunas] = $this->bcode[$this->nm_grid_colunas];
          if ($this->bcode[$this->nm_grid_colunas] === "") 
          { 
              $this->bcode[$this->nm_grid_colunas] = "" ;  
          } 
          $this->bcode[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->bcode[$this->nm_grid_colunas]);
          $this->scode[$this->nm_grid_colunas] = $this->scode[$this->nm_grid_colunas];
          if ($this->scode[$this->nm_grid_colunas] === "") 
          { 
              $this->scode[$this->nm_grid_colunas] = "" ;  
          } 
          $this->scode[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->scode[$this->nm_grid_colunas]);
          $this->salesman[$this->nm_grid_colunas] = $this->salesman[$this->nm_grid_colunas];
          if ($this->salesman[$this->nm_grid_colunas] === "") 
          { 
              $this->salesman[$this->nm_grid_colunas] = "" ;  
          } 
          $this->salesman[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->salesman[$this->nm_grid_colunas]);
          $this->terms[$this->nm_grid_colunas] = $this->terms[$this->nm_grid_colunas];
          if ($this->terms[$this->nm_grid_colunas] === "") 
          { 
              $this->terms[$this->nm_grid_colunas] = "" ;  
          } 
          $this->terms[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->terms[$this->nm_grid_colunas]);
          $this->terms2[$this->nm_grid_colunas] = $this->terms2[$this->nm_grid_colunas];
          if ($this->terms2[$this->nm_grid_colunas] === "") 
          { 
              $this->terms2[$this->nm_grid_colunas] = "" ;  
          } 
          $this->terms2[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->terms2[$this->nm_grid_colunas]);
          $this->bill_ladin[$this->nm_grid_colunas] = $this->bill_ladin[$this->nm_grid_colunas];
          if ($this->bill_ladin[$this->nm_grid_colunas] === "") 
          { 
              $this->bill_ladin[$this->nm_grid_colunas] = "" ;  
          } 
          $this->bill_ladin[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->bill_ladin[$this->nm_grid_colunas]);
          $this->cases[$this->nm_grid_colunas] = $this->cases[$this->nm_grid_colunas];
          if ($this->cases[$this->nm_grid_colunas] === "") 
          { 
              $this->cases[$this->nm_grid_colunas] = "" ;  
          } 
          $this->cases[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->cases[$this->nm_grid_colunas]);
          $this->add_ons[$this->nm_grid_colunas] = $this->add_ons[$this->nm_grid_colunas];
          if ($this->add_ons[$this->nm_grid_colunas] === "") 
          { 
              $this->add_ons[$this->nm_grid_colunas] = "" ;  
          } 
          $this->add_ons[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->add_ons[$this->nm_grid_colunas]);
          $this->add_charge[$this->nm_grid_colunas] = $this->add_charge[$this->nm_grid_colunas];
          if ($this->add_charge[$this->nm_grid_colunas] === "") 
          { 
              $this->add_charge[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->add_charge[$this->nm_grid_colunas], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
          $this->add_charge[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->add_charge[$this->nm_grid_colunas]);
          $this->message[$this->nm_grid_colunas] = $this->message[$this->nm_grid_colunas];
          if ($this->message[$this->nm_grid_colunas] === "") 
          { 
              $this->message[$this->nm_grid_colunas] = "" ;  
          } 
          $this->message[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->message[$this->nm_grid_colunas]);
          $this->shippedvia[$this->nm_grid_colunas] = $this->shippedvia[$this->nm_grid_colunas];
          if ($this->shippedvia[$this->nm_grid_colunas] === "") 
          { 
              $this->shippedvia[$this->nm_grid_colunas] = "" ;  
          } 
          $this->shippedvia[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->shippedvia[$this->nm_grid_colunas]);
          $this->amount[$this->nm_grid_colunas] = $this->amount[$this->nm_grid_colunas];
          if ($this->amount[$this->nm_grid_colunas] === "") 
          { 
              $this->amount[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->amount[$this->nm_grid_colunas], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
          $this->amount[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->amount[$this->nm_grid_colunas]);
          $this->void[$this->nm_grid_colunas] = $this->void[$this->nm_grid_colunas];
          if ($this->void[$this->nm_grid_colunas] === "") 
          { 
              $this->void[$this->nm_grid_colunas] = "" ;  
          } 
          $this->void[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->void[$this->nm_grid_colunas]);
          $this->cost[$this->nm_grid_colunas] = $this->cost[$this->nm_grid_colunas];
          if ($this->cost[$this->nm_grid_colunas] === "") 
          { 
              $this->cost[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->cost[$this->nm_grid_colunas], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
          $this->cost[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->cost[$this->nm_grid_colunas]);
          $this->gp[$this->nm_grid_colunas] = $this->gp[$this->nm_grid_colunas];
          if ($this->gp[$this->nm_grid_colunas] === "") 
          { 
              $this->gp[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->gp[$this->nm_grid_colunas], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
          $this->gp[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->gp[$this->nm_grid_colunas]);
          $this->factored[$this->nm_grid_colunas] = $this->factored[$this->nm_grid_colunas];
          if ($this->factored[$this->nm_grid_colunas] === "") 
          { 
              $this->factored[$this->nm_grid_colunas] = "" ;  
          } 
          $this->factored[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->factored[$this->nm_grid_colunas]);
          $this->adate[$this->nm_grid_colunas] = $this->adate[$this->nm_grid_colunas];
          if ($this->adate[$this->nm_grid_colunas] === "") 
          { 
              $this->adate[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
               $adate_x =  $this->adate[$this->nm_grid_colunas];
               nm_conv_limpa_dado($adate_x, "YYYY-MM-DD");
               if (is_numeric($adate_x) && $adate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->adate[$this->nm_grid_colunas], "YYYY-MM-DD");
                   $this->adate[$this->nm_grid_colunas] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
          $this->adate[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->adate[$this->nm_grid_colunas]);
          $this->edate[$this->nm_grid_colunas] = $this->edate[$this->nm_grid_colunas];
          if ($this->edate[$this->nm_grid_colunas] === "") 
          { 
              $this->edate[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
               $edate_x =  $this->edate[$this->nm_grid_colunas];
               nm_conv_limpa_dado($edate_x, "YYYY-MM-DD");
               if (is_numeric($edate_x) && $edate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->edate[$this->nm_grid_colunas], "YYYY-MM-DD");
                   $this->edate[$this->nm_grid_colunas] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
          $this->edate[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->edate[$this->nm_grid_colunas]);
          $this->appno[$this->nm_grid_colunas] = $this->appno[$this->nm_grid_colunas];
          if ($this->appno[$this->nm_grid_colunas] === "") 
          { 
              $this->appno[$this->nm_grid_colunas] = "" ;  
          } 
          $this->appno[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->appno[$this->nm_grid_colunas]);
          $this->postedar[$this->nm_grid_colunas] = $this->postedar[$this->nm_grid_colunas];
          if ($this->postedar[$this->nm_grid_colunas] === "") 
          { 
              $this->postedar[$this->nm_grid_colunas] = "" ;  
          } 
          $this->postedar[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->postedar[$this->nm_grid_colunas]);
          $this->dday[$this->nm_grid_colunas] = $this->dday[$this->nm_grid_colunas];
          if ($this->dday[$this->nm_grid_colunas] === "") 
          { 
              $this->dday[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->dday[$this->nm_grid_colunas], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "0", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'] , $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
          $this->dday[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->dday[$this->nm_grid_colunas]);
          $this->Lookup->lookup_address1($this->address1[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->address1[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->address1[$this->nm_grid_colunas]);
          $this->Lookup->lookup_name($this->name[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->name[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->name[$this->nm_grid_colunas]);
          $this->Lookup->lookup_address2($this->address2[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->address2[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->address2[$this->nm_grid_colunas]);
          $this->Lookup->lookup_city($this->city[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->city[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->city[$this->nm_grid_colunas]);
          $this->Lookup->lookup_state($this->state[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->state[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->state[$this->nm_grid_colunas]);
          $this->Lookup->lookup_zip($this->zip[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->zip[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->zip[$this->nm_grid_colunas]);
          $this->Lookup->lookup_country($this->country[$this->nm_grid_colunas] , $this->bcode[$this->nm_grid_colunas]) ; 
          $this->country[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->country[$this->nm_grid_colunas]);
          $this->Lookup->lookup_sname($this->sname[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->sname[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->sname[$this->nm_grid_colunas]);
          $this->Lookup->lookup_saddress1($this->saddress1[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->saddress1[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->saddress1[$this->nm_grid_colunas]);
          $this->Lookup->lookup_saddress2($this->saddress2[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->saddress2[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->saddress2[$this->nm_grid_colunas]);
          $this->Lookup->lookup_scity($this->scity[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->scity[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->scity[$this->nm_grid_colunas]);
          $this->Lookup->lookup_sstate($this->sstate[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->sstate[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->sstate[$this->nm_grid_colunas]);
          $this->Lookup->lookup_szip($this->szip[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->szip[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->szip[$this->nm_grid_colunas]);
          $this->Lookup->lookup_scountry($this->scountry[$this->nm_grid_colunas] , $this->scode[$this->nm_grid_colunas]) ; 
          $this->scountry[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->scountry[$this->nm_grid_colunas]);
          foreach ($this->items_item[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_item[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_item[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_item[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "0", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'] , $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_item[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_item[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_lin[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_lin[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_lin[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_lin[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_lin[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_lin[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_sq[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_sq[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_sq[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_sq[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_sq[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_sq[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_style[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_style[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_style[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_style[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_style[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_width[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_width[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_width[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_width[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_width[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_color[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_color[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_color[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_color[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_color[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_cust_order[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_cust_order[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_cust_order[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_cust_order[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_cust_order[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_our_order[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_our_order[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_our_order[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_our_order[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_our_order[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_price[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_price[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_price[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_price[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_price[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_price[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_unit[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_unit[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_unit[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_unit[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_unit[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_amount[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_amount[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_amount[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_amount[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
              $this->items_amount[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_amount[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_descrip[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_descrip[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_descrip[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_descrip[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_descrip[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_dye_order[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_dye_order[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_dye_order[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_dye_order[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_dye_order[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_dye_lot[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_dye_lot[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_cases[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_cases[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_cases[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_cases[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_cases[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_invoice[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_invoice[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_invoice[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_invoice[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_invoice[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_date[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_date[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_date[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
               $items_date_x =  $this->items_date[$this->nm_grid_colunas][$NM_ind];
               nm_conv_limpa_dado($items_date_x, "YYYY-MM-DD");
               if (is_numeric($items_date_x) && $items_date_x > 0) 
               { 
                   $this->nm_data->SetaData($this->items_date[$this->nm_grid_colunas][$NM_ind], "YYYY-MM-DD");
                   $this->items_date[$this->nm_grid_colunas][$NM_ind] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
              $this->items_date[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_date[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_bcode[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_bcode[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_bcode[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_bcode[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_bcode[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_cost[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_cost[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_cost[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_cost[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
              $this->items_cost[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_cost[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_cost_yd[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_cost_yd[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_cost_yd[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_cost_yd[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_cost_yd[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_cost_yd[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_gp[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_gp[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_gp[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_gp[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_val'], $_SESSION['scriptcase']['reg_conf']['dec_val'], "2", "S", "2", "", "V:" . $_SESSION['scriptcase']['reg_conf']['monet_f_pos'] . ":" . $_SESSION['scriptcase']['reg_conf']['monet_f_neg'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['unid_mont_group_digit']) ; 
          } 
              $this->items_gp[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_gp[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_gp_yd[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_gp_yd[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_gp_yd[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_gp_yd[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_gp_yd[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_gp_yd[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_pc[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_pc[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_pc[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_pc[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_pc[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_pc[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_adate[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_adate[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_adate[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
               $items_adate_x =  $this->items_adate[$this->nm_grid_colunas][$NM_ind];
               nm_conv_limpa_dado($items_adate_x, "YYYY-MM-DD");
               if (is_numeric($items_adate_x) && $items_adate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->items_adate[$this->nm_grid_colunas][$NM_ind], "YYYY-MM-DD");
                   $this->items_adate[$this->nm_grid_colunas][$NM_ind] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
              $this->items_adate[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_adate[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_edate[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_edate[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_edate[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
               $items_edate_x =  $this->items_edate[$this->nm_grid_colunas][$NM_ind];
               nm_conv_limpa_dado($items_edate_x, "YYYY-MM-DD");
               if (is_numeric($items_edate_x) && $items_edate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->items_edate[$this->nm_grid_colunas][$NM_ind], "YYYY-MM-DD");
                   $this->items_edate[$this->nm_grid_colunas][$NM_ind] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
              $this->items_edate[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_edate[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_smit[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_smit[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_smit[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_smit[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_smit[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_memo[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_memo[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_memo[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else   
          { 
              $this->items_memo[$this->nm_grid_colunas][$NM_ind] = nl2br($this->items_memo[$this->nm_grid_colunas][$NM_ind]) ; 
              $temp = explode("<br />", $this->items_memo[$this->nm_grid_colunas][$NM_ind]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->items_memo[$this->nm_grid_colunas][$NM_ind]); 
              } 
              $this->items_memo[$this->nm_grid_colunas][$NM_ind] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->items_memo[$this->nm_grid_colunas][$NM_ind])) 
                 { 
                     $this->items_memo[$this->nm_grid_colunas][$NM_ind] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->items_memo[$this->nm_grid_colunas][$NM_ind] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->items_memo[$this->nm_grid_colunas][$NM_ind] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
              $this->items_memo[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_memo[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_id2[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_id2[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_id2[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_id2[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "0", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'] , $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_id2[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_id2[$this->nm_grid_colunas][$NM_ind]);
          }
            $cell_INVOICE = array('posx' => 35, 'posy' => 33, 'data' => $this->invoice[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_APPNO = array('posx' => 197, 'posy' => 33, 'data' => $this->appno[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_DATE = array('posx' => 35, 'posy' => 42, 'data' => $this->date[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SALESMAN = array('posx' => 198, 'posy' => 42, 'data' => $this->salesman[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Name = array('posx' => 20, 'posy' => 55, 'data' => $this->name[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Sname = array('posx' => 112, 'posy' => 55, 'data' => $this->sname[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Address1 = array('posx' => 20, 'posy' => 58, 'data' => $this->address1[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SAddress1 = array('posx' => 112, 'posy' => 58, 'data' => $this->saddress1[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Address2 = array('posx' => 20, 'posy' => 61, 'data' => $this->address2[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SAddress2 = array('posx' => 112, 'posy' => 61, 'data' => $this->saddress2[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_City = array('posx' => 20, 'posy' => 64, 'data' => $this->city[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_State = array('posx' => 45, 'posy' => 64, 'data' => $this->state[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Zip = array('posx' => 50, 'posy' => 64, 'data' => $this->zip[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SCity = array('posx' => 112, 'posy' => 64, 'data' => $this->scity[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SState = array('posx' => 137, 'posy' => 64, 'data' => $this->sstate[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SZip = array('posx' => 142, 'posy' => 64, 'data' => $this->szip[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Country = array('posx' => 20, 'posy' => 67, 'data' => $this->country[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SCountry = array('posx' => 112, 'posy' => 67, 'data' => $this->scountry[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SHIPPEDVIA = array('posx' => 35, 'posy' => 77, 'data' => $this->shippedvia[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_BILL_LADIN = array('posx' => 136, 'posy' => 77, 'data' => $this->bill_ladin[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_CASES = array('posx' => 187, 'posy' => 77, 'data' => $this->cases[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_TERMS = array('posx' => 35, 'posy' => 85, 'data' => $this->terms[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_TERMS2 = array('posx' => 35, 'posy' => 88, 'data' => $this->terms2[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_LIN = array('posx' => 12, 'posy' => 107, 'data' => $this->items_lin[$this->nm_grid_colunas], 'width'      => 10, 'align'      => 'R', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_UNIT = array('posx' => 22, 'posy' => 107, 'data' => $this->items_unit[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_STYLE = array('posx' => 30, 'posy' => 107, 'data' => $this->items_style[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_WIDTH = array('posx' => 44, 'posy' => 107, 'data' => $this->items_width[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_COLOR = array('posx' => 56, 'posy' => 107, 'data' => $this->items_color[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_items_DESCRIP = array('posx' => 69, 'posy' => 107, 'data' => $this->items_descrip[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => 'Courier', 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_SMIT = array('posx' => 101, 'posy' => 107, 'data' => $this->items_smit[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_DYE_ORDER = array('posx' => 115, 'posy' => 107, 'data' => $this->items_dye_order[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_DYE_LOT = array('posx' => 128, 'posy' => 107, 'data' => $this->items_dye_lot[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_CUST_ORDER = array('posx' => 145, 'posy' => 107, 'data' => $this->items_cust_order[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_OUR_ORDER = array('posx' => 163, 'posy' => 107, 'data' => $this->items_our_order[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_PRICE = array('posx' => 183, 'posy' => 107, 'data' => $this->items_price[$this->nm_grid_colunas], 'width'      => 7, 'align'      => 'R', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_AMOUNT = array('posx' => 197, 'posy' => 107, 'data' => $this->items_amount[$this->nm_grid_colunas], 'width'      => 10, 'align'      => 'R', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_MESSAGE = array('posx' => 20, 'posy' => 198, 'data' => $this->message[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ADD_ONS = array('posx' => 130, 'posy' => 210, 'data' => $this->add_ons[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ADD_CHARGE = array('posx' => 197, 'posy' => 210, 'data' => $this->add_charge[$this->nm_grid_colunas], 'width'      => 10, 'align'      => 'R', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_AMOUNT = array('posx' => 197, 'posy' => 217, 'data' => $this->amount[$this->nm_grid_colunas], 'width'      => 10, 'align'      => 'R', 'font_type'  => $this->default_font, 'font_size'  => 8, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);


            $this->Pdf->SetFont($cell_INVOICE['font_type'], $cell_INVOICE['font_style'], $cell_INVOICE['font_size']);
            $this->Pdf->SetTextColor($cell_INVOICE['color_r'], $cell_INVOICE['color_g'], $cell_INVOICE['color_b']);
            if (!empty($cell_INVOICE['posx']) && !empty($cell_INVOICE['posy']))
            {
                $this->Pdf->SetXY($cell_INVOICE['posx'], $cell_INVOICE['posy']);
            }
            elseif (!empty($cell_INVOICE['posx']))
            {
                $this->Pdf->SetX($cell_INVOICE['posx']);
            }
            elseif (!empty($cell_INVOICE['posy']))
            {
                $this->Pdf->SetY($cell_INVOICE['posy']);
            }
            $this->Pdf->Cell($cell_INVOICE['width'], 0, $cell_INVOICE['data'], 0, 0, $cell_INVOICE['align']);

            $this->Pdf->SetFont($cell_APPNO['font_type'], $cell_APPNO['font_style'], $cell_APPNO['font_size']);
            $this->Pdf->SetTextColor($cell_APPNO['color_r'], $cell_APPNO['color_g'], $cell_APPNO['color_b']);
            if (!empty($cell_APPNO['posx']) && !empty($cell_APPNO['posy']))
            {
                $this->Pdf->SetXY($cell_APPNO['posx'], $cell_APPNO['posy']);
            }
            elseif (!empty($cell_APPNO['posx']))
            {
                $this->Pdf->SetX($cell_APPNO['posx']);
            }
            elseif (!empty($cell_APPNO['posy']))
            {
                $this->Pdf->SetY($cell_APPNO['posy']);
            }
            $this->Pdf->Cell($cell_APPNO['width'], 0, $cell_APPNO['data'], 0, 0, $cell_APPNO['align']);

            $this->Pdf->SetFont($cell_DATE['font_type'], $cell_DATE['font_style'], $cell_DATE['font_size']);
            $this->Pdf->SetTextColor($cell_DATE['color_r'], $cell_DATE['color_g'], $cell_DATE['color_b']);
            if (!empty($cell_DATE['posx']) && !empty($cell_DATE['posy']))
            {
                $this->Pdf->SetXY($cell_DATE['posx'], $cell_DATE['posy']);
            }
            elseif (!empty($cell_DATE['posx']))
            {
                $this->Pdf->SetX($cell_DATE['posx']);
            }
            elseif (!empty($cell_DATE['posy']))
            {
                $this->Pdf->SetY($cell_DATE['posy']);
            }
            $this->Pdf->Cell($cell_DATE['width'], 0, $cell_DATE['data'], 0, 0, $cell_DATE['align']);

            $this->Pdf->SetFont($cell_SALESMAN['font_type'], $cell_SALESMAN['font_style'], $cell_SALESMAN['font_size']);
            $this->Pdf->SetTextColor($cell_SALESMAN['color_r'], $cell_SALESMAN['color_g'], $cell_SALESMAN['color_b']);
            if (!empty($cell_SALESMAN['posx']) && !empty($cell_SALESMAN['posy']))
            {
                $this->Pdf->SetXY($cell_SALESMAN['posx'], $cell_SALESMAN['posy']);
            }
            elseif (!empty($cell_SALESMAN['posx']))
            {
                $this->Pdf->SetX($cell_SALESMAN['posx']);
            }
            elseif (!empty($cell_SALESMAN['posy']))
            {
                $this->Pdf->SetY($cell_SALESMAN['posy']);
            }
            $this->Pdf->Cell($cell_SALESMAN['width'], 0, $cell_SALESMAN['data'], 0, 0, $cell_SALESMAN['align']);

            $this->Pdf->SetFont($cell_Name['font_type'], $cell_Name['font_style'], $cell_Name['font_size']);
            $this->Pdf->SetTextColor($cell_Name['color_r'], $cell_Name['color_g'], $cell_Name['color_b']);
            if (!empty($cell_Name['posx']) && !empty($cell_Name['posy']))
            {
                $this->Pdf->SetXY($cell_Name['posx'], $cell_Name['posy']);
            }
            elseif (!empty($cell_Name['posx']))
            {
                $this->Pdf->SetX($cell_Name['posx']);
            }
            elseif (!empty($cell_Name['posy']))
            {
                $this->Pdf->SetY($cell_Name['posy']);
            }
            $this->Pdf->Cell($cell_Name['width'], 0, $cell_Name['data'], 0, 0, $cell_Name['align']);

            $this->Pdf->SetFont($cell_Sname['font_type'], $cell_Sname['font_style'], $cell_Sname['font_size']);
            $this->Pdf->SetTextColor($cell_Sname['color_r'], $cell_Sname['color_g'], $cell_Sname['color_b']);
            if (!empty($cell_Sname['posx']) && !empty($cell_Sname['posy']))
            {
                $this->Pdf->SetXY($cell_Sname['posx'], $cell_Sname['posy']);
            }
            elseif (!empty($cell_Sname['posx']))
            {
                $this->Pdf->SetX($cell_Sname['posx']);
            }
            elseif (!empty($cell_Sname['posy']))
            {
                $this->Pdf->SetY($cell_Sname['posy']);
            }
            $this->Pdf->Cell($cell_Sname['width'], 0, $cell_Sname['data'], 0, 0, $cell_Sname['align']);

            $this->Pdf->SetFont($cell_Address1['font_type'], $cell_Address1['font_style'], $cell_Address1['font_size']);
            $this->Pdf->SetTextColor($cell_Address1['color_r'], $cell_Address1['color_g'], $cell_Address1['color_b']);
            if (!empty($cell_Address1['posx']) && !empty($cell_Address1['posy']))
            {
                $this->Pdf->SetXY($cell_Address1['posx'], $cell_Address1['posy']);
            }
            elseif (!empty($cell_Address1['posx']))
            {
                $this->Pdf->SetX($cell_Address1['posx']);
            }
            elseif (!empty($cell_Address1['posy']))
            {
                $this->Pdf->SetY($cell_Address1['posy']);
            }
            $this->Pdf->Cell($cell_Address1['width'], 0, $cell_Address1['data'], 0, 0, $cell_Address1['align']);

            $this->Pdf->SetFont($cell_SAddress1['font_type'], $cell_SAddress1['font_style'], $cell_SAddress1['font_size']);
            $this->Pdf->SetTextColor($cell_SAddress1['color_r'], $cell_SAddress1['color_g'], $cell_SAddress1['color_b']);
            if (!empty($cell_SAddress1['posx']) && !empty($cell_SAddress1['posy']))
            {
                $this->Pdf->SetXY($cell_SAddress1['posx'], $cell_SAddress1['posy']);
            }
            elseif (!empty($cell_SAddress1['posx']))
            {
                $this->Pdf->SetX($cell_SAddress1['posx']);
            }
            elseif (!empty($cell_SAddress1['posy']))
            {
                $this->Pdf->SetY($cell_SAddress1['posy']);
            }
            $this->Pdf->Cell($cell_SAddress1['width'], 0, $cell_SAddress1['data'], 0, 0, $cell_SAddress1['align']);

            $this->Pdf->SetFont($cell_Address2['font_type'], $cell_Address2['font_style'], $cell_Address2['font_size']);
            $this->Pdf->SetTextColor($cell_Address2['color_r'], $cell_Address2['color_g'], $cell_Address2['color_b']);
            if (!empty($cell_Address2['posx']) && !empty($cell_Address2['posy']))
            {
                $this->Pdf->SetXY($cell_Address2['posx'], $cell_Address2['posy']);
            }
            elseif (!empty($cell_Address2['posx']))
            {
                $this->Pdf->SetX($cell_Address2['posx']);
            }
            elseif (!empty($cell_Address2['posy']))
            {
                $this->Pdf->SetY($cell_Address2['posy']);
            }
            $this->Pdf->Cell($cell_Address2['width'], 0, $cell_Address2['data'], 0, 0, $cell_Address2['align']);

            $this->Pdf->SetFont($cell_SAddress2['font_type'], $cell_SAddress2['font_style'], $cell_SAddress2['font_size']);
            $this->Pdf->SetTextColor($cell_SAddress2['color_r'], $cell_SAddress2['color_g'], $cell_SAddress2['color_b']);
            if (!empty($cell_SAddress2['posx']) && !empty($cell_SAddress2['posy']))
            {
                $this->Pdf->SetXY($cell_SAddress2['posx'], $cell_SAddress2['posy']);
            }
            elseif (!empty($cell_SAddress2['posx']))
            {
                $this->Pdf->SetX($cell_SAddress2['posx']);
            }
            elseif (!empty($cell_SAddress2['posy']))
            {
                $this->Pdf->SetY($cell_SAddress2['posy']);
            }
            $this->Pdf->Cell($cell_SAddress2['width'], 0, $cell_SAddress2['data'], 0, 0, $cell_SAddress2['align']);

            $this->Pdf->SetFont($cell_City['font_type'], $cell_City['font_style'], $cell_City['font_size']);
            $this->Pdf->SetTextColor($cell_City['color_r'], $cell_City['color_g'], $cell_City['color_b']);
            if (!empty($cell_City['posx']) && !empty($cell_City['posy']))
            {
                $this->Pdf->SetXY($cell_City['posx'], $cell_City['posy']);
            }
            elseif (!empty($cell_City['posx']))
            {
                $this->Pdf->SetX($cell_City['posx']);
            }
            elseif (!empty($cell_City['posy']))
            {
                $this->Pdf->SetY($cell_City['posy']);
            }
            $this->Pdf->Cell($cell_City['width'], 0, $cell_City['data'], 0, 0, $cell_City['align']);

            $this->Pdf->SetFont($cell_State['font_type'], $cell_State['font_style'], $cell_State['font_size']);
            $this->Pdf->SetTextColor($cell_State['color_r'], $cell_State['color_g'], $cell_State['color_b']);
            if (!empty($cell_State['posx']) && !empty($cell_State['posy']))
            {
                $this->Pdf->SetXY($cell_State['posx'], $cell_State['posy']);
            }
            elseif (!empty($cell_State['posx']))
            {
                $this->Pdf->SetX($cell_State['posx']);
            }
            elseif (!empty($cell_State['posy']))
            {
                $this->Pdf->SetY($cell_State['posy']);
            }
            $this->Pdf->Cell($cell_State['width'], 0, $cell_State['data'], 0, 0, $cell_State['align']);

            $this->Pdf->SetFont($cell_Zip['font_type'], $cell_Zip['font_style'], $cell_Zip['font_size']);
            $this->Pdf->SetTextColor($cell_Zip['color_r'], $cell_Zip['color_g'], $cell_Zip['color_b']);
            if (!empty($cell_Zip['posx']) && !empty($cell_Zip['posy']))
            {
                $this->Pdf->SetXY($cell_Zip['posx'], $cell_Zip['posy']);
            }
            elseif (!empty($cell_Zip['posx']))
            {
                $this->Pdf->SetX($cell_Zip['posx']);
            }
            elseif (!empty($cell_Zip['posy']))
            {
                $this->Pdf->SetY($cell_Zip['posy']);
            }
            $this->Pdf->Cell($cell_Zip['width'], 0, $cell_Zip['data'], 0, 0, $cell_Zip['align']);

            $this->Pdf->SetFont($cell_SCity['font_type'], $cell_SCity['font_style'], $cell_SCity['font_size']);
            $this->Pdf->SetTextColor($cell_SCity['color_r'], $cell_SCity['color_g'], $cell_SCity['color_b']);
            if (!empty($cell_SCity['posx']) && !empty($cell_SCity['posy']))
            {
                $this->Pdf->SetXY($cell_SCity['posx'], $cell_SCity['posy']);
            }
            elseif (!empty($cell_SCity['posx']))
            {
                $this->Pdf->SetX($cell_SCity['posx']);
            }
            elseif (!empty($cell_SCity['posy']))
            {
                $this->Pdf->SetY($cell_SCity['posy']);
            }
            $this->Pdf->Cell($cell_SCity['width'], 0, $cell_SCity['data'], 0, 0, $cell_SCity['align']);

            $this->Pdf->SetFont($cell_SState['font_type'], $cell_SState['font_style'], $cell_SState['font_size']);
            $this->Pdf->SetTextColor($cell_SState['color_r'], $cell_SState['color_g'], $cell_SState['color_b']);
            if (!empty($cell_SState['posx']) && !empty($cell_SState['posy']))
            {
                $this->Pdf->SetXY($cell_SState['posx'], $cell_SState['posy']);
            }
            elseif (!empty($cell_SState['posx']))
            {
                $this->Pdf->SetX($cell_SState['posx']);
            }
            elseif (!empty($cell_SState['posy']))
            {
                $this->Pdf->SetY($cell_SState['posy']);
            }
            $this->Pdf->Cell($cell_SState['width'], 0, $cell_SState['data'], 0, 0, $cell_SState['align']);

            $this->Pdf->SetFont($cell_SZip['font_type'], $cell_SZip['font_style'], $cell_SZip['font_size']);
            $this->Pdf->SetTextColor($cell_SZip['color_r'], $cell_SZip['color_g'], $cell_SZip['color_b']);
            if (!empty($cell_SZip['posx']) && !empty($cell_SZip['posy']))
            {
                $this->Pdf->SetXY($cell_SZip['posx'], $cell_SZip['posy']);
            }
            elseif (!empty($cell_SZip['posx']))
            {
                $this->Pdf->SetX($cell_SZip['posx']);
            }
            elseif (!empty($cell_SZip['posy']))
            {
                $this->Pdf->SetY($cell_SZip['posy']);
            }
            $this->Pdf->Cell($cell_SZip['width'], 0, $cell_SZip['data'], 0, 0, $cell_SZip['align']);

            $this->Pdf->SetFont($cell_Country['font_type'], $cell_Country['font_style'], $cell_Country['font_size']);
            $this->Pdf->SetTextColor($cell_Country['color_r'], $cell_Country['color_g'], $cell_Country['color_b']);
            if (!empty($cell_Country['posx']) && !empty($cell_Country['posy']))
            {
                $this->Pdf->SetXY($cell_Country['posx'], $cell_Country['posy']);
            }
            elseif (!empty($cell_Country['posx']))
            {
                $this->Pdf->SetX($cell_Country['posx']);
            }
            elseif (!empty($cell_Country['posy']))
            {
                $this->Pdf->SetY($cell_Country['posy']);
            }
            $this->Pdf->Cell($cell_Country['width'], 0, $cell_Country['data'], 0, 0, $cell_Country['align']);

            $this->Pdf->SetFont($cell_SCountry['font_type'], $cell_SCountry['font_style'], $cell_SCountry['font_size']);
            $this->Pdf->SetTextColor($cell_SCountry['color_r'], $cell_SCountry['color_g'], $cell_SCountry['color_b']);
            if (!empty($cell_SCountry['posx']) && !empty($cell_SCountry['posy']))
            {
                $this->Pdf->SetXY($cell_SCountry['posx'], $cell_SCountry['posy']);
            }
            elseif (!empty($cell_SCountry['posx']))
            {
                $this->Pdf->SetX($cell_SCountry['posx']);
            }
            elseif (!empty($cell_SCountry['posy']))
            {
                $this->Pdf->SetY($cell_SCountry['posy']);
            }
            $this->Pdf->Cell($cell_SCountry['width'], 0, $cell_SCountry['data'], 0, 0, $cell_SCountry['align']);

            $this->Pdf->SetFont($cell_SHIPPEDVIA['font_type'], $cell_SHIPPEDVIA['font_style'], $cell_SHIPPEDVIA['font_size']);
            $this->Pdf->SetTextColor($cell_SHIPPEDVIA['color_r'], $cell_SHIPPEDVIA['color_g'], $cell_SHIPPEDVIA['color_b']);
            if (!empty($cell_SHIPPEDVIA['posx']) && !empty($cell_SHIPPEDVIA['posy']))
            {
                $this->Pdf->SetXY($cell_SHIPPEDVIA['posx'], $cell_SHIPPEDVIA['posy']);
            }
            elseif (!empty($cell_SHIPPEDVIA['posx']))
            {
                $this->Pdf->SetX($cell_SHIPPEDVIA['posx']);
            }
            elseif (!empty($cell_SHIPPEDVIA['posy']))
            {
                $this->Pdf->SetY($cell_SHIPPEDVIA['posy']);
            }
            $this->Pdf->Cell($cell_SHIPPEDVIA['width'], 0, $cell_SHIPPEDVIA['data'], 0, 0, $cell_SHIPPEDVIA['align']);

            $this->Pdf->SetFont($cell_BILL_LADIN['font_type'], $cell_BILL_LADIN['font_style'], $cell_BILL_LADIN['font_size']);
            $this->Pdf->SetTextColor($cell_BILL_LADIN['color_r'], $cell_BILL_LADIN['color_g'], $cell_BILL_LADIN['color_b']);
            if (!empty($cell_BILL_LADIN['posx']) && !empty($cell_BILL_LADIN['posy']))
            {
                $this->Pdf->SetXY($cell_BILL_LADIN['posx'], $cell_BILL_LADIN['posy']);
            }
            elseif (!empty($cell_BILL_LADIN['posx']))
            {
                $this->Pdf->SetX($cell_BILL_LADIN['posx']);
            }
            elseif (!empty($cell_BILL_LADIN['posy']))
            {
                $this->Pdf->SetY($cell_BILL_LADIN['posy']);
            }
            $this->Pdf->Cell($cell_BILL_LADIN['width'], 0, $cell_BILL_LADIN['data'], 0, 0, $cell_BILL_LADIN['align']);

            $this->Pdf->SetFont($cell_CASES['font_type'], $cell_CASES['font_style'], $cell_CASES['font_size']);
            $this->Pdf->SetTextColor($cell_CASES['color_r'], $cell_CASES['color_g'], $cell_CASES['color_b']);
            if (!empty($cell_CASES['posx']) && !empty($cell_CASES['posy']))
            {
                $this->Pdf->SetXY($cell_CASES['posx'], $cell_CASES['posy']);
            }
            elseif (!empty($cell_CASES['posx']))
            {
                $this->Pdf->SetX($cell_CASES['posx']);
            }
            elseif (!empty($cell_CASES['posy']))
            {
                $this->Pdf->SetY($cell_CASES['posy']);
            }
            $this->Pdf->Cell($cell_CASES['width'], 0, $cell_CASES['data'], 0, 0, $cell_CASES['align']);

            $this->Pdf->SetFont($cell_TERMS['font_type'], $cell_TERMS['font_style'], $cell_TERMS['font_size']);
            $this->Pdf->SetTextColor($cell_TERMS['color_r'], $cell_TERMS['color_g'], $cell_TERMS['color_b']);
            if (!empty($cell_TERMS['posx']) && !empty($cell_TERMS['posy']))
            {
                $this->Pdf->SetXY($cell_TERMS['posx'], $cell_TERMS['posy']);
            }
            elseif (!empty($cell_TERMS['posx']))
            {
                $this->Pdf->SetX($cell_TERMS['posx']);
            }
            elseif (!empty($cell_TERMS['posy']))
            {
                $this->Pdf->SetY($cell_TERMS['posy']);
            }
            $this->Pdf->Cell($cell_TERMS['width'], 0, $cell_TERMS['data'], 0, 0, $cell_TERMS['align']);

            $this->Pdf->SetFont($cell_TERMS2['font_type'], $cell_TERMS2['font_style'], $cell_TERMS2['font_size']);
            $this->Pdf->SetTextColor($cell_TERMS2['color_r'], $cell_TERMS2['color_g'], $cell_TERMS2['color_b']);
            if (!empty($cell_TERMS2['posx']) && !empty($cell_TERMS2['posy']))
            {
                $this->Pdf->SetXY($cell_TERMS2['posx'], $cell_TERMS2['posy']);
            }
            elseif (!empty($cell_TERMS2['posx']))
            {
                $this->Pdf->SetX($cell_TERMS2['posx']);
            }
            elseif (!empty($cell_TERMS2['posy']))
            {
                $this->Pdf->SetY($cell_TERMS2['posy']);
            }
            $this->Pdf->Cell($cell_TERMS2['width'], 0, $cell_TERMS2['data'], 0, 0, $cell_TERMS2['align']);

            $this->Pdf->SetY(107);
            foreach ($this->items[$this->nm_grid_colunas] as $NM_ind => $Dados)
            {
                $this->Pdf->SetFont($cell_Items_LIN['font_type'], $cell_Items_LIN['font_style'], $cell_Items_LIN['font_size']);
                $this->Pdf->SetTextColor($cell_Items_LIN['color_r'], $cell_Items_LIN['color_g'], $cell_Items_LIN['color_b']);
                if (!empty($cell_Items_LIN['posx']))
                {
                    $this->Pdf->SetX($cell_Items_LIN['posx']);
                }
                $this->Pdf->Cell($cell_Items_LIN['width'], 0, $this->items_lin[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_LIN['align']);
                $this->Pdf->SetFont($cell_Items_UNIT['font_type'], $cell_Items_UNIT['font_style'], $cell_Items_UNIT['font_size']);
                $this->Pdf->SetTextColor($cell_Items_UNIT['color_r'], $cell_Items_UNIT['color_g'], $cell_Items_UNIT['color_b']);
                if (!empty($cell_Items_UNIT['posx']))
                {
                    $this->Pdf->SetX($cell_Items_UNIT['posx']);
                }
                $this->Pdf->Cell($cell_Items_UNIT['width'], 0, $this->items_unit[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_UNIT['align']);
                $this->Pdf->SetFont($cell_Items_STYLE['font_type'], $cell_Items_STYLE['font_style'], $cell_Items_STYLE['font_size']);
                $this->Pdf->SetTextColor($cell_Items_STYLE['color_r'], $cell_Items_STYLE['color_g'], $cell_Items_STYLE['color_b']);
                if (!empty($cell_Items_STYLE['posx']))
                {
                    $this->Pdf->SetX($cell_Items_STYLE['posx']);
                }
                $this->Pdf->Cell($cell_Items_STYLE['width'], 0, $this->items_style[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_STYLE['align']);
                $this->Pdf->SetFont($cell_Items_WIDTH['font_type'], $cell_Items_WIDTH['font_style'], $cell_Items_WIDTH['font_size']);
                $this->Pdf->SetTextColor($cell_Items_WIDTH['color_r'], $cell_Items_WIDTH['color_g'], $cell_Items_WIDTH['color_b']);
                if (!empty($cell_Items_WIDTH['posx']))
                {
                    $this->Pdf->SetX($cell_Items_WIDTH['posx']);
                }
                $this->Pdf->Cell($cell_Items_WIDTH['width'], 0, $this->items_width[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_WIDTH['align']);
                $this->Pdf->SetFont($cell_Items_COLOR['font_type'], $cell_Items_COLOR['font_style'], $cell_Items_COLOR['font_size']);
                $this->Pdf->SetTextColor($cell_Items_COLOR['color_r'], $cell_Items_COLOR['color_g'], $cell_Items_COLOR['color_b']);
                if (!empty($cell_Items_COLOR['posx']))
                {
                    $this->Pdf->SetX($cell_Items_COLOR['posx']);
                }
                $this->Pdf->Cell($cell_Items_COLOR['width'], 0, $this->items_color[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_COLOR['align']);
                $this->Pdf->SetFont($cell_items_DESCRIP['font_type'], $cell_items_DESCRIP['font_style'], $cell_items_DESCRIP['font_size']);
                $this->Pdf->SetTextColor($cell_items_DESCRIP['color_r'], $cell_items_DESCRIP['color_g'], $cell_items_DESCRIP['color_b']);
                if (!empty($cell_items_DESCRIP['posx']))
                {
                    $this->Pdf->SetX($cell_items_DESCRIP['posx']);
                }
                $this->Pdf->Cell($cell_items_DESCRIP['width'], 0, $this->items_descrip[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_items_DESCRIP['align']);
                $this->Pdf->SetFont($cell_Items_SMIT['font_type'], $cell_Items_SMIT['font_style'], $cell_Items_SMIT['font_size']);
                $this->Pdf->SetTextColor($cell_Items_SMIT['color_r'], $cell_Items_SMIT['color_g'], $cell_Items_SMIT['color_b']);
                if (!empty($cell_Items_SMIT['posx']))
                {
                    $this->Pdf->SetX($cell_Items_SMIT['posx']);
                }
                $this->Pdf->Cell($cell_Items_SMIT['width'], 0, $this->items_smit[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_SMIT['align']);
                $this->Pdf->SetFont($cell_Items_DYE_ORDER['font_type'], $cell_Items_DYE_ORDER['font_style'], $cell_Items_DYE_ORDER['font_size']);
                $this->Pdf->SetTextColor($cell_Items_DYE_ORDER['color_r'], $cell_Items_DYE_ORDER['color_g'], $cell_Items_DYE_ORDER['color_b']);
                if (!empty($cell_Items_DYE_ORDER['posx']))
                {
                    $this->Pdf->SetX($cell_Items_DYE_ORDER['posx']);
                }
                $this->Pdf->Cell($cell_Items_DYE_ORDER['width'], 0, $this->items_dye_order[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_DYE_ORDER['align']);
                $this->Pdf->SetFont($cell_Items_DYE_LOT['font_type'], $cell_Items_DYE_LOT['font_style'], $cell_Items_DYE_LOT['font_size']);
                $this->Pdf->SetTextColor($cell_Items_DYE_LOT['color_r'], $cell_Items_DYE_LOT['color_g'], $cell_Items_DYE_LOT['color_b']);
                if (!empty($cell_Items_DYE_LOT['posx']))
                {
                    $this->Pdf->SetX($cell_Items_DYE_LOT['posx']);
                }
                $this->Pdf->Cell($cell_Items_DYE_LOT['width'], 0, $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_DYE_LOT['align']);
                $this->Pdf->SetFont($cell_Items_CUST_ORDER['font_type'], $cell_Items_CUST_ORDER['font_style'], $cell_Items_CUST_ORDER['font_size']);
                $this->Pdf->SetTextColor($cell_Items_CUST_ORDER['color_r'], $cell_Items_CUST_ORDER['color_g'], $cell_Items_CUST_ORDER['color_b']);
                if (!empty($cell_Items_CUST_ORDER['posx']))
                {
                    $this->Pdf->SetX($cell_Items_CUST_ORDER['posx']);
                }
                $this->Pdf->Cell($cell_Items_CUST_ORDER['width'], 0, $this->items_cust_order[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_CUST_ORDER['align']);
                $this->Pdf->SetFont($cell_Items_OUR_ORDER['font_type'], $cell_Items_OUR_ORDER['font_style'], $cell_Items_OUR_ORDER['font_size']);
                $this->Pdf->SetTextColor($cell_Items_OUR_ORDER['color_r'], $cell_Items_OUR_ORDER['color_g'], $cell_Items_OUR_ORDER['color_b']);
                if (!empty($cell_Items_OUR_ORDER['posx']))
                {
                    $this->Pdf->SetX($cell_Items_OUR_ORDER['posx']);
                }
                $this->Pdf->Cell($cell_Items_OUR_ORDER['width'], 0, $this->items_our_order[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_OUR_ORDER['align']);
                $this->Pdf->SetFont($cell_Items_PRICE['font_type'], $cell_Items_PRICE['font_style'], $cell_Items_PRICE['font_size']);
                $this->Pdf->SetTextColor($cell_Items_PRICE['color_r'], $cell_Items_PRICE['color_g'], $cell_Items_PRICE['color_b']);
                if (!empty($cell_Items_PRICE['posx']))
                {
                    $this->Pdf->SetX($cell_Items_PRICE['posx']);
                }
                $this->Pdf->Cell($cell_Items_PRICE['width'], 0, $this->items_price[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_PRICE['align']);
                $this->Pdf->SetFont($cell_Items_AMOUNT['font_type'], $cell_Items_AMOUNT['font_style'], $cell_Items_AMOUNT['font_size']);
                $this->Pdf->SetTextColor($cell_Items_AMOUNT['color_r'], $cell_Items_AMOUNT['color_g'], $cell_Items_AMOUNT['color_b']);
                if (!empty($cell_Items_AMOUNT['posx']))
                {
                    $this->Pdf->SetX($cell_Items_AMOUNT['posx']);
                }
                $this->Pdf->Cell($cell_Items_AMOUNT['width'], 0, $this->items_amount[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_AMOUNT['align']);
                if (!isset($max_Y) || empty($max_Y))
                {
                    $max_Y = $this->Pdf->GetY();
                }
                $max_Y += 14;
                $this->Pdf->SetY($max_Y);

            }

            $this->Pdf->SetFont($cell_MESSAGE['font_type'], $cell_MESSAGE['font_style'], $cell_MESSAGE['font_size']);
            $this->Pdf->SetTextColor($cell_MESSAGE['color_r'], $cell_MESSAGE['color_g'], $cell_MESSAGE['color_b']);
            if (!empty($cell_MESSAGE['posx']) && !empty($cell_MESSAGE['posy']))
            {
                $this->Pdf->SetXY($cell_MESSAGE['posx'], $cell_MESSAGE['posy']);
            }
            elseif (!empty($cell_MESSAGE['posx']))
            {
                $this->Pdf->SetX($cell_MESSAGE['posx']);
            }
            elseif (!empty($cell_MESSAGE['posy']))
            {
                $this->Pdf->SetY($cell_MESSAGE['posy']);
            }
            $this->Pdf->Cell($cell_MESSAGE['width'], 0, $cell_MESSAGE['data'], 0, 0, $cell_MESSAGE['align']);

            $this->Pdf->SetFont($cell_ADD_ONS['font_type'], $cell_ADD_ONS['font_style'], $cell_ADD_ONS['font_size']);
            $this->Pdf->SetTextColor($cell_ADD_ONS['color_r'], $cell_ADD_ONS['color_g'], $cell_ADD_ONS['color_b']);
            if (!empty($cell_ADD_ONS['posx']) && !empty($cell_ADD_ONS['posy']))
            {
                $this->Pdf->SetXY($cell_ADD_ONS['posx'], $cell_ADD_ONS['posy']);
            }
            elseif (!empty($cell_ADD_ONS['posx']))
            {
                $this->Pdf->SetX($cell_ADD_ONS['posx']);
            }
            elseif (!empty($cell_ADD_ONS['posy']))
            {
                $this->Pdf->SetY($cell_ADD_ONS['posy']);
            }
            $this->Pdf->Cell($cell_ADD_ONS['width'], 0, $cell_ADD_ONS['data'], 0, 0, $cell_ADD_ONS['align']);

            $this->Pdf->SetFont($cell_ADD_CHARGE['font_type'], $cell_ADD_CHARGE['font_style'], $cell_ADD_CHARGE['font_size']);
            $this->Pdf->SetTextColor($cell_ADD_CHARGE['color_r'], $cell_ADD_CHARGE['color_g'], $cell_ADD_CHARGE['color_b']);
            if (!empty($cell_ADD_CHARGE['posx']) && !empty($cell_ADD_CHARGE['posy']))
            {
                $this->Pdf->SetXY($cell_ADD_CHARGE['posx'], $cell_ADD_CHARGE['posy']);
            }
            elseif (!empty($cell_ADD_CHARGE['posx']))
            {
                $this->Pdf->SetX($cell_ADD_CHARGE['posx']);
            }
            elseif (!empty($cell_ADD_CHARGE['posy']))
            {
                $this->Pdf->SetY($cell_ADD_CHARGE['posy']);
            }
            $this->Pdf->Cell($cell_ADD_CHARGE['width'], 0, $cell_ADD_CHARGE['data'], 0, 0, $cell_ADD_CHARGE['align']);

            $this->Pdf->SetFont($cell_AMOUNT['font_type'], $cell_AMOUNT['font_style'], $cell_AMOUNT['font_size']);
            $this->Pdf->SetTextColor($cell_AMOUNT['color_r'], $cell_AMOUNT['color_g'], $cell_AMOUNT['color_b']);
            if (!empty($cell_AMOUNT['posx']) && !empty($cell_AMOUNT['posy']))
            {
                $this->Pdf->SetXY($cell_AMOUNT['posx'], $cell_AMOUNT['posy']);
            }
            elseif (!empty($cell_AMOUNT['posx']))
            {
                $this->Pdf->SetX($cell_AMOUNT['posx']);
            }
            elseif (!empty($cell_AMOUNT['posy']))
            {
                $this->Pdf->SetY($cell_AMOUNT['posy']);
            }
            $this->Pdf->Cell($cell_AMOUNT['width'], 0, $cell_AMOUNT['data'], 0, 0, $cell_AMOUNT['align']);

          $max_Y = 0;
          $this->rs_grid->MoveNext();
          $this->sc_proc_grid = false;
          $nm_quant_linhas++ ;
      }  
   }  
   $this->rs_grid->Close();
   $this->Pdf->Output($this->Ini->root . $this->Ini->nm_path_pdf);
 }
 function SC_conv_utf8($input)
 {
     if ($this->Font_ttf && !NM_is_utf8($input))
     {
         $input = mb_convert_encoding($input, "UTF-8", $_SESSION['scriptcase']['charset']);
     }
     elseif (!$this->Font_ttf && $_SESSION['scriptcase']['charset'] == "UTF-8" && NM_is_utf8($input))
     {
         $input = mb_convert_encoding($input, "ISO-8859-9", "UTF-8");
     }
     return $input;
 }
   function nm_conv_data_db($dt_in, $form_in, $form_out)
   {
       $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);
       return $dt_out;
   }

 function Nm_date_format($Type, $Format)
 {
     $Form_base = str_replace("/", "", $Format);
     $Form_base = str_replace("-", "", $Form_base);
     $Form_base = str_replace(":", "", $Form_base);
     $Form_base = str_replace(";", "", $Form_base);
     $Form_base = str_replace(" ", "", $Form_base);
     $Form_base = str_replace("a", "Y", $Form_base);
     $Form_base = str_replace("y", "Y", $Form_base);
     $Form_base = str_replace("h", "H", $Form_base);
     $date_format_show = "";
     if ($Type == "DT" || $Type == "DH")
     {
         $Str_date = str_replace("a", "y", strtolower($_SESSION['scriptcase']['reg_conf']['date_format']));
         $Str_date = str_replace("y", "Y", $Str_date);
         $Str_date = str_replace("h", "H", $Str_date);
         $Lim   = strlen($Str_date);
         $Ult   = "";
         $Arr_D = array();
         for ($I = 0; $I < $Lim; $I++)
         {
              $Char = substr($Str_date, $I, 1);
              if ($Char != $Ult)
              {
                  $Arr_D[] = $Char;
              }
              $Ult = $Char;
         }
         $Prim = true;
         foreach ($Arr_D as $Cada_d)
         {
             if (strpos($Form_base, $Cada_d) !== false)
             {
                 $date_format_show .= (!$Prim) ? $_SESSION['scriptcase']['reg_conf']['date_sep'] : "";
                 $date_format_show .= $Cada_d;
                 $Prim = false;
             }
         }
     }
     if ($Type == "DH" || $Type == "HH")
     {
         if ($Type == "DH")
         {
             $date_format_show .= " ";
         }
         $Str_time = strtolower($_SESSION['scriptcase']['reg_conf']['time_format']);
         $Str_time = str_replace("h", "H", $Str_time);
         $Lim   = strlen($Str_time);
         $Ult   = "";
         $Arr_T = array();
         for ($I = 0; $I < $Lim; $I++)
         {
              $Char = substr($Str_time, $I, 1);
              if ($Char != $Ult)
              {
                  $Arr_T[] = $Char;
              }
              $Ult = $Char;
         }
         $Prim = true;
         foreach ($Arr_T as $Cada_t)
         {
             if (strpos($Form_base, $Cada_t) !== false)
             {
                 $date_format_show .= (!$Prim) ? $_SESSION['scriptcase']['reg_conf']['time_sep'] : "";
                 $date_format_show .= $Cada_t;
                 $Prim = false;
             }
         }
     }
     return $date_format_show;
 }

   function nm_gera_mask(&$nm_campo, $nm_mask)
   { 
      $trab_campo = $nm_campo;
      $trab_mask  = $nm_mask;
      $tam_campo  = strlen($nm_campo);
      $trab_saida = "";
      $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 ($cont2 >= $tam_campo)
              {
                  $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;
   } 
}
?>
