<?php
class shipping_doship_pdf_grid
{
   var $Ini;
   var $Erro;
   var $Pdf;
   var $Db;
   var $rs_grid;
   var $nm_grid_sem_reg;
   var $SC_seq_register;
   var $nm_location;
   var $nm_data;
   var $nm_cod_barra;
   var $sc_proc_grid; 
   var $nmgp_botoes = array();
   var $Campos_Mens_erro;
   var $NM_raiz_img; 
   var $Font_ttf; 
   var $items = array();
   var $items_color = array();
   var $items_color_no = array();
   var $items_custno = array();
   var $items_dye_lot = array();
   var $items_lyards = array();
   var $items_our_order = array();
   var $items_price = array();
   var $items_p_o_number = array();
   var $items_style = array();
   var $items_syards = array();
   var $items_unit = array();
   var $items_width = array();
   var $sm = array();
   var $date = array();
   var $p_o_number = array();
   var $q1 = array();
   var $s1 = array();
   var $po1 = array();
   var $via1 = array();
   var $odate = array();
   var $rdate = array();
   var $sdate = array();
   var $spoke = array();
   var $from = array();
   var $cases = array();
   var $comment = array();
   var $spec = array();
   var $att = array();
   var $how = array();
   var $howwho = 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['shipping_doship_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("shipping_doship_pdf", $apls_aba))
           {
               $this->aba_iframe = true;
               break;
           }
       }
   }
   if ($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_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]['shipping_doship_pdf']['campos_busca']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['campos_busca']))
   { 
       $this->sm[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['campos_busca']['sm']; 
       $tmp_pos = strpos($this->sm[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->sm[0] = substr($this->sm[0], 0, $tmp_pos);
       }
       $this->date[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_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->p_o_number[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['campos_busca']['p_o_number']; 
       $tmp_pos = strpos($this->p_o_number[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->p_o_number[0] = substr($this->p_o_number[0], 0, $tmp_pos);
       }
       $this->q1[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['campos_busca']['q1']; 
       $tmp_pos = strpos($this->q1[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->q1[0] = substr($this->q1[0], 0, $tmp_pos);
       }
       $this->items_our_order[0] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['campos_busca']['items_our_order']; 
       $tmp_pos = strpos($this->items_our_order[0], "##@@");
       if ($tmp_pos !== false)
       {
           $this->items_our_order[0] = substr($this->items_our_order[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]['shipping_doship_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_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]['shipping_doship_pdf']['qt_col_grid'] = 1 ;  
   if (isset($_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['cols']) && !empty($_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['cols']))
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['qt_col_grid'] = $_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['cols'];  
       unset($_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['cols']);
   }
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_select']))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_select'] = array(); 
   } 
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_quebra']))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_grid'] = "" ; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_ant']  = ""; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_desc'] = "" ; 
   }   
   if (!empty($nmgp_parms) && $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['opcao'] != "pdf")   
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['opcao'] = "igual";
       $rec = "ini";
   }
   if (!isset($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_orig']) || $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['prim_cons'] || !empty($nmgp_parms))  
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['prim_cons'] = false;  
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_orig'] = " where sm = '" . $_SESSION['var_sm'] . "'";  
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq']        = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_orig'];  
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq_ant']    = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_orig'];  
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['cond_pesq']         = ""; 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq_filtro'] = "";
   }   
   if  (!empty($this->nm_where_dinamico)) 
   {   
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq'] .= $this->nm_where_dinamico;
   }   
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq_filtro'];
//
   if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['tot_geral'][1])) 
   { 
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['total'] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['tot_geral'][1] ;  
   }
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq_ant'] = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq'];  
//----- 
   if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_sybase))
   { 
       $nmgp_select = "SELECT SM, str_replace (convert(char(10),`DATE`,102), '.', '-') + ' ' + convert(char(8),`DATE`,20) as sc_def_col_1, P_O_NUMBER, Q1, S1, PO1, VIA1, str_replace (convert(char(10),ODATE,102), '.', '-') + ' ' + convert(char(8),ODATE,20), str_replace (convert(char(10),RDATE,102), '.', '-') + ' ' + convert(char(8),RDATE,20), str_replace (convert(char(10),SDATE,102), '.', '-') + ' ' + convert(char(8),SDATE,20), SPOKE, `FROM` as sc_def_col_2, CASES, COMMENT, SPEC, ATT, HOW, HOWWHO from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
   { 
       $nmgp_select = "SELECT SM, `DATE` as sc_def_col_1, P_O_NUMBER, Q1, S1, PO1, VIA1, ODATE, RDATE, SDATE, SPOKE, `FROM` as sc_def_col_2, CASES, COMMENT, SPEC, ATT, HOW, HOWWHO from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mssql))
   { 
       $nmgp_select = "SELECT SM, convert(char(23),`DATE`,121) as sc_def_col_1, P_O_NUMBER, Q1, S1, PO1, VIA1, convert(char(23),ODATE,121), convert(char(23),RDATE,121), convert(char(23),SDATE,121), SPOKE, `FROM` as sc_def_col_2, CASES, COMMENT, SPEC, ATT, HOW, HOWWHO from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_oracle))
   { 
       $nmgp_select = "SELECT SM, `DATE` as sc_def_col_1, P_O_NUMBER, Q1, S1, PO1, VIA1, ODATE, RDATE, SDATE, SPOKE, `FROM` as sc_def_col_2, CASES, COMMENT, SPEC, ATT, HOW, HOWWHO from " . $this->Ini->nm_tabela; 
   } 
   elseif (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_informix))
   { 
       $nmgp_select = "SELECT SM, EXTEND(`DATE`, YEAR TO DAY) as sc_def_col_1, P_O_NUMBER, Q1, S1, PO1, VIA1, EXTEND(ODATE, YEAR TO DAY), EXTEND(RDATE, YEAR TO DAY), EXTEND(SDATE, YEAR TO DAY), SPOKE, `FROM` as sc_def_col_2, CASES, COMMENT, SPEC, ATT, HOW, HOWWHO from " . $this->Ini->nm_tabela; 
   } 
   else 
   { 
       $nmgp_select = "SELECT SM, `DATE` as sc_def_col_1, P_O_NUMBER, Q1, S1, PO1, VIA1, ODATE, RDATE, SDATE, SPOKE, `FROM` as sc_def_col_2, CASES, COMMENT, SPEC, ATT, HOW, HOWWHO from " . $this->Ini->nm_tabela; 
   } 
   $nmgp_select .= " " . $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq']; 
   $nmgp_order_by = ""; 
   $campos_order_select = "";
   foreach($_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_select'] as $campo => $ordem) 
   {
        if ($campo != $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_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]['shipping_doship_pdf']['ordem_grid'])) 
   { 
       $nmgp_order_by = " order by " . $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['ordem_grid'] . $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_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]['shipping_doship_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, 12);
   $this->Pdf->SetTextColor(0, 0, 0);
 }
// 
 function Pdf_image()
 {
   $this->Pdf->Image($this->NM_raiz_img . $this->Ini->path_img_global . "/sys__NM__shippingordertemplate.gif", 1, 1, 0, 0);
 }
// 
//----- 
 function grid($linhas = 0)
 {
    global 
           $nm_saida, $nm_url_saida;
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['sm'] = "SM";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['date'] = "DATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['p_o_number'] = "P O NUMBER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['q1'] = "Q1";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['s1'] = "S1";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['po1'] = "PO1";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['via1'] = "VIA1";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['odate'] = "ODATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['rdate'] = "RDATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['sdate'] = "SDATE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['spoke'] = "SPOKE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['from'] = "FROM";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['cases'] = "CASES";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['comment'] = "COMMENT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['spec'] = "SPEC";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['att'] = "ATT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['how'] = "HOW";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['howwho'] = "HOWWHO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items'] = "Items";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_color'] = "COLOR";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_color_no'] = "COLOR NO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_custno'] = "CUSTNO";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_dye_lot'] = "DYE LOT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_lyards'] = "LYARDS";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_our_order'] = "OUR ORDER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_price'] = "PRICE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_p_o_number'] = "P O NUMBER";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_style'] = "STYLE";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_syards'] = "SYARDS";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_unit'] = "UNIT";
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['labels']['items_width'] = "WIDTH";
   $HTTP_REFERER = (isset($_SERVER['HTTP_REFERER'])) ? $_SERVER['HTTP_REFERER'] : ""; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['seq_dir'] = 0; 
   $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['sub_dir'] = array(); 
   $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_orig'];
   $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq'];
   $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['where_pesq_filtro'];
   if (isset($_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['lig_edit']) && $_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['lig_edit'] != '')
   {
       $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['mostra_edit'] = $_SESSION['scriptcase']['sc_apl_conf']['shipping_doship_pdf']['lig_edit'];
   }
   if (!empty($this->nm_grid_sem_reg))
   {
       $this->Pdf_init();
       $this->Pdf->AddPage();
       $this->Pdf->SetFont($this->default_font_sr, 'B', 12);
       $this->Pdf->SetTextColor(0, 0, 0);
       $this->Pdf->Text(10, 10, html_entity_decode($this->nm_grid_sem_reg));
       $this->Pdf->Output($this->Ini->root . $this->Ini->nm_path_pdf);
       return;
   }
