<?php
class orders_order_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 $assortments = array();
   var $assortments_amount = array();
   var $assortments_color = array();
   var $assortments_color_no = array();
   var $assortments_c_o_number = array();
   var $assortments_date = array();
   var $assortments_delivery = array();
   var $assortments_lin_sq = array();
   var $assortments_our_order = array();
   var $assortments_price = array();
   var $assortments_style = array();
   var $assortments_width = array();
   var $assortments_yards = array();
   var $order = array();
   var $date = array();
   var $bcode = array();
   var $scode = array();
   var $terms = array();
   var $terms2 = array();
   var $ship_via = array();
   var $how = array();
   var $howwho = array();
   var $salesman = array();
   var $comdol = array();
   var $bill_descr = array();
   var $ordered_by = array();
   var $put_up = array();
   var $rolls = array();
   var $tubes = array();
   var $finish = array();
   var $finish_no = array();
   var $style = array();
   var $width = array();
   var $quantity = array();
   var $lin_sq = array();
   var $amount = array();
   var $bp = array();
   var $released = array();
   var $dday = array();
   var $fgi = array();
   var $message = array();
   var $noship = array();
   var $addcharge = array();
   var $addfor = array();
   var $acknow = array();
   var $dup = array();
   var $dupwho = array();
   var $sld = array();
   var $she = array();
   var $whosld = array();
   var $whoshe = array();
   var $lvia = array();
   var $hvia = 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 = 'Arial';
   $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['orders_order_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("orders_order_pdf", $apls_aba))
           {
               $this->aba_iframe = true;
               break;
           }
       }
   }
   if ($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_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]['orders_order_pdf']['campos_busca']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['campos_busca']))
   { 
       $this->order[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['campos_busca']['order']; 
       $tmp_pos = strpos($this->order[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->order[0] = substr($this->order[0], 0, $tmp_pos);
       }
       $this->date[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_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]['orders_order_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->nm_field_dinamico = array();
   $this->nm_order_dinamico = array();
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_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]['orders_order_pdf']['qt_col_grid'] = 1 ;  
   if (isset($_SESSION['scriptcase']['sc_apl_conf']['orders_order_pdf']['cols']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['orders_order_pdf']['cols']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['qt_col_grid'] = $_SESSION['scriptcase']['sc_apl_conf']['orders_order_pdf']['cols'];  
       unset($_SESSION['scriptcase']['sc_apl_conf']['orders_order_pdf']['cols']);
   }
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_select']))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_select'] = array(); 
   } 
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_quebra']))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_grid'] = "" ; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_ant']  = ""; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_desc'] = "" ; 
   }   
   if (!empty($nmgp_parms) && $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['opcao'] != "pdf")   
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['opcao'] = "igual";
       $rec = "ini";
   }
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig']) || $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['prim_cons'] || !empty($nmgp_parms))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['prim_cons'] = false;  
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig'] = " where `ORDER`='" . $_SESSION['var_order'] . "'";  
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq']        = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig'];  
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq_ant']    = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig'];  
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['cond_pesq']         = ""; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq_filtro'] = "";
   }   
   if  (!empty($this->nm_where_dinamico)) 
   {   
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq'] .= $this->nm_where_dinamico;
   }   
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq_filtro'];
//
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['tot_geral'][1])) 
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['total'] = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['tot_geral'][1] ;  
   }
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq_ant'] = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq'];  
//----- 
   if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
   { 
       $nmgp_select = "SELECT `ORDER` as sc_def_col_1, str_replace (convert(char(10),`DATE`,102), '.', '-') + ' ' + convert(char(8),`DATE`,20) as sc_def_col_2, BCODE, SCODE, TERMS, TERMS2, SHIP_VIA, HOW, HOWWHO, SALESMAN, COMDOL, BILL_DESCR, ORDERED_BY, PUT_UP, ROLLS, TUBES, FINISH, FINISH_NO, STYLE, WIDTH, QUANTITY, LIN_SQ, AMOUNT, BP, RELEASED, DDAY, FGI, MESSAGE, NOSHIP, ADDCHARGE, ADDFOR, ACKNOW, DUP, DUPWHO, SLD, SHE, WHOSLD, WHOSHE, LVIA, HVIA from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
   { 
       $nmgp_select = "SELECT `ORDER` as sc_def_col_1, `DATE` as sc_def_col_2, BCODE, SCODE, TERMS, TERMS2, SHIP_VIA, HOW, HOWWHO, SALESMAN, COMDOL, BILL_DESCR, ORDERED_BY, PUT_UP, ROLLS, TUBES, FINISH, FINISH_NO, STYLE, WIDTH, QUANTITY, LIN_SQ, AMOUNT, BP, RELEASED, DDAY, FGI, MESSAGE, NOSHIP, ADDCHARGE, ADDFOR, ACKNOW, DUP, DUPWHO, SLD, SHE, WHOSLD, WHOSHE, LVIA, HVIA from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
   { 
       $nmgp_select = "SELECT `ORDER` as sc_def_col_1, convert(char(23),`DATE`,121) as sc_def_col_2, BCODE, SCODE, TERMS, TERMS2, SHIP_VIA, HOW, HOWWHO, SALESMAN, COMDOL, BILL_DESCR, ORDERED_BY, PUT_UP, ROLLS, TUBES, FINISH, FINISH_NO, STYLE, WIDTH, QUANTITY, LIN_SQ, AMOUNT, BP, RELEASED, DDAY, FGI, MESSAGE, NOSHIP, ADDCHARGE, ADDFOR, ACKNOW, DUP, DUPWHO, SLD, SHE, WHOSLD, WHOSHE, LVIA, HVIA from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
   { 
       $nmgp_select = "SELECT `ORDER` as sc_def_col_1, `DATE` as sc_def_col_2, BCODE, SCODE, TERMS, TERMS2, SHIP_VIA, HOW, HOWWHO, SALESMAN, COMDOL, BILL_DESCR, ORDERED_BY, PUT_UP, ROLLS, TUBES, FINISH, FINISH_NO, STYLE, WIDTH, QUANTITY, LIN_SQ, AMOUNT, BP, RELEASED, DDAY, FGI, MESSAGE, NOSHIP, ADDCHARGE, ADDFOR, ACKNOW, DUP, DUPWHO, SLD, SHE, WHOSLD, WHOSHE, LVIA, HVIA from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
   { 
       $nmgp_select = "SELECT `ORDER` as sc_def_col_1, EXTEND(`DATE`, YEAR TO DAY) as sc_def_col_2, BCODE, SCODE, TERMS, TERMS2, SHIP_VIA, HOW, HOWWHO, SALESMAN, COMDOL, BILL_DESCR, ORDERED_BY, PUT_UP, ROLLS, TUBES, FINISH, FINISH_NO, STYLE, WIDTH, QUANTITY, LIN_SQ, AMOUNT, BP, RELEASED, DDAY, FGI, MESSAGE, NOSHIP, ADDCHARGE, ADDFOR, ACKNOW, DUP, DUPWHO, SLD, SHE, WHOSLD, WHOSHE, LVIA, HVIA from " . $this->Ini->nm_tabela; 
   } 
   else 
   { 
       $nmgp_select = "SELECT `ORDER` as sc_def_col_1, `DATE` as sc_def_col_2, BCODE, SCODE, TERMS, TERMS2, SHIP_VIA, HOW, HOWWHO, SALESMAN, COMDOL, BILL_DESCR, ORDERED_BY, PUT_UP, ROLLS, TUBES, FINISH, FINISH_NO, STYLE, WIDTH, QUANTITY, LIN_SQ, AMOUNT, BP, RELEASED, DDAY, FGI, MESSAGE, NOSHIP, ADDCHARGE, ADDFOR, ACKNOW, DUP, DUPWHO, SLD, SHE, WHOSLD, WHOSHE, LVIA, HVIA from " . $this->Ini->nm_tabela; 
   } 
   $nmgp_select .= " " . $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq']; 
   $nmgp_order_by = ""; 
   $campos_order_select = "";
   foreach($_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_select'] as $campo => $ordem) 
   {
        if ($campo != $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_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]['orders_order_pdf']['ordem_grid'])) 
   { 
       $nmgp_order_by = " order by " . $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['ordem_grid'] . $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_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]['orders_order_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->SetFont($this->default_font, $this->default_style, 10);
   $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 grid($linhas = 0)
 {
    global 
           $nm_saida, $nm_url_saida;
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['order'] = "ORDER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['date'] = "DATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['bcode'] = "BCODE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['scode'] = "SCODE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['terms'] = "TERMS";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['terms2'] = "TERMS2";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['ship_via'] = "SHIP_VIA";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['how'] = "HOW";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['howwho'] = "HOWWHO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['salesman'] = "SALESMAN";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['comdol'] = "COMDOL";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['bill_descr'] = "BILL_DESCR";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['ordered_by'] = "ORDERED_BY";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['put_up'] = "PUT_UP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['rolls'] = "ROLLS";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['tubes'] = "TUBES";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['finish'] = "FINISH";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['finish_no'] = "FINISH_NO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['style'] = "STYLE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['width'] = "WIDTH";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['quantity'] = "QUANTITY";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['lin_sq'] = "LIN_SQ";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['amount'] = "AMOUNT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['bp'] = "BP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['released'] = "RELEASED";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['dday'] = "DDAY";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['fgi'] = "FGI";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['message'] = "MESSAGE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['noship'] = "NOSHIP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['addcharge'] = "ADDCHARGE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['addfor'] = "ADDFOR";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['acknow'] = "ACKNOW";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['dup'] = "DUP";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['dupwho'] = "DUPWHO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['sld'] = "SLD";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['she'] = "SHE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['whosld'] = "WHOSLD";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['whoshe'] = "WHOSHE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['lvia'] = "LVIA";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['hvia'] = "HVIA";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments'] = "assortments";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_amount'] = "AMOUNT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_color'] = "COLOR";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_color_no'] = "COLOR NO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_c_o_number'] = "C O NUMBER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_date'] = "DATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_delivery'] = "DELIVERY";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_lin_sq'] = "LIN SQ";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_our_order'] = "OUR ORDER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_price'] = "PRICE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_style'] = "STYLE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_width'] = "WIDTH";
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['labels']['assortments_yards'] = "YARDS";
   $HTTP_REFERER = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ""; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['seq_dir'] = 0; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['sub_dir'] = array(); 
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['where_pesq_filtro'];
   if (isset($_SESSION['scriptcase']['sc_apl_conf']['orders_order_pdf']['lig_edit']) && $_SESSION['scriptcase']['sc_apl_conf']['orders_order_pdf']['lig_edit'] != '')
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['mostra_edit'] = $_SESSION['scriptcase']['sc_apl_conf']['orders_order_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_scale();
      $this->Pdf_init();
      while (!$this->rs_grid->EOF && $nm_quant_linhas < $_SESSION['sc_session'][$this->Ini->sc_page]['orders_order_pdf']['qt_col_grid']) 
      {  
          $this->sc_proc_grid = true;
          $this->SC_seq_register++; 
          $this->order[$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->terms[$this->nm_grid_colunas] = $this->rs_grid->fields[4] ;  
          $this->terms2[$this->nm_grid_colunas] = $this->rs_grid->fields[5] ;  
          $this->ship_via[$this->nm_grid_colunas] = $this->rs_grid->fields[6] ;  
          $this->how[$this->nm_grid_colunas] = $this->rs_grid->fields[7] ;  
          $this->howwho[$this->nm_grid_colunas] = $this->rs_grid->fields[8] ;  
          $this->salesman[$this->nm_grid_colunas] = $this->rs_grid->fields[9] ;  
          $this->comdol[$this->nm_grid_colunas] = $this->rs_grid->fields[10] ;  
          $this->comdol[$this->nm_grid_colunas] = (strpos(strtolower($this->comdol[$this->nm_grid_colunas]), "e")) ? (float)$this->comdol[$this->nm_grid_colunas] : $this->comdol[$this->nm_grid_colunas]; 
          $this->comdol[$this->nm_grid_colunas] = (string)$this->comdol[$this->nm_grid_colunas];
          $this->bill_descr[$this->nm_grid_colunas] = $this->rs_grid->fields[11] ;  
          $this->ordered_by[$this->nm_grid_colunas] = $this->rs_grid->fields[12] ;  
          $this->put_up[$this->nm_grid_colunas] = $this->rs_grid->fields[13] ;  
          $this->rolls[$this->nm_grid_colunas] = $this->rs_grid->fields[14] ;  
          $this->tubes[$this->nm_grid_colunas] = $this->rs_grid->fields[15] ;  
          $this->finish[$this->nm_grid_colunas] = $this->rs_grid->fields[16] ;  
          $this->finish_no[$this->nm_grid_colunas] = $this->rs_grid->fields[17] ;  
          $this->style[$this->nm_grid_colunas] = $this->rs_grid->fields[18] ;  
          $this->width[$this->nm_grid_colunas] = $this->rs_grid->fields[19] ;  
          $this->quantity[$this->nm_grid_colunas] = $this->rs_grid->fields[20] ;  
          $this->quantity[$this->nm_grid_colunas] = (string)$this->quantity[$this->nm_grid_colunas];
          $this->lin_sq[$this->nm_grid_colunas] = $this->rs_grid->fields[21] ;  
          $this->amount[$this->nm_grid_colunas] = $this->rs_grid->fields[22] ;  
          $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->bp[$this->nm_grid_colunas] = $this->rs_grid->fields[23] ;  
          $this->bp[$this->nm_grid_colunas] = (strpos(strtolower($this->bp[$this->nm_grid_colunas]), "e")) ? (float)$this->bp[$this->nm_grid_colunas] : $this->bp[$this->nm_grid_colunas]; 
          $this->bp[$this->nm_grid_colunas] = (string)$this->bp[$this->nm_grid_colunas];
          $this->released[$this->nm_grid_colunas] = $this->rs_grid->fields[24] ;  
          $this->released[$this->nm_grid_colunas] = (string)$this->released[$this->nm_grid_colunas];
          $this->dday[$this->nm_grid_colunas] = $this->rs_grid->fields[25] ;  
          $this->dday[$this->nm_grid_colunas] = (string)$this->dday[$this->nm_grid_colunas];
          $this->fgi[$this->nm_grid_colunas] = $this->rs_grid->fields[26] ;  
          $this->fgi[$this->nm_grid_colunas] = (string)$this->fgi[$this->nm_grid_colunas];
          $this->message[$this->nm_grid_colunas] = $this->rs_grid->fields[27] ;  
          $this->noship[$this->nm_grid_colunas] = $this->rs_grid->fields[28] ;  
          $this->addcharge[$this->nm_grid_colunas] = $this->rs_grid->fields[29] ;  
          $this->addcharge[$this->nm_grid_colunas] =  str_replace(",", ".", $this->addcharge[$this->nm_grid_colunas]);
          $this->addcharge[$this->nm_grid_colunas] = (strpos(strtolower($this->addcharge[$this->nm_grid_colunas]), "e")) ? (float)$this->addcharge[$this->nm_grid_colunas] : $this->addcharge[$this->nm_grid_colunas]; 
          $this->addcharge[$this->nm_grid_colunas] = (string)$this->addcharge[$this->nm_grid_colunas];
          $this->addfor[$this->nm_grid_colunas] = $this->rs_grid->fields[30] ;  
          $this->acknow[$this->nm_grid_colunas] = $this->rs_grid->fields[31] ;  
          $this->dup[$this->nm_grid_colunas] = $this->rs_grid->fields[32] ;  
          $this->dupwho[$this->nm_grid_colunas] = $this->rs_grid->fields[33] ;  
          $this->sld[$this->nm_grid_colunas] = $this->rs_grid->fields[34] ;  
          $this->she[$this->nm_grid_colunas] = $this->rs_grid->fields[35] ;  
          $this->whosld[$this->nm_grid_colunas] = $this->rs_grid->fields[36] ;  
          $this->whoshe[$this->nm_grid_colunas] = $this->rs_grid->fields[37] ;  
          $this->lvia[$this->nm_grid_colunas] = $this->rs_grid->fields[38] ;  
          $this->hvia[$this->nm_grid_colunas] = $this->rs_grid->fields[39] ;  
          $this->assortments_amount[$this->nm_grid_colunas] = array();
          $this->assortments_color[$this->nm_grid_colunas] = array();
          $this->assortments_color_no[$this->nm_grid_colunas] = array();
          $this->assortments_c_o_number[$this->nm_grid_colunas] = array();
          $this->assortments_date[$this->nm_grid_colunas] = array();
          $this->assortments_delivery[$this->nm_grid_colunas] = array();
          $this->assortments_lin_sq[$this->nm_grid_colunas] = array();
          $this->assortments_our_order[$this->nm_grid_colunas] = array();
          $this->assortments_price[$this->nm_grid_colunas] = array();
          $this->assortments_style[$this->nm_grid_colunas] = array();
          $this->assortments_width[$this->nm_grid_colunas] = array();
          $this->assortments_yards[$this->nm_grid_colunas] = array();
          $this->Lookup->lookup_assortments($this->assortments[$this->nm_grid_colunas] , $this->order[$this->nm_grid_colunas], $array_assortments); 
          $NM_ind = 0;
          $this->assortments = array();
          foreach ($array_assortments as $cada_subselect) 
          {
              $this->assortments[$this->nm_grid_colunas][$NM_ind] = "";
              $this->assortments_our_order[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[0];
              $this->assortments_date[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[1];
              $this->assortments_style[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[2];
              $this->assortments_width[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[3];
              $this->assortments_color[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[4];
              $this->assortments_color_no[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[5];
              $this->assortments_yards[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[6];
              $this->assortments_lin_sq[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[7];
              $this->assortments_delivery[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[8];
              $this->assortments_c_o_number[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[9];
              $this->assortments_price[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[10];
              $this->assortments_amount[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[11];
              $NM_ind++;
          }
          $this->order[$this->nm_grid_colunas] = $this->order[$this->nm_grid_colunas];
          if ($this->order[$this->nm_grid_colunas] === "") 
          { 
              $this->order[$this->nm_grid_colunas] = "" ;  
          } 
          $this->order[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->order[$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->Lookup->lookup_bcode($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->Lookup->lookup_scode($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->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->ship_via[$this->nm_grid_colunas] = $this->ship_via[$this->nm_grid_colunas];
          if ($this->ship_via[$this->nm_grid_colunas] === "") 
          { 
              $this->ship_via[$this->nm_grid_colunas] = "" ;  
          } 
          $this->ship_via[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->ship_via[$this->nm_grid_colunas]);
          $this->how[$this->nm_grid_colunas] = $this->how[$this->nm_grid_colunas];
          if ($this->how[$this->nm_grid_colunas] === "") 
          { 
              $this->how[$this->nm_grid_colunas] = "" ;  
          } 
          $this->how[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->how[$this->nm_grid_colunas]);
          $this->howwho[$this->nm_grid_colunas] = $this->howwho[$this->nm_grid_colunas];
          if ($this->howwho[$this->nm_grid_colunas] === "") 
          { 
              $this->howwho[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->howwho[$this->nm_grid_colunas] = nl2br($this->howwho[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->howwho[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->howwho[$this->nm_grid_colunas]); 
              } 
              $this->howwho[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->howwho[$this->nm_grid_colunas])) 
                 { 
                     $this->howwho[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->howwho[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->howwho[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->howwho[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->howwho[$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->comdol[$this->nm_grid_colunas] = $this->comdol[$this->nm_grid_colunas];
          if ($this->comdol[$this->nm_grid_colunas] === "") 
          { 
              $this->comdol[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->comdol[$this->nm_grid_colunas], $_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->comdol[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->comdol[$this->nm_grid_colunas]);
          $this->bill_descr[$this->nm_grid_colunas] = $this->bill_descr[$this->nm_grid_colunas];
          if ($this->bill_descr[$this->nm_grid_colunas] === "") 
          { 
              $this->bill_descr[$this->nm_grid_colunas] = "" ;  
          } 
          $this->bill_descr[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->bill_descr[$this->nm_grid_colunas]);
          $this->ordered_by[$this->nm_grid_colunas] = $this->ordered_by[$this->nm_grid_colunas];
          if ($this->ordered_by[$this->nm_grid_colunas] === "") 
          { 
              $this->ordered_by[$this->nm_grid_colunas] = "" ;  
          } 
          $this->ordered_by[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->ordered_by[$this->nm_grid_colunas]);
          $this->put_up[$this->nm_grid_colunas] = $this->put_up[$this->nm_grid_colunas];
          if ($this->put_up[$this->nm_grid_colunas] === "") 
          { 
              $this->put_up[$this->nm_grid_colunas] = "" ;  
          } 
          $this->put_up[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->put_up[$this->nm_grid_colunas]);
          $this->rolls[$this->nm_grid_colunas] = $this->rolls[$this->nm_grid_colunas];
          if ($this->rolls[$this->nm_grid_colunas] === "") 
          { 
              $this->rolls[$this->nm_grid_colunas] = "" ;  
          } 
          $this->rolls[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->rolls[$this->nm_grid_colunas]);
          $this->tubes[$this->nm_grid_colunas] = $this->tubes[$this->nm_grid_colunas];
          if ($this->tubes[$this->nm_grid_colunas] === "") 
          { 
              $this->tubes[$this->nm_grid_colunas] = "" ;  
          } 
          $this->tubes[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->tubes[$this->nm_grid_colunas]);
          $this->finish[$this->nm_grid_colunas] = $this->finish[$this->nm_grid_colunas];
          if ($this->finish[$this->nm_grid_colunas] === "") 
          { 
              $this->finish[$this->nm_grid_colunas] = "" ;  
          } 
          $this->finish[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->finish[$this->nm_grid_colunas]);
          $this->finish_no[$this->nm_grid_colunas] = $this->finish_no[$this->nm_grid_colunas];
          if ($this->finish_no[$this->nm_grid_colunas] === "") 
          { 
              $this->finish_no[$this->nm_grid_colunas] = "" ;  
          } 
          $this->finish_no[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->finish_no[$this->nm_grid_colunas]);
          $this->style[$this->nm_grid_colunas] = $this->style[$this->nm_grid_colunas];
          if ($this->style[$this->nm_grid_colunas] === "") 
          { 
              $this->style[$this->nm_grid_colunas] = "" ;  
          } 
          $this->style[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->style[$this->nm_grid_colunas]);
          $this->width[$this->nm_grid_colunas] = $this->width[$this->nm_grid_colunas];
          if ($this->width[$this->nm_grid_colunas] === "") 
          { 
              $this->width[$this->nm_grid_colunas] = "" ;  
          } 
          $this->width[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->width[$this->nm_grid_colunas]);
          $this->quantity[$this->nm_grid_colunas] = $this->quantity[$this->nm_grid_colunas];
          if ($this->quantity[$this->nm_grid_colunas] === "") 
          { 
              $this->quantity[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->quantity[$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->quantity[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->quantity[$this->nm_grid_colunas]);
          $this->lin_sq[$this->nm_grid_colunas] = $this->lin_sq[$this->nm_grid_colunas];
          if ($this->lin_sq[$this->nm_grid_colunas] === "") 
          { 
              $this->lin_sq[$this->nm_grid_colunas] = "" ;  
          } 
          $this->lin_sq[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->lin_sq[$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->bp[$this->nm_grid_colunas] = $this->bp[$this->nm_grid_colunas];
          if ($this->bp[$this->nm_grid_colunas] === "") 
          { 
              $this->bp[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->bp[$this->nm_grid_colunas], $_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->bp[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->bp[$this->nm_grid_colunas]);
          $this->released[$this->nm_grid_colunas] = $this->released[$this->nm_grid_colunas];
          if ($this->released[$this->nm_grid_colunas] === "") 
          { 
              $this->released[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->released[$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->released[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->released[$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->fgi[$this->nm_grid_colunas] = $this->fgi[$this->nm_grid_colunas];
          if ($this->fgi[$this->nm_grid_colunas] === "") 
          { 
              $this->fgi[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->fgi[$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->fgi[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->fgi[$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] = "" ;  
          } 
          else   
          { 
              $this->message[$this->nm_grid_colunas] = nl2br($this->message[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->message[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->message[$this->nm_grid_colunas]); 
              } 
              $this->message[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->message[$this->nm_grid_colunas])) 
                 { 
                     $this->message[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->message[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->message[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->message[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->message[$this->nm_grid_colunas]);
          $this->noship[$this->nm_grid_colunas] = $this->noship[$this->nm_grid_colunas];
          if ($this->noship[$this->nm_grid_colunas] === "") 
          { 
              $this->noship[$this->nm_grid_colunas] = "" ;  
          } 
          $this->noship[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->noship[$this->nm_grid_colunas]);
          $this->addcharge[$this->nm_grid_colunas] = $this->addcharge[$this->nm_grid_colunas];
          if ($this->addcharge[$this->nm_grid_colunas] === "") 
          { 
              $this->addcharge[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->addcharge[$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->addcharge[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->addcharge[$this->nm_grid_colunas]);
          $this->addfor[$this->nm_grid_colunas] = $this->addfor[$this->nm_grid_colunas];
          if ($this->addfor[$this->nm_grid_colunas] === "") 
          { 
              $this->addfor[$this->nm_grid_colunas] = "" ;  
          } 
          $this->addfor[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->addfor[$this->nm_grid_colunas]);
          $this->acknow[$this->nm_grid_colunas] = $this->acknow[$this->nm_grid_colunas];
          if ($this->acknow[$this->nm_grid_colunas] === "") 
          { 
              $this->acknow[$this->nm_grid_colunas] = "" ;  
          } 
          $this->acknow[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->acknow[$this->nm_grid_colunas]);
          $this->dup[$this->nm_grid_colunas] = $this->dup[$this->nm_grid_colunas];
          if ($this->dup[$this->nm_grid_colunas] === "") 
          { 
              $this->dup[$this->nm_grid_colunas] = "" ;  
          } 
          $this->dup[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->dup[$this->nm_grid_colunas]);
          $this->dupwho[$this->nm_grid_colunas] = $this->dupwho[$this->nm_grid_colunas];
          if ($this->dupwho[$this->nm_grid_colunas] === "") 
          { 
              $this->dupwho[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->dupwho[$this->nm_grid_colunas] = nl2br($this->dupwho[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->dupwho[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->dupwho[$this->nm_grid_colunas]); 
              } 
              $this->dupwho[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->dupwho[$this->nm_grid_colunas])) 
                 { 
                     $this->dupwho[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->dupwho[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->dupwho[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->dupwho[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->dupwho[$this->nm_grid_colunas]);
          $this->sld[$this->nm_grid_colunas] = $this->sld[$this->nm_grid_colunas];
          if ($this->sld[$this->nm_grid_colunas] === "") 
          { 
              $this->sld[$this->nm_grid_colunas] = "" ;  
          } 
          $this->sld[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->sld[$this->nm_grid_colunas]);
          $this->she[$this->nm_grid_colunas] = $this->she[$this->nm_grid_colunas];
          if ($this->she[$this->nm_grid_colunas] === "") 
          { 
              $this->she[$this->nm_grid_colunas] = "" ;  
          } 
          $this->she[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->she[$this->nm_grid_colunas]);
          $this->whosld[$this->nm_grid_colunas] = $this->whosld[$this->nm_grid_colunas];
          if ($this->whosld[$this->nm_grid_colunas] === "") 
          { 
              $this->whosld[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->whosld[$this->nm_grid_colunas] = nl2br($this->whosld[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->whosld[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->whosld[$this->nm_grid_colunas]); 
              } 
              $this->whosld[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->whosld[$this->nm_grid_colunas])) 
                 { 
                     $this->whosld[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->whosld[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->whosld[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->whosld[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->whosld[$this->nm_grid_colunas]);
          $this->whoshe[$this->nm_grid_colunas] = $this->whoshe[$this->nm_grid_colunas];
          if ($this->whoshe[$this->nm_grid_colunas] === "") 
          { 
              $this->whoshe[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->whoshe[$this->nm_grid_colunas] = nl2br($this->whoshe[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->whoshe[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->whoshe[$this->nm_grid_colunas]); 
              } 
              $this->whoshe[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->whoshe[$this->nm_grid_colunas])) 
                 { 
                     $this->whoshe[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->whoshe[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->whoshe[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->whoshe[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->whoshe[$this->nm_grid_colunas]);
          $this->lvia[$this->nm_grid_colunas] = $this->lvia[$this->nm_grid_colunas];
          if ($this->lvia[$this->nm_grid_colunas] === "") 
          { 
              $this->lvia[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->lvia[$this->nm_grid_colunas] = nl2br($this->lvia[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->lvia[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->lvia[$this->nm_grid_colunas]); 
              } 
              $this->lvia[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->lvia[$this->nm_grid_colunas])) 
                 { 
                     $this->lvia[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->lvia[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->lvia[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->lvia[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->lvia[$this->nm_grid_colunas]);
          $this->hvia[$this->nm_grid_colunas] = $this->hvia[$this->nm_grid_colunas];
          if ($this->hvia[$this->nm_grid_colunas] === "") 
          { 
              $this->hvia[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->hvia[$this->nm_grid_colunas] = nl2br($this->hvia[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->hvia[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->hvia[$this->nm_grid_colunas]); 
              } 
              $this->hvia[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->hvia[$this->nm_grid_colunas])) 
                 { 
                     $this->hvia[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->hvia[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->hvia[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->hvia[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->hvia[$this->nm_grid_colunas]);
          foreach ($this->assortments_amount[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_amount[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_amount[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->assortments_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->assortments_amount[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_amount[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_color[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_color[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_color[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_color[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_color[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_color_no[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_color_no[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_color_no[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_color_no[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_color_no[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_c_o_number[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_c_o_number[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_c_o_number[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_c_o_number[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_c_o_number[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_date[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_date[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_date[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
               $assortments_date_x =  $this->assortments_date[$this->nm_grid_colunas][$NM_ind];
               nm_conv_limpa_dado($assortments_date_x, "YYYY-MM-DD");
               if (is_numeric($assortments_date_x) && $assortments_date_x > 0) 
               { 
                   $this->nm_data->SetaData($this->assortments_date[$this->nm_grid_colunas][$NM_ind], "YYYY-MM-DD");
                   $this->assortments_date[$this->nm_grid_colunas][$NM_ind] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
              $this->assortments_date[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_date[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_delivery[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_delivery[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_delivery[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_delivery[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_delivery[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_lin_sq[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_lin_sq[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_lin_sq[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_lin_sq[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_lin_sq[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_our_order[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_our_order[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_our_order[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_our_order[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_our_order[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_price[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_price[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_price[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->assortments_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->assortments_price[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_price[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_style[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_style[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_style[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_style[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_style[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_width[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_width[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_width[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->assortments_width[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_width[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->assortments_yards[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->assortments_yards[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->assortments_yards[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->assortments_yards[$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->assortments_yards[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->assortments_yards[$this->nm_grid_colunas][$NM_ind]);
          }
            $cell_ORDER = array('posx' => 120, 'posy' => 10, 'data' => $this->order[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_DATE = array('posx' => 120, 'posy' => 15, 'data' => $this->date[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ORDERED_BY = array('posx' => 120, 'posy' => 20, 'data' => $this->ordered_by[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_BCODE = array('posx' => 5, 'posy' => 25, 'data' => $this->bcode[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SCODE = array('posx' => 120, 'posy' => 25, 'data' => $this->scode[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_TERMS = array('posx' => 5, 'posy' => 30, 'data' => $this->terms[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_TERMS2 = array('posx' => 5, 'posy' => 35, 'data' => $this->terms2[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SHIP_VIA = array('posx' => 5, 'posy' => 40, 'data' => $this->ship_via[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_HOW = array('posx' => 40, 'posy' => 40, 'data' => $this->how[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_HOWWHO = array('posx' => 70, 'posy' => 40, 'data' => $this->howwho[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SALESMAN = array('posx' => 5, 'posy' => 45, 'data' => $this->salesman[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_PUT_UP = array('posx' => 5, 'posy' => 50, 'data' => $this->put_up[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ROLLS = array('posx' => 30, 'posy' => 50, 'data' => $this->rolls[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_TUBES = array('posx' => 50, 'posy' => 50, 'data' => $this->tubes[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_FINISH = array('posx' => 5, 'posy' => 55, 'data' => $this->finish[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_FINISH_NO = array('posx' => 40, 'posy' => 55, 'data' => $this->finish_no[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_STYLE = array('posx' => 5, 'posy' => 60, 'data' => $this->style[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_BILL_DESCR = array('posx' => 5, 'posy' => 60, 'data' => $this->bill_descr[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_WIDTH = array('posx' => 20, 'posy' => 65, 'data' => $this->width[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SLD = array('posx' => 5, 'posy' => 70, 'data' => $this->sld[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SHE = array('posx' => 120, 'posy' => 75, 'data' => $this->she[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_WHOSLD = array('posx' => 5, 'posy' => 80, 'data' => $this->whosld[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_WHOSHE = array('posx' => 120, 'posy' => 85, 'data' => $this->whoshe[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_LVIA = array('posx' => 5, 'posy' => 90, 'data' => $this->lvia[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_HVIA = array('posx' => 120, 'posy' => 95, 'data' => $this->hvia[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_DATE = array('posx' => 5, 'posy' => 100, 'data' => $this->assortments_date[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_WIDTH = array('posx' => 30, 'posy' => 100, 'data' => $this->assortments_width[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_COLOR = array('posx' => 50, 'posy' => 100, 'data' => $this->assortments_color[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_COLOR_NO = array('posx' => 70, 'posy' => 100, 'data' => $this->assortments_color_no[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_YARDS = array('posx' => 90, 'posy' => 100, 'data' => $this->assortments_yards[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_LIN_SQ = array('posx' => 110, 'posy' => 100, 'data' => $this->assortments_lin_sq[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_DELIVERY = array('posx' => 120, 'posy' => 100, 'data' => $this->assortments_delivery[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_C_O_NUMBER = array('posx' => 140, 'posy' => 100, 'data' => $this->assortments_c_o_number[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_PRICE = array('posx' => 160, 'posy' => 100, 'data' => $this->assortments_price[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_AMOUNT = array('posx' => 180, 'posy' => 100, 'data' => $this->assortments_amount[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_assortments_OUR_ORDER = array('posx' => 200, 'posy' => 100, 'data' => $this->assortments_our_order[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_QUANTITY = array('posx' => 90, 'posy' => 110, 'data' => $this->quantity[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ADDFOR = array('posx' => 110, 'posy' => 115, 'data' => $this->addfor[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ADDCHARGE = array('posx' => 180, 'posy' => 120, 'data' => $this->addcharge[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_AMOUNT = array('posx' => 180, 'posy' => 125, 'data' => $this->amount[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 10, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);


            $this->Pdf->SetFont($cell_ORDER['font_type'], $cell_ORDER['font_style'], $cell_ORDER['font_size']);
            $this->Pdf->SetTextColor($cell_ORDER['color_r'], $cell_ORDER['color_g'], $cell_ORDER['color_b']);
            if (!empty($cell_ORDER['posx']) && !empty($cell_ORDER['posy']))
            {
                $this->Pdf->SetXY($cell_ORDER['posx'], $cell_ORDER['posy']);
            }
            elseif (!empty($cell_ORDER['posx']))
            {
                $this->Pdf->SetX($cell_ORDER['posx']);
            }
            elseif (!empty($cell_ORDER['posy']))
            {
                $this->Pdf->SetY($cell_ORDER['posy']);
            }
            $this->Pdf->Cell($cell_ORDER['width'], 0, $cell_ORDER['data'], 0, 0, $cell_ORDER['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_ORDERED_BY['font_type'], $cell_ORDERED_BY['font_style'], $cell_ORDERED_BY['font_size']);
            $this->Pdf->SetTextColor($cell_ORDERED_BY['color_r'], $cell_ORDERED_BY['color_g'], $cell_ORDERED_BY['color_b']);
            if (!empty($cell_ORDERED_BY['posx']) && !empty($cell_ORDERED_BY['posy']))
            {
                $this->Pdf->SetXY($cell_ORDERED_BY['posx'], $cell_ORDERED_BY['posy']);
            }
            elseif (!empty($cell_ORDERED_BY['posx']))
            {
                $this->Pdf->SetX($cell_ORDERED_BY['posx']);
            }
            elseif (!empty($cell_ORDERED_BY['posy']))
            {
                $this->Pdf->SetY($cell_ORDERED_BY['posy']);
            }
            $this->Pdf->Cell($cell_ORDERED_BY['width'], 0, $cell_ORDERED_BY['data'], 0, 0, $cell_ORDERED_BY['align']);

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

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

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

            $this->Pdf->SetFont($cell_HOWWHO['font_type'], $cell_HOWWHO['font_style'], $cell_HOWWHO['font_size']);
            $this->Pdf->SetTextColor($cell_HOWWHO['color_r'], $cell_HOWWHO['color_g'], $cell_HOWWHO['color_b']);
            if (!empty($cell_HOWWHO['posx']) && !empty($cell_HOWWHO['posy']))
            {
                $this->Pdf->SetXY($cell_HOWWHO['posx'], $cell_HOWWHO['posy']);
            }
            elseif (!empty($cell_HOWWHO['posx']))
            {
                $this->Pdf->SetX($cell_HOWWHO['posx']);
            }
            elseif (!empty($cell_HOWWHO['posy']))
            {
                $this->Pdf->SetY($cell_HOWWHO['posy']);
            }
            $NM_partes_val = explode("<br>", $cell_HOWWHO['data']);
            $PosX = $this->Pdf->GetX();
            $Incre = false;
            foreach ($NM_partes_val as $Lines)
            {
                if ($Incre)
                {
                    $this->Pdf->Ln(3.5277777777778);
                }
                $this->Pdf->SetX($PosX);
                $this->Pdf->Cell($cell_HOWWHO['width'], 0, trim($Lines), 0, 0, $cell_HOWWHO['align']);
                $Incre = true;
            }

            $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_PUT_UP['font_type'], $cell_PUT_UP['font_style'], $cell_PUT_UP['font_size']);
            $this->Pdf->SetTextColor($cell_PUT_UP['color_r'], $cell_PUT_UP['color_g'], $cell_PUT_UP['color_b']);
            if (!empty($cell_PUT_UP['posx']) && !empty($cell_PUT_UP['posy']))
            {
                $this->Pdf->SetXY($cell_PUT_UP['posx'], $cell_PUT_UP['posy']);
            }
            elseif (!empty($cell_PUT_UP['posx']))
            {
                $this->Pdf->SetX($cell_PUT_UP['posx']);
            }
            elseif (!empty($cell_PUT_UP['posy']))
            {
                $this->Pdf->SetY($cell_PUT_UP['posy']);
            }
            $this->Pdf->Cell($cell_PUT_UP['width'], 0, $cell_PUT_UP['data'], 0, 0, $cell_PUT_UP['align']);

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

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

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

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

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

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

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

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

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

            $this->Pdf->SetFont($cell_WHOSLD['font_type'], $cell_WHOSLD['font_style'], $cell_WHOSLD['font_size']);
            $this->Pdf->SetTextColor($cell_WHOSLD['color_r'], $cell_WHOSLD['color_g'], $cell_WHOSLD['color_b']);
            if (!empty($cell_WHOSLD['posx']) && !empty($cell_WHOSLD['posy']))
            {
                $this->Pdf->SetXY($cell_WHOSLD['posx'], $cell_WHOSLD['posy']);
            }
            elseif (!empty($cell_WHOSLD['posx']))
            {
                $this->Pdf->SetX($cell_WHOSLD['posx']);
            }
            elseif (!empty($cell_WHOSLD['posy']))
            {
                $this->Pdf->SetY($cell_WHOSLD['posy']);
            }
            $NM_partes_val = explode("<br>", $cell_WHOSLD['data']);
            $PosX = $this->Pdf->GetX();
            $Incre = false;
            foreach ($NM_partes_val as $Lines)
            {
                if ($Incre)
                {
                    $this->Pdf->Ln(3.5277777777778);
                }
                $this->Pdf->SetX($PosX);
                $this->Pdf->Cell($cell_WHOSLD['width'], 0, trim($Lines), 0, 0, $cell_WHOSLD['align']);
                $Incre = true;
            }
            $this->Pdf->SetFont($cell_WHOSHE['font_type'], $cell_WHOSHE['font_style'], $cell_WHOSHE['font_size']);
            $this->Pdf->SetTextColor($cell_WHOSHE['color_r'], $cell_WHOSHE['color_g'], $cell_WHOSHE['color_b']);
            if (!empty($cell_WHOSHE['posx']) && !empty($cell_WHOSHE['posy']))
            {
                $this->Pdf->SetXY($cell_WHOSHE['posx'], $cell_WHOSHE['posy']);
            }
            elseif (!empty($cell_WHOSHE['posx']))
            {
                $this->Pdf->SetX($cell_WHOSHE['posx']);
            }
            elseif (!empty($cell_WHOSHE['posy']))
            {
                $this->Pdf->SetY($cell_WHOSHE['posy']);
            }
            $NM_partes_val = explode("<br>", $cell_WHOSHE['data']);
            $PosX = $this->Pdf->GetX();
            $Incre = false;
            foreach ($NM_partes_val as $Lines)
            {
                if ($Incre)
                {
                    $this->Pdf->Ln(3.5277777777778);
                }
                $this->Pdf->SetX($PosX);
                $this->Pdf->Cell($cell_WHOSHE['width'], 0, trim($Lines), 0, 0, $cell_WHOSHE['align']);
                $Incre = true;
            }
            $this->Pdf->SetFont($cell_LVIA['font_type'], $cell_LVIA['font_style'], $cell_LVIA['font_size']);
            $this->Pdf->SetTextColor($cell_LVIA['color_r'], $cell_LVIA['color_g'], $cell_LVIA['color_b']);
            if (!empty($cell_LVIA['posx']) && !empty($cell_LVIA['posy']))
            {
                $this->Pdf->SetXY($cell_LVIA['posx'], $cell_LVIA['posy']);
            }
            elseif (!empty($cell_LVIA['posx']))
            {
                $this->Pdf->SetX($cell_LVIA['posx']);
            }
            elseif (!empty($cell_LVIA['posy']))
            {
                $this->Pdf->SetY($cell_LVIA['posy']);
            }
            $NM_partes_val = explode("<br>", $cell_LVIA['data']);
            $PosX = $this->Pdf->GetX();
            $Incre = false;
            foreach ($NM_partes_val as $Lines)
            {
                if ($Incre)
                {
                    $this->Pdf->Ln(3.5277777777778);
                }
                $this->Pdf->SetX($PosX);
                $this->Pdf->Cell($cell_LVIA['width'], 0, trim($Lines), 0, 0, $cell_LVIA['align']);
                $Incre = true;
            }
            $this->Pdf->SetFont($cell_HVIA['font_type'], $cell_HVIA['font_style'], $cell_HVIA['font_size']);
            $this->Pdf->SetTextColor($cell_HVIA['color_r'], $cell_HVIA['color_g'], $cell_HVIA['color_b']);
            if (!empty($cell_HVIA['posx']) && !empty($cell_HVIA['posy']))
            {
                $this->Pdf->SetXY($cell_HVIA['posx'], $cell_HVIA['posy']);
            }
            elseif (!empty($cell_HVIA['posx']))
            {
                $this->Pdf->SetX($cell_HVIA['posx']);
            }
            elseif (!empty($cell_HVIA['posy']))
            {
                $this->Pdf->SetY($cell_HVIA['posy']);
            }
            $NM_partes_val = explode("<br>", $cell_HVIA['data']);
            $PosX = $this->Pdf->GetX();
            $Incre = false;
            foreach ($NM_partes_val as $Lines)
            {
                if ($Incre)
                {
                    $this->Pdf->Ln(3.5277777777778);
                }
                $this->Pdf->SetX($PosX);
                $this->Pdf->Cell($cell_HVIA['width'], 0, trim($Lines), 0, 0, $cell_HVIA['align']);
                $Incre = true;
            }

            $this->Pdf->SetY(100);
            foreach ($this->assortments[$this->nm_grid_colunas] as $NM_ind => $Dados)
            {
                $this->Pdf->SetFont($cell_assortments_DATE['font_type'], $cell_assortments_DATE['font_style'], $cell_assortments_DATE['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_DATE['color_r'], $cell_assortments_DATE['color_g'], $cell_assortments_DATE['color_b']);
                if (!empty($cell_assortments_DATE['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_DATE['posx']);
                }
                $this->Pdf->Cell($cell_assortments_DATE['width'], 0, $this->assortments_date[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_DATE['align']);
                $this->Pdf->SetFont($cell_assortments_WIDTH['font_type'], $cell_assortments_WIDTH['font_style'], $cell_assortments_WIDTH['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_WIDTH['color_r'], $cell_assortments_WIDTH['color_g'], $cell_assortments_WIDTH['color_b']);
                if (!empty($cell_assortments_WIDTH['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_WIDTH['posx']);
                }
                $this->Pdf->Cell($cell_assortments_WIDTH['width'], 0, $this->assortments_width[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_WIDTH['align']);
                $this->Pdf->SetFont($cell_assortments_COLOR['font_type'], $cell_assortments_COLOR['font_style'], $cell_assortments_COLOR['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_COLOR['color_r'], $cell_assortments_COLOR['color_g'], $cell_assortments_COLOR['color_b']);
                if (!empty($cell_assortments_COLOR['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_COLOR['posx']);
                }
                $this->Pdf->Cell($cell_assortments_COLOR['width'], 0, $this->assortments_color[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_COLOR['align']);
                $this->Pdf->SetFont($cell_assortments_COLOR_NO['font_type'], $cell_assortments_COLOR_NO['font_style'], $cell_assortments_COLOR_NO['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_COLOR_NO['color_r'], $cell_assortments_COLOR_NO['color_g'], $cell_assortments_COLOR_NO['color_b']);
                if (!empty($cell_assortments_COLOR_NO['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_COLOR_NO['posx']);
                }
                $this->Pdf->Cell($cell_assortments_COLOR_NO['width'], 0, $this->assortments_color_no[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_COLOR_NO['align']);
                $this->Pdf->SetFont($cell_assortments_YARDS['font_type'], $cell_assortments_YARDS['font_style'], $cell_assortments_YARDS['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_YARDS['color_r'], $cell_assortments_YARDS['color_g'], $cell_assortments_YARDS['color_b']);
                if (!empty($cell_assortments_YARDS['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_YARDS['posx']);
                }
                $this->Pdf->Cell($cell_assortments_YARDS['width'], 0, $this->assortments_yards[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_YARDS['align']);
                $this->Pdf->SetFont($cell_assortments_LIN_SQ['font_type'], $cell_assortments_LIN_SQ['font_style'], $cell_assortments_LIN_SQ['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_LIN_SQ['color_r'], $cell_assortments_LIN_SQ['color_g'], $cell_assortments_LIN_SQ['color_b']);
                if (!empty($cell_assortments_LIN_SQ['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_LIN_SQ['posx']);
                }
                $this->Pdf->Cell($cell_assortments_LIN_SQ['width'], 0, $this->assortments_lin_sq[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_LIN_SQ['align']);
                $this->Pdf->SetFont($cell_assortments_DELIVERY['font_type'], $cell_assortments_DELIVERY['font_style'], $cell_assortments_DELIVERY['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_DELIVERY['color_r'], $cell_assortments_DELIVERY['color_g'], $cell_assortments_DELIVERY['color_b']);
                if (!empty($cell_assortments_DELIVERY['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_DELIVERY['posx']);
                }
                $this->Pdf->Cell($cell_assortments_DELIVERY['width'], 0, $this->assortments_delivery[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_DELIVERY['align']);
                $this->Pdf->SetFont($cell_assortments_C_O_NUMBER['font_type'], $cell_assortments_C_O_NUMBER['font_style'], $cell_assortments_C_O_NUMBER['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_C_O_NUMBER['color_r'], $cell_assortments_C_O_NUMBER['color_g'], $cell_assortments_C_O_NUMBER['color_b']);
                if (!empty($cell_assortments_C_O_NUMBER['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_C_O_NUMBER['posx']);
                }
                $this->Pdf->Cell($cell_assortments_C_O_NUMBER['width'], 0, $this->assortments_c_o_number[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_C_O_NUMBER['align']);
                $this->Pdf->SetFont($cell_assortments_PRICE['font_type'], $cell_assortments_PRICE['font_style'], $cell_assortments_PRICE['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_PRICE['color_r'], $cell_assortments_PRICE['color_g'], $cell_assortments_PRICE['color_b']);
                if (!empty($cell_assortments_PRICE['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_PRICE['posx']);
                }
                $this->Pdf->Cell($cell_assortments_PRICE['width'], 0, $this->assortments_price[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_PRICE['align']);
                $this->Pdf->SetFont($cell_assortments_AMOUNT['font_type'], $cell_assortments_AMOUNT['font_style'], $cell_assortments_AMOUNT['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_AMOUNT['color_r'], $cell_assortments_AMOUNT['color_g'], $cell_assortments_AMOUNT['color_b']);
                if (!empty($cell_assortments_AMOUNT['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_AMOUNT['posx']);
                }
                $this->Pdf->Cell($cell_assortments_AMOUNT['width'], 0, $this->assortments_amount[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_AMOUNT['align']);
                $this->Pdf->SetFont($cell_assortments_OUR_ORDER['font_type'], $cell_assortments_OUR_ORDER['font_style'], $cell_assortments_OUR_ORDER['font_size']);
                $this->Pdf->SetTextColor($cell_assortments_OUR_ORDER['color_r'], $cell_assortments_OUR_ORDER['color_g'], $cell_assortments_OUR_ORDER['color_b']);
                if (!empty($cell_assortments_OUR_ORDER['posx']))
                {
                    $this->Pdf->SetX($cell_assortments_OUR_ORDER['posx']);
                }
                $this->Pdf->Cell($cell_assortments_OUR_ORDER['width'], 0, $this->assortments_our_order[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_assortments_OUR_ORDER['align']);
                if (!isset($max_Y) || empty($max_Y))
                {
                    $max_Y = $this->Pdf->GetY();
                }
                $max_Y += 5;
                $this->Pdf->SetY($max_Y);

            }

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

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

            $this->Pdf->SetFont($cell_ADDCHARGE['font_type'], $cell_ADDCHARGE['font_style'], $cell_ADDCHARGE['font_size']);
            $this->Pdf->SetTextColor($cell_ADDCHARGE['color_r'], $cell_ADDCHARGE['color_g'], $cell_ADDCHARGE['color_b']);
            if (!empty($cell_ADDCHARGE['posx']) && !empty($cell_ADDCHARGE['posy']))
            {
                $this->Pdf->SetXY($cell_ADDCHARGE['posx'], $cell_ADDCHARGE['posy']);
            }
            elseif (!empty($cell_ADDCHARGE['posx']))
            {
                $this->Pdf->SetX($cell_ADDCHARGE['posx']);
            }
            elseif (!empty($cell_ADDCHARGE['posy']))
            {
                $this->Pdf->SetY($cell_ADDCHARGE['posy']);
            }
            $this->Pdf->Cell($cell_ADDCHARGE['width'], 0, $cell_ADDCHARGE['data'], 0, 0, $cell_ADDCHARGE['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;
   } 
}
?>