// 
   $Init_Pdf = true;
   $this->SC_seq_register = 0; 
   while (!$this->rs_grid->EOF) 
   {  
      $this->nm_grid_colunas = 0; 
      $nm_quant_linhas = 0;
      $this->Pdf->AddPage();
      $this->Pdf_init();
      $this->Pdf_image();
      while (!$this->rs_grid->EOF && $nm_quant_linhas < $_SESSION['sc_session'][$this->Ini->sc_page]['shipping_doship_pdf']['qt_col_grid']) 
      {  
          $this->sc_proc_grid = true;
          $this->SC_seq_register++; 
          $this->sm[$this->nm_grid_colunas] = $this->rs_grid->fields[0] ;  
          $this->date[$this->nm_grid_colunas] = $this->rs_grid->fields[1] ;  
          $this->p_o_number[$this->nm_grid_colunas] = $this->rs_grid->fields[2] ;  
          $this->q1[$this->nm_grid_colunas] = $this->rs_grid->fields[3] ;  
          $this->s1[$this->nm_grid_colunas] = $this->rs_grid->fields[4] ;  
          $this->po1[$this->nm_grid_colunas] = $this->rs_grid->fields[5] ;  
          $this->via1[$this->nm_grid_colunas] = $this->rs_grid->fields[6] ;  
          $this->odate[$this->nm_grid_colunas] = $this->rs_grid->fields[7] ;  
          $this->rdate[$this->nm_grid_colunas] = $this->rs_grid->fields[8] ;  
          $this->sdate[$this->nm_grid_colunas] = $this->rs_grid->fields[9] ;  
          $this->spoke[$this->nm_grid_colunas] = $this->rs_grid->fields[10] ;  
          $this->from[$this->nm_grid_colunas] = $this->rs_grid->fields[11] ;  
          $this->cases[$this->nm_grid_colunas] = $this->rs_grid->fields[12] ;  
          $this->comment[$this->nm_grid_colunas] = $this->rs_grid->fields[13] ;  
          $this->spec[$this->nm_grid_colunas] = $this->rs_grid->fields[14] ;  
          $this->att[$this->nm_grid_colunas] = $this->rs_grid->fields[15] ;  
          $this->how[$this->nm_grid_colunas] = $this->rs_grid->fields[16] ;  
          $this->howwho[$this->nm_grid_colunas] = $this->rs_grid->fields[17] ;  
          $this->items_color[$this->nm_grid_colunas] = array();
          $this->items_color_no[$this->nm_grid_colunas] = array();
          $this->items_custno[$this->nm_grid_colunas] = array();
          $this->items_dye_lot[$this->nm_grid_colunas] = array();
          $this->items_lyards[$this->nm_grid_colunas] = array();
          $this->items_our_order[$this->nm_grid_colunas] = array();
          $this->items_price[$this->nm_grid_colunas] = array();
          $this->items_p_o_number[$this->nm_grid_colunas] = array();
          $this->items_style[$this->nm_grid_colunas] = array();
          $this->items_syards[$this->nm_grid_colunas] = array();
          $this->items_unit[$this->nm_grid_colunas] = array();
          $this->items_width[$this->nm_grid_colunas] = array();
          $this->Lookup->lookup_items($this->items[$this->nm_grid_colunas] , $this->sm[$this->nm_grid_colunas], $array_items); 
          $NM_ind = 0;
          $this->items = array();
          foreach ($array_items as $cada_subselect) 
          {
              $this->items[$this->nm_grid_colunas][$NM_ind] = "";
              $this->items_our_order[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[0];
              $this->items_p_o_number[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[1];
              $this->items_lyards[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[2];
              $this->items_syards[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[3];
              $this->items_style[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[4];
              $this->items_color[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[5];
              $this->items_color_no[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[6];
              $this->items_width[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[7];
              $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[8];
              $this->items_price[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[9];
              $this->items_unit[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[10];
              $this->items_custno[$this->nm_grid_colunas][$NM_ind] = $cada_subselect[11];
              $NM_ind++;
          }
          $this->sm[$this->nm_grid_colunas] = $this->sm[$this->nm_grid_colunas];
          if ($this->sm[$this->nm_grid_colunas] === "") 
          { 
              $this->sm[$this->nm_grid_colunas] = "" ;  
          } 
          $this->sm[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->sm[$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->p_o_number[$this->nm_grid_colunas] = $this->p_o_number[$this->nm_grid_colunas];
          if ($this->p_o_number[$this->nm_grid_colunas] === "") 
          { 
              $this->p_o_number[$this->nm_grid_colunas] = "" ;  
          } 
          $this->p_o_number[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->p_o_number[$this->nm_grid_colunas]);
          $this->q1[$this->nm_grid_colunas] = $this->q1[$this->nm_grid_colunas];
          if ($this->q1[$this->nm_grid_colunas] === "") 
          { 
              $this->q1[$this->nm_grid_colunas] = "" ;  
          } 
          $this->q1[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->q1[$this->nm_grid_colunas]);
          $this->s1[$this->nm_grid_colunas] = $this->s1[$this->nm_grid_colunas];
          if ($this->s1[$this->nm_grid_colunas] === "") 
          { 
              $this->s1[$this->nm_grid_colunas] = "" ;  
          } 
          $this->s1[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->s1[$this->nm_grid_colunas]);
          $this->po1[$this->nm_grid_colunas] = $this->po1[$this->nm_grid_colunas];
          if ($this->po1[$this->nm_grid_colunas] === "") 
          { 
              $this->po1[$this->nm_grid_colunas] = "" ;  
          } 
          $this->po1[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->po1[$this->nm_grid_colunas]);
          $this->via1[$this->nm_grid_colunas] = $this->via1[$this->nm_grid_colunas];
          if ($this->via1[$this->nm_grid_colunas] === "") 
          { 
              $this->via1[$this->nm_grid_colunas] = "" ;  
          } 
          $this->via1[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->via1[$this->nm_grid_colunas]);
          $this->odate[$this->nm_grid_colunas] = $this->odate[$this->nm_grid_colunas];
          if ($this->odate[$this->nm_grid_colunas] === "") 
          { 
              $this->odate[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
               $odate_x =  $this->odate[$this->nm_grid_colunas];
               nm_conv_limpa_dado($odate_x, "YYYY-MM-DD");
               if (is_numeric($odate_x) && $odate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->odate[$this->nm_grid_colunas], "YYYY-MM-DD");
                   $this->odate[$this->nm_grid_colunas] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
          $this->odate[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->odate[$this->nm_grid_colunas]);
          $this->rdate[$this->nm_grid_colunas] = $this->rdate[$this->nm_grid_colunas];
          if ($this->rdate[$this->nm_grid_colunas] === "") 
          { 
              $this->rdate[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
               $rdate_x =  $this->rdate[$this->nm_grid_colunas];
               nm_conv_limpa_dado($rdate_x, "YYYY-MM-DD");
               if (is_numeric($rdate_x) && $rdate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->rdate[$this->nm_grid_colunas], "YYYY-MM-DD");
                   $this->rdate[$this->nm_grid_colunas] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
          $this->rdate[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->rdate[$this->nm_grid_colunas]);
          $this->sdate[$this->nm_grid_colunas] = $this->sdate[$this->nm_grid_colunas];
          if ($this->sdate[$this->nm_grid_colunas] === "") 
          { 
              $this->sdate[$this->nm_grid_colunas] = "" ;  
          } 
          else    
          { 
               $sdate_x =  $this->sdate[$this->nm_grid_colunas];
               nm_conv_limpa_dado($sdate_x, "YYYY-MM-DD");
               if (is_numeric($sdate_x) && $sdate_x > 0) 
               { 
                   $this->nm_data->SetaData($this->sdate[$this->nm_grid_colunas], "YYYY-MM-DD");
                   $this->sdate[$this->nm_grid_colunas] = html_entity_decode($this->nm_data->FormataSaida($this->Nm_date_format("DT", "ddmmaaaa")));
               } 
          } 
          $this->sdate[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->sdate[$this->nm_grid_colunas]);
          $this->spoke[$this->nm_grid_colunas] = $this->spoke[$this->nm_grid_colunas];
          if ($this->spoke[$this->nm_grid_colunas] === "") 
          { 
              $this->spoke[$this->nm_grid_colunas] = "" ;  
          } 
          $this->spoke[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->spoke[$this->nm_grid_colunas]);
          $this->from[$this->nm_grid_colunas] = $this->from[$this->nm_grid_colunas];
          if ($this->from[$this->nm_grid_colunas] === "") 
          { 
              $this->from[$this->nm_grid_colunas] = "" ;  
          } 
          $this->from[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->from[$this->nm_grid_colunas]);
          $this->cases[$this->nm_grid_colunas] = $this->cases[$this->nm_grid_colunas];
          if ($this->cases[$this->nm_grid_colunas] === "") 
          { 
              $this->cases[$this->nm_grid_colunas] = "" ;  
          } 
          $this->cases[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->cases[$this->nm_grid_colunas]);
          $this->comment[$this->nm_grid_colunas] = $this->comment[$this->nm_grid_colunas];
          if ($this->comment[$this->nm_grid_colunas] === "") 
          { 
              $this->comment[$this->nm_grid_colunas] = "" ;  
          } 
          $this->comment[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->comment[$this->nm_grid_colunas]);
          $this->spec[$this->nm_grid_colunas] = $this->spec[$this->nm_grid_colunas];
          if ($this->spec[$this->nm_grid_colunas] === "") 
          { 
              $this->spec[$this->nm_grid_colunas] = "" ;  
          } 
          else   
          { 
              $this->spec[$this->nm_grid_colunas] = nl2br($this->spec[$this->nm_grid_colunas]) ; 
              $temp = explode("<br />", $this->spec[$this->nm_grid_colunas]); 
              if (!isset($temp[1])) 
              { 
                  $temp = explode("<br>", $this->spec[$this->nm_grid_colunas]); 
              } 
              $this->spec[$this->nm_grid_colunas] = "" ; 
              $ind_x = 0 ; 
              while (isset($temp[$ind_x])) 
              { 
                 if (!empty($this->spec[$this->nm_grid_colunas])) 
                 { 
                     $this->spec[$this->nm_grid_colunas] .= "<br>"; 
                 } 
                 if (strlen($temp[$ind_x]) > 50) 
                 { 
                     $this->spec[$this->nm_grid_colunas] .= wordwrap($temp[$ind_x], 50, "<br>"); 
                 } 
                 else 
                 { 
                     $this->spec[$this->nm_grid_colunas] .= $temp[$ind_x]; 
                 } 
                 $ind_x++; 
              }  
          }  
          $this->spec[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->spec[$this->nm_grid_colunas]);
          $this->att[$this->nm_grid_colunas] = $this->att[$this->nm_grid_colunas];
          if ($this->att[$this->nm_grid_colunas] === "") 
          { 
              $this->att[$this->nm_grid_colunas] = "" ;  
          } 
          $this->att[$this->nm_grid_colunas] = $this->SC_conv_utf8($this->att[$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]);
          foreach ($this->items_color[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_color[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_color[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_color[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_color[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_color_no[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_color_no[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_color_no[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_color_no[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_color_no[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_custno[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_custno[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_custno[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_custno[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_custno[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_dye_lot[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_dye_lot[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_lyards[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_lyards[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_lyards[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_lyards[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_lyards[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_lyards[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_our_order[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_our_order[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_our_order[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_our_order[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_our_order[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_price[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_price[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_price[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_price[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_price[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_price[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_p_o_number[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_p_o_number[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_p_o_number[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_p_o_number[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_p_o_number[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_style[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_style[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_style[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_style[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_style[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_syards[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_syards[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_syards[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
          else    
          { 
              nmgp_Form_Num_Val($this->items_syards[$this->nm_grid_colunas][$NM_ind], $_SESSION['scriptcase']['reg_conf']['grup_num'], $_SESSION['scriptcase']['reg_conf']['dec_num'], "3", "S", "2", "", "N:" . $_SESSION['scriptcase']['reg_conf']['neg_num'], $_SESSION['scriptcase']['reg_conf']['simb_neg'], $_SESSION['scriptcase']['reg_conf']['num_group_digit']) ; 
          } 
              $this->items_syards[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_syards[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_unit[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_unit[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_unit[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_unit[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_unit[$this->nm_grid_colunas][$NM_ind]);
          }
          foreach ($this->items_width[$this->nm_grid_colunas] as $NM_ind => $Dados) 
          {
          if ($this->items_width[$this->nm_grid_colunas][$NM_ind] === "") 
          { 
              $this->items_width[$this->nm_grid_colunas][$NM_ind] = "" ;  
          } 
              $this->items_width[$this->nm_grid_colunas][$NM_ind] = $this->SC_conv_utf8($this->items_width[$this->nm_grid_colunas][$NM_ind]);
          }
            $cell_SM = array('posx' => 120, 'posy' => 10, 'data' => $this->sm[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, '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'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_P_O_NUMBER = array('posx' => 120, 'posy' => 20, 'data' => $this->p_o_number[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Q1 = array('posx' => 10, 'posy' => 30, 'data' => $this->q1[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_S1 = array('posx' => 75, 'posy' => 30, 'data' => $this->s1[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_PO1 = array('posx' => 10, 'posy' => 60, 'data' => $this->po1[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_VIA1 = array('posx' => 10, 'posy' => 70, 'data' => $this->via1[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_HOW = array('posx' => 10, 'posy' => 80, 'data' => $this->how[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_HOWWHO = array('posx' => 10, 'posy' => 90, 'data' => $this->howwho[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ODATE = array('posx' => 10, 'posy' => 95, 'data' => $this->odate[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_RDATE = array('posx' => 10, 'posy' => 100, 'data' => $this->rdate[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SDATE = array('posx' => 10, 'posy' => 130, 'data' => $this->sdate[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SPOKE = array('posx' => 10, 'posy' => 140, 'data' => $this->spoke[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_FROM = array('posx' => 10, 'posy' => 160, 'data' => $this->from[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_CASES = array('posx' => 10, 'posy' => 170, 'data' => $this->cases[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_COMMENT = array('posx' => 10, 'posy' => 180, 'data' => $this->comment[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_SPEC = array('posx' => 10, 'posy' => 210, 'data' => $this->spec[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_ATT = array('posx' => 10, 'posy' => 220, 'data' => $this->att[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_OUR_ORDER = array('posx' => 10, 'posy' => 280, 'data' => $this->items_our_order[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_P_O_NUMBER = array('posx' => 25, 'posy' => 280, 'data' => $this->items_p_o_number[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_DYE_LOT = array('posx' => 40, 'posy' => 280, 'data' => $this->items_dye_lot[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_STYLE = array('posx' => 60, 'posy' => 280, 'data' => $this->items_style[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_COLOR = array('posx' => 75, 'posy' => 280, 'data' => $this->items_color[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_COLOR_NO = array('posx' => 90, 'posy' => 280, 'data' => $this->items_color_no[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_WIDTH = array('posx' => 105, 'posy' => 280, 'data' => $this->items_width[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_PRICE = array('posx' => 120, 'posy' => 280, 'data' => $this->items_price[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_UNIT = array('posx' => 135, 'posy' => 280, 'data' => $this->items_unit[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_LYARDS = array('posx' => 150, 'posy' => 280, 'data' => $this->items_lyards[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_SYARDS = array('posx' => 165, 'posy' => 280, 'data' => $this->items_syards[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);
            $cell_Items_CUSTNO = array('posx' => 180, 'posy' => 280, 'data' => $this->items_custno[$this->nm_grid_colunas], 'width'      => 0, 'align'      => 'L', 'font_type'  => $this->default_font, 'font_size'  => 12, 'color_r'    => '0', 'color_g'    => '0', 'color_b'    => '0', 'font_style' => $this->default_style);


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

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

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

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

            $this->Pdf->SetFont($cell_VIA1['font_type'], $cell_VIA1['font_style'], $cell_VIA1['font_size']);
            $this->Pdf->SetTextColor($cell_VIA1['color_r'], $cell_VIA1['color_g'], $cell_VIA1['color_b']);
            if (!empty($cell_VIA1['posx']) && !empty($cell_VIA1['posy']))
            {
                $this->Pdf->SetXY($cell_VIA1['posx'], $cell_VIA1['posy']);
            }
            elseif (!empty($cell_VIA1['posx']))
            {
                $this->Pdf->SetX($cell_VIA1['posx']);
            }
            elseif (!empty($cell_VIA1['posy']))
            {
                $this->Pdf->SetY($cell_VIA1['posy']);
            }
            $this->Pdf->Cell($cell_VIA1['width'], 0, $cell_VIA1['data'], 0, 0, $cell_VIA1['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(4.2333333333333);
                }
                $this->Pdf->SetX($PosX);
                $this->Pdf->Cell($cell_HOWWHO['width'], 0, trim($Lines), 0, 0, $cell_HOWWHO['align']);
                $Incre = true;
            }

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

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

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

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

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

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

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

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

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

            $this->Pdf->SetY(280);
            foreach ($this->items[$this->nm_grid_colunas] as $NM_ind => $Dados)
            {
                $this->Pdf->SetFont($cell_Items_OUR_ORDER['font_type'], $cell_Items_OUR_ORDER['font_style'], $cell_Items_OUR_ORDER['font_size']);
                $this->Pdf->SetTextColor($cell_Items_OUR_ORDER['color_r'], $cell_Items_OUR_ORDER['color_g'], $cell_Items_OUR_ORDER['color_b']);
                if (!empty($cell_Items_OUR_ORDER['posx']))
                {
                    $this->Pdf->SetX($cell_Items_OUR_ORDER['posx']);
                }
                $this->Pdf->Cell($cell_Items_OUR_ORDER['width'], 0, $this->items_our_order[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_OUR_ORDER['align']);
                $this->Pdf->SetFont($cell_Items_P_O_NUMBER['font_type'], $cell_Items_P_O_NUMBER['font_style'], $cell_Items_P_O_NUMBER['font_size']);
                $this->Pdf->SetTextColor($cell_Items_P_O_NUMBER['color_r'], $cell_Items_P_O_NUMBER['color_g'], $cell_Items_P_O_NUMBER['color_b']);
                if (!empty($cell_Items_P_O_NUMBER['posx']))
                {
                    $this->Pdf->SetX($cell_Items_P_O_NUMBER['posx']);
                }
                $this->Pdf->Cell($cell_Items_P_O_NUMBER['width'], 0, $this->items_p_o_number[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_P_O_NUMBER['align']);
                $this->Pdf->SetFont($cell_Items_DYE_LOT['font_type'], $cell_Items_DYE_LOT['font_style'], $cell_Items_DYE_LOT['font_size']);
                $this->Pdf->SetTextColor($cell_Items_DYE_LOT['color_r'], $cell_Items_DYE_LOT['color_g'], $cell_Items_DYE_LOT['color_b']);
                if (!empty($cell_Items_DYE_LOT['posx']))
                {
                    $this->Pdf->SetX($cell_Items_DYE_LOT['posx']);
                }
                $this->Pdf->Cell($cell_Items_DYE_LOT['width'], 0, $this->items_dye_lot[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_DYE_LOT['align']);
                $this->Pdf->SetFont($cell_Items_STYLE['font_type'], $cell_Items_STYLE['font_style'], $cell_Items_STYLE['font_size']);
                $this->Pdf->SetTextColor($cell_Items_STYLE['color_r'], $cell_Items_STYLE['color_g'], $cell_Items_STYLE['color_b']);
                if (!empty($cell_Items_STYLE['posx']))
                {
                    $this->Pdf->SetX($cell_Items_STYLE['posx']);
                }
                $this->Pdf->Cell($cell_Items_STYLE['width'], 0, $this->items_style[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_STYLE['align']);
                $this->Pdf->SetFont($cell_Items_COLOR['font_type'], $cell_Items_COLOR['font_style'], $cell_Items_COLOR['font_size']);
                $this->Pdf->SetTextColor($cell_Items_COLOR['color_r'], $cell_Items_COLOR['color_g'], $cell_Items_COLOR['color_b']);
                if (!empty($cell_Items_COLOR['posx']))
                {
                    $this->Pdf->SetX($cell_Items_COLOR['posx']);
                }
                $this->Pdf->Cell($cell_Items_COLOR['width'], 0, $this->items_color[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_COLOR['align']);
                $this->Pdf->SetFont($cell_Items_COLOR_NO['font_type'], $cell_Items_COLOR_NO['font_style'], $cell_Items_COLOR_NO['font_size']);
                $this->Pdf->SetTextColor($cell_Items_COLOR_NO['color_r'], $cell_Items_COLOR_NO['color_g'], $cell_Items_COLOR_NO['color_b']);
                if (!empty($cell_Items_COLOR_NO['posx']))
                {
                    $this->Pdf->SetX($cell_Items_COLOR_NO['posx']);
                }
                $this->Pdf->Cell($cell_Items_COLOR_NO['width'], 0, $this->items_color_no[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_COLOR_NO['align']);
                $this->Pdf->SetFont($cell_Items_WIDTH['font_type'], $cell_Items_WIDTH['font_style'], $cell_Items_WIDTH['font_size']);
                $this->Pdf->SetTextColor($cell_Items_WIDTH['color_r'], $cell_Items_WIDTH['color_g'], $cell_Items_WIDTH['color_b']);
                if (!empty($cell_Items_WIDTH['posx']))
                {
                    $this->Pdf->SetX($cell_Items_WIDTH['posx']);
                }
                $this->Pdf->Cell($cell_Items_WIDTH['width'], 0, $this->items_width[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_WIDTH['align']);
                $this->Pdf->SetFont($cell_Items_PRICE['font_type'], $cell_Items_PRICE['font_style'], $cell_Items_PRICE['font_size']);
                $this->Pdf->SetTextColor($cell_Items_PRICE['color_r'], $cell_Items_PRICE['color_g'], $cell_Items_PRICE['color_b']);
                if (!empty($cell_Items_PRICE['posx']))
                {
                    $this->Pdf->SetX($cell_Items_PRICE['posx']);
                }
                $this->Pdf->Cell($cell_Items_PRICE['width'], 0, $this->items_price[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_PRICE['align']);
                $this->Pdf->SetFont($cell_Items_UNIT['font_type'], $cell_Items_UNIT['font_style'], $cell_Items_UNIT['font_size']);
                $this->Pdf->SetTextColor($cell_Items_UNIT['color_r'], $cell_Items_UNIT['color_g'], $cell_Items_UNIT['color_b']);
                if (!empty($cell_Items_UNIT['posx']))
                {
                    $this->Pdf->SetX($cell_Items_UNIT['posx']);
                }
                $this->Pdf->Cell($cell_Items_UNIT['width'], 0, $this->items_unit[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_UNIT['align']);
                $this->Pdf->SetFont($cell_Items_LYARDS['font_type'], $cell_Items_LYARDS['font_style'], $cell_Items_LYARDS['font_size']);
                $this->Pdf->SetTextColor($cell_Items_LYARDS['color_r'], $cell_Items_LYARDS['color_g'], $cell_Items_LYARDS['color_b']);
                if (!empty($cell_Items_LYARDS['posx']))
                {
                    $this->Pdf->SetX($cell_Items_LYARDS['posx']);
                }
                $this->Pdf->Cell($cell_Items_LYARDS['width'], 0, $this->items_lyards[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_LYARDS['align']);
                $this->Pdf->SetFont($cell_Items_SYARDS['font_type'], $cell_Items_SYARDS['font_style'], $cell_Items_SYARDS['font_size']);
                $this->Pdf->SetTextColor($cell_Items_SYARDS['color_r'], $cell_Items_SYARDS['color_g'], $cell_Items_SYARDS['color_b']);
                if (!empty($cell_Items_SYARDS['posx']))
                {
                    $this->Pdf->SetX($cell_Items_SYARDS['posx']);
                }
                $this->Pdf->Cell($cell_Items_SYARDS['width'], 0, $this->items_syards[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_SYARDS['align']);
                $this->Pdf->SetFont($cell_Items_CUSTNO['font_type'], $cell_Items_CUSTNO['font_style'], $cell_Items_CUSTNO['font_size']);
                $this->Pdf->SetTextColor($cell_Items_CUSTNO['color_r'], $cell_Items_CUSTNO['color_g'], $cell_Items_CUSTNO['color_b']);
                if (!empty($cell_Items_CUSTNO['posx']))
                {
                    $this->Pdf->SetX($cell_Items_CUSTNO['posx']);
                }
                $this->Pdf->Cell($cell_Items_CUSTNO['width'], 0, $this->items_custno[$this->nm_grid_colunas][$NM_ind], 0, 0, $cell_Items_CUSTNO['align']);
                if (!isset($max_Y) || empty($max_Y))
                {
                    $max_Y = $this->Pdf->GetY();
                }
                $max_Y += 20;
                $this->Pdf->SetY($max_Y);

            }
          $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;
   } 
}
?>
