<?php

class pdfreport_wastetransactions_xls
{
   var $Db;
   var $Erro;
   var $Ini;
   var $Lookup;
   var $nm_data;
   var $xls_dados;
   var $xls_workbook;
   var $xls_col;
   var $xls_row;
   var $sc_proc_grid; 
   var $NM_cmp_hidden = array();
   var $arquivo;
   var $tit_doc;
   //---- 
   function pdfreport_wastetransactions_xls()
   {
   }

   //---- 
   function monta_xls()
   {
      $this->inicializa_vars();
      $this->grava_arquivo();
      $this->monta_html();
   }

   //----- 
   function inicializa_vars()
   {
      global $nm_lang;
      $this->xls_row = 1;
      $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; 
      set_include_path(get_include_path() . PATH_SEPARATOR . $this->Ini->path_third . '/phpexcel/');
      require_once $this->Ini->path_third . '/phpexcel/PHPExcel.php';
      require_once $this->Ini->path_third . '/phpexcel/PHPExcel/IOFactory.php';
      $this->xls_col    = 0;
      $this->nm_data    = new nm_data("el");
      $this->arquivo    = "sc_xls";
      $this->arquivo   .= "_" . date("YmdHis") . "_" . rand(0, 1000);
      $this->arquivo   .= "_pdfreport_wastetransactions";
      $this->arquivo   .= ".xls";
      $this->tit_doc    = "pdfreport_wastetransactions.xls";
      $this->xls_f = $this->Ini->root . $this->Ini->path_imag_temp . "/" . $this->arquivo;
      $this->xls_dados = new PHPExcel();
      $this->xls_dados->setActiveSheetIndex(0);
      $this->Nm_ActiveSheet = $this->xls_dados->getActiveSheet();
      if ($_SESSION['scriptcase']['reg_conf']['css_dir'] == "RTL")
      {
          $this->Nm_ActiveSheet->setRightToLeft(true);
      }
   }

   //----- 
   function grava_arquivo()
   {
      global $nm_lang;
      global
             $nm_nada, $nm_lang;

      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->sc_proc_grid = false; 
      $nm_raiz_img  = ""; 
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['campos_busca']) && !empty($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['campos_busca']))
      { 
          $Busca_temp = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['campos_busca'];
          if ($_SESSION['scriptcase']['charset'] != "UTF-8")
          {
              $Busca_temp = NM_conv_charset($Busca_temp, $_SESSION['scriptcase']['charset'], "UTF-8");
          }
          $this->wtfdestrd = $Busca_temp['wtfdestrd']; 
          $tmp_pos = strpos($this->wtfdestrd, "##@@");
          if ($tmp_pos !== false)
          {
              $this->wtfdestrd = substr($this->wtfdestrd, 0, $tmp_pos);
          }
          $this->wtid = $Busca_temp['wtid']; 
          $tmp_pos = strpos($this->wtid, "##@@");
          if ($tmp_pos !== false)
          {
              $this->wtid = substr($this->wtid, 0, $tmp_pos);
          }
          $this->wtid_2 = $Busca_temp['wtid_input_2']; 
          $this->wtprofilid = $Busca_temp['wtprofilid']; 
          $tmp_pos = strpos($this->wtprofilid, "##@@");
          if ($tmp_pos !== false)
          {
              $this->wtprofilid = substr($this->wtprofilid, 0, $tmp_pos);
          }
          $this->wtprofilid_2 = $Busca_temp['wtprofilid_input_2']; 
          $this->intnumber = $Busca_temp['intnumber']; 
          $tmp_pos = strpos($this->intnumber, "##@@");
          if ($tmp_pos !== false)
          {
              $this->intnumber = substr($this->intnumber, 0, $tmp_pos);
          }
          $this->intnumber_2 = $Busca_temp['intnumber_input_2']; 
          $this->wtrequestdate = $Busca_temp['wtrequestdate']; 
          $tmp_pos = strpos($this->wtrequestdate, "##@@");
          if ($tmp_pos !== false)
          {
              $this->wtrequestdate = substr($this->wtrequestdate, 0, $tmp_pos);
          }
          $this->wtrequestdate_2 = $Busca_temp['wtrequestdate_input_2']; 
      } 
      $this->nm_field_dinamico = array();
      $this->nm_order_dinamico = array();
      $this->sc_where_orig   = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['where_orig'];
      $this->sc_where_atual  = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['where_pesq'];
      $this->sc_where_filtro = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['where_pesq_filtro'];
      if (isset($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['xls_name']))
      {
          $this->arquivo = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['xls_name'];
          $this->tit_doc = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['xls_name'];
          unset($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['xls_name']);
          $this->xls_f = $this->Ini->root . $this->Ini->path_imag_temp . "/" . $this->arquivo;
      }
      if (in_array(strtolower($this->Ini->nm_tpbanco), $this->Ini->nm_bases_mysql))
      { 
          $nmgp_select = "SELECT wtid, wtProfilID, INTNUMBER, wtRequestDate, wtProducerBranchID, wtProducerPeriferia, wtProducerEwc, wtProducerEwc as ewc1, wtProducerAcceptWeigth, wtProducerQty, wtPrducerm3, wtProducerRemarks, wtProducerValidate, wtTransportDate, wtTransporterID, wtTransporterPeriferiaID, wtTransporterEWC, wtTransporterVechicle, wtTransporterValidate, wtTransporterValidateIP, wtTransporterNumberID, wtFdestDate, wtFDestID, wtFDestPeriferia, wtFDestEWC, wtFDestEWC as ewc2, wtFDestRD, wtFDestQty, wtFDestM3, wtFDestVlidated, wtFDestValidateIP, wtProducerSign, wtTransporterSign, wtFDestSign from " . $this->Ini->nm_tabela; 
      } 
      else 
      { 
          $nmgp_select = "SELECT wtid, wtProfilID, INTNUMBER, wtRequestDate, wtProducerBranchID, wtProducerPeriferia, wtProducerEwc, wtProducerEwc as ewc1, wtProducerAcceptWeigth, wtProducerQty, wtPrducerm3, wtProducerRemarks, wtProducerValidate, wtTransportDate, wtTransporterID, wtTransporterPeriferiaID, wtTransporterEWC, wtTransporterVechicle, wtTransporterValidate, wtTransporterValidateIP, wtTransporterNumberID, wtFdestDate, wtFDestID, wtFDestPeriferia, wtFDestEWC, wtFDestEWC as ewc2, wtFDestRD, wtFDestQty, wtFDestM3, wtFDestVlidated, wtFDestValidateIP, wtProducerSign, wtTransporterSign, wtFDestSign from " . $this->Ini->nm_tabela; 
      } 
      $nmgp_select .= " " . $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['where_pesq'];
      $nmgp_order_by = $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['order_grid'];
      $nmgp_select .= $nmgp_order_by; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nmgp_select;
      $rs = $this->Db->Execute($nmgp_select);
      if ($rs === false && !$rs->EOF && $GLOBALS["NM_ERRO_IBASE"] != 1)
      {
         $this->Erro->mensagem(__FILE__, __LINE__, "banco", $this->Ini->Nm_lang['lang_errm_dber'], $this->Db->ErrorMsg());
         exit;
      }

      foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['field_order'] as $Cada_col)
      { 
          $SC_Label = (isset($this->New_label['wtid'])) ? $this->New_label['wtid'] : "Wtid"; 
          if ($Cada_col == "wtid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtprofilid'])) ? $this->New_label['wtprofilid'] : "Wt Profil ID"; 
          if ($Cada_col == "wtprofilid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['intnumber'])) ? $this->New_label['intnumber'] : "INTNUMBER"; 
          if ($Cada_col == "intnumber" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtrequestdate'])) ? $this->New_label['wtrequestdate'] : "Wt Request Date"; 
          if ($Cada_col == "wtrequestdate" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducerbranchid'])) ? $this->New_label['wtproducerbranchid'] : "Wt Producer Branch ID"; 
          if ($Cada_col == "wtproducerbranchid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducerperiferia'])) ? $this->New_label['wtproducerperiferia'] : "Wt Producer Periferia"; 
          if ($Cada_col == "wtproducerperiferia" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducerewc'])) ? $this->New_label['wtproducerewc'] : "Wt Producer Ewc"; 
          if ($Cada_col == "wtproducerewc" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['ewc1'])) ? $this->New_label['ewc1'] : "Ewc 1"; 
          if ($Cada_col == "ewc1" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproduceracceptweigth'])) ? $this->New_label['wtproduceracceptweigth'] : "Wt Producer Accept Weigth"; 
          if ($Cada_col == "wtproduceracceptweigth" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducerqty'])) ? $this->New_label['wtproducerqty'] : "Wt Producer Qty"; 
          if ($Cada_col == "wtproducerqty" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtprducerm3'])) ? $this->New_label['wtprducerm3'] : "Wt Prducerm 3"; 
          if ($Cada_col == "wtprducerm3" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducerremarks'])) ? $this->New_label['wtproducerremarks'] : "Wt Producer Remarks"; 
          if ($Cada_col == "wtproducerremarks" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducervalidate'])) ? $this->New_label['wtproducervalidate'] : "Wt Producer Validate"; 
          if ($Cada_col == "wtproducervalidate" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransportdate'])) ? $this->New_label['wttransportdate'] : "Wt Transport Date"; 
          if ($Cada_col == "wttransportdate" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransporterid'])) ? $this->New_label['wttransporterid'] : "Wt Transporter ID"; 
          if ($Cada_col == "wttransporterid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransporterperiferiaid'])) ? $this->New_label['wttransporterperiferiaid'] : "Wt Transporter Periferia ID"; 
          if ($Cada_col == "wttransporterperiferiaid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransporterewc'])) ? $this->New_label['wttransporterewc'] : "Wt Transporter EWC"; 
          if ($Cada_col == "wttransporterewc" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransportervechicle'])) ? $this->New_label['wttransportervechicle'] : "Wt Transporter Vechicle"; 
          if ($Cada_col == "wttransportervechicle" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransportervalidate'])) ? $this->New_label['wttransportervalidate'] : "Wt Transporter Validate"; 
          if ($Cada_col == "wttransportervalidate" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransportervalidateip'])) ? $this->New_label['wttransportervalidateip'] : "Wt Transporter Validate IP"; 
          if ($Cada_col == "wttransportervalidateip" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransporternumberid'])) ? $this->New_label['wttransporternumberid'] : "Wt Transporter Number ID"; 
          if ($Cada_col == "wttransporternumberid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestdate'])) ? $this->New_label['wtfdestdate'] : "Wt Fdest Date"; 
          if ($Cada_col == "wtfdestdate" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestid'])) ? $this->New_label['wtfdestid'] : "Wt F Dest ID"; 
          if ($Cada_col == "wtfdestid" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestperiferia'])) ? $this->New_label['wtfdestperiferia'] : "Wt F Dest Periferia"; 
          if ($Cada_col == "wtfdestperiferia" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestewc'])) ? $this->New_label['wtfdestewc'] : "Wt F Dest EWC"; 
          if ($Cada_col == "wtfdestewc" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['ewc2'])) ? $this->New_label['ewc2'] : "Ewc 2"; 
          if ($Cada_col == "ewc2" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestrd'])) ? $this->New_label['wtfdestrd'] : "Wt F Dest RD"; 
          if ($Cada_col == "wtfdestrd" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestqty'])) ? $this->New_label['wtfdestqty'] : "Wt F Dest Qty"; 
          if ($Cada_col == "wtfdestqty" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestm3'])) ? $this->New_label['wtfdestm3'] : "Wt F Dest M3"; 
          if ($Cada_col == "wtfdestm3" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestvlidated'])) ? $this->New_label['wtfdestvlidated'] : "Wt F Dest Vlidated"; 
          if ($Cada_col == "wtfdestvlidated" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestvalidateip'])) ? $this->New_label['wtfdestvalidateip'] : "Wt F Dest Validate IP"; 
          if ($Cada_col == "wtfdestvalidateip" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtproducersign'])) ? $this->New_label['wtproducersign'] : ""; 
          if ($Cada_col == "wtproducersign" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransportersign'])) ? $this->New_label['wttransportersign'] : "Wt Transporter Sign"; 
          if ($Cada_col == "wttransportersign" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wtfdestsign'])) ? $this->New_label['wtfdestsign'] : "Wt F Dest Sign"; 
          if ($Cada_col == "wtfdestsign" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['email'])) ? $this->New_label['email'] : "Email"; 
          if ($Cada_col == "email" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['envregistrationno'])) ? $this->New_label['envregistrationno'] : "EnvRegistrationNo"; 
          if ($Cada_col == "envregistrationno" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['fdestaddress'])) ? $this->New_label['fdestaddress'] : "FDestAddress"; 
          if ($Cada_col == "fdestaddress" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['fdestaepo'])) ? $this->New_label['fdestaepo'] : "FDestAepo"; 
          if ($Cada_col == "fdestaepo" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['fdestphone'])) ? $this->New_label['fdestphone'] : "FDestPhone"; 
          if ($Cada_col == "fdestphone" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['fdestrespone'])) ? $this->New_label['fdestrespone'] : "FDestRespone"; 
          if ($Cada_col == "fdestrespone" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['fdestresponseemail'])) ? $this->New_label['fdestresponseemail'] : "FDestResponseEmail"; 
          if ($Cada_col == "fdestresponseemail" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['phone'])) ? $this->New_label['phone'] : "Phone"; 
          if ($Cada_col == "phone" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['produceraepo'])) ? $this->New_label['produceraepo'] : "ProducerAEPO"; 
          if ($Cada_col == "produceraepo" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['producerb_address'])) ? $this->New_label['producerb_address'] : "ProducerB_Address"; 
          if ($Cada_col == "producerb_address" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['responsename'])) ? $this->New_label['responsename'] : "ResponseName"; 
          if ($Cada_col == "responsename" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
          $SC_Label = (isset($this->New_label['wttransporterresponse'])) ? $this->New_label['wttransporterresponse'] : "wtTransporterResponse"; 
          if ($Cada_col == "wttransporterresponse" && (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off"))
          {
             if (!NM_is_utf8($SC_Label))
              {
                  $SC_Label = sc_convert_encoding($SC_Label, "UTF-8", $_SESSION['scriptcase']['charset']);
              }
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
              $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $SC_Label);
              $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getFont()->setBold(true);
              $this->Nm_ActiveSheet->getColumnDimension($this->calc_cell($this->xls_col))->setAutoSize(true);
              $this->xls_col++;
          }
      } 
      while (!$rs->EOF)
      {
         $this->xls_col = 0;
         $this->xls_row++;
         $this->wtid = $rs->fields[0] ;  
         $this->wtid = (string)$this->wtid;
         $this->wtprofilid = $rs->fields[1] ;  
         $this->wtprofilid = (string)$this->wtprofilid;
         $this->intnumber = $rs->fields[2] ;  
         $this->intnumber = (string)$this->intnumber;
         $this->wtrequestdate = $rs->fields[3] ;  
         $this->wtproducerbranchid = $rs->fields[4] ;  
         $this->wtproducerbranchid = (string)$this->wtproducerbranchid;
         $this->wtproducerperiferia = $rs->fields[5] ;  
         $this->wtproducerperiferia = (string)$this->wtproducerperiferia;
         $this->wtproducerewc = $rs->fields[6] ;  
         $this->ewc1 = $rs->fields[7] ;  
         $this->wtproduceracceptweigth = $rs->fields[8] ;  
         $this->wtproduceracceptweigth = (string)$this->wtproduceracceptweigth;
         $this->wtproducerqty = $rs->fields[9] ;  
         $this->wtproducerqty = (string)$this->wtproducerqty;
         $this->wtprducerm3 = $rs->fields[10] ;  
         $this->wtprducerm3 = (string)$this->wtprducerm3;
         $this->wtproducerremarks = $rs->fields[11] ;  
         $this->wtproducervalidate = $rs->fields[12] ;  
         $this->wttransportdate = $rs->fields[13] ;  
         $this->wttransporterid = $rs->fields[14] ;  
         $this->wttransporterid = (string)$this->wttransporterid;
         $this->wttransporterperiferiaid = $rs->fields[15] ;  
         $this->wttransporterperiferiaid = (string)$this->wttransporterperiferiaid;
         $this->wttransporterewc = $rs->fields[16] ;  
         $this->wttransportervechicle = $rs->fields[17] ;  
         $this->wttransportervalidate = $rs->fields[18] ;  
         $this->wttransportervalidate = (string)$this->wttransportervalidate;
         $this->wttransportervalidateip = $rs->fields[19] ;  
         $this->wttransporternumberid = $rs->fields[20] ;  
         $this->wtfdestdate = $rs->fields[21] ;  
         $this->wtfdestid = $rs->fields[22] ;  
         $this->wtfdestid = (string)$this->wtfdestid;
         $this->wtfdestperiferia = $rs->fields[23] ;  
         $this->wtfdestperiferia = (string)$this->wtfdestperiferia;
         $this->wtfdestewc = $rs->fields[24] ;  
         $this->ewc2 = $rs->fields[25] ;  
         $this->wtfdestrd = $rs->fields[26] ;  
         $this->wtfdestqty = $rs->fields[27] ;  
         $this->wtfdestqty = (string)$this->wtfdestqty;
         $this->wtfdestm3 = $rs->fields[28] ;  
         $this->wtfdestm3 = (string)$this->wtfdestm3;
         $this->wtfdestvlidated = $rs->fields[29] ;  
         $this->wtfdestvlidated = (string)$this->wtfdestvlidated;
         $this->wtfdestvalidateip = $rs->fields[30] ;  
         $this->wtproducersign = $rs->fields[31] ;  
         $this->wttransportersign = $rs->fields[32] ;  
         $this->wtfdestsign = $rs->fields[33] ;  
         //----- lookup - wtprofilid
         $this->look_wtprofilid = $this->wtprofilid; 
         $this->Lookup->lookup_wtprofilid($this->look_wtprofilid, $this->wtprofilid) ; 
         $this->look_wtprofilid = ($this->look_wtprofilid == "&nbsp;") ? "" : $this->look_wtprofilid; 
         //----- lookup - wtproducerbranchid
         $this->look_wtproducerbranchid = $this->wtproducerbranchid; 
         $this->Lookup->lookup_wtproducerbranchid($this->look_wtproducerbranchid, $this->wtproducerbranchid) ; 
         $this->look_wtproducerbranchid = ($this->look_wtproducerbranchid == "&nbsp;") ? "" : $this->look_wtproducerbranchid; 
         //----- lookup - wtproducerewc
         $this->look_wtproducerewc = $this->wtproducerewc; 
         $this->Lookup->lookup_wtproducerewc($this->look_wtproducerewc, $this->wtproducerewc) ; 
         $this->look_wtproducerewc = ($this->look_wtproducerewc == "&nbsp;") ? "" : $this->look_wtproducerewc; 
         //----- lookup - wtproduceracceptweigth
         $this->look_wtproduceracceptweigth = $this->wtproduceracceptweigth; 
         $this->Lookup->lookup_wtproduceracceptweigth($this->look_wtproduceracceptweigth); 
         $this->look_wtproduceracceptweigth = ($this->look_wtproduceracceptweigth == "&nbsp;") ? "" : $this->look_wtproduceracceptweigth; 
         //----- lookup - wtfdestid
         $this->look_wtfdestid = $this->wtfdestid; 
         $this->Lookup->lookup_wtfdestid($this->look_wtfdestid, $this->wtfdestid) ; 
         $this->look_wtfdestid = ($this->look_wtfdestid == "&nbsp;") ? "" : $this->look_wtfdestid; 
         //----- lookup - ewc2
         $this->look_ewc2 = $this->ewc2; 
         $this->Lookup->lookup_ewc2($this->look_ewc2, $this->ewc2) ; 
         $this->look_ewc2 = ($this->look_ewc2 == "&nbsp;") ? "" : $this->look_ewc2; 
         $this->sc_proc_grid = true; 
         $_SESSION['scriptcase']['pdfreport_wastetransactions']['contr_erro'] = 'on';
  $this->loadDetails();
$_SESSION['scriptcase']['pdfreport_wastetransactions']['contr_erro'] = 'off'; 
         foreach ($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['field_order'] as $Cada_col)
         { 
            if (!isset($this->NM_cmp_hidden[$Cada_col]) || $this->NM_cmp_hidden[$Cada_col] != "off")
            { 
                $NM_func_exp = "NM_export_" . $Cada_col;
                $this->$NM_func_exp();
            } 
         } 
         if (isset($this->NM_Row_din[$this->xls_row]))
         { 
             $this->Nm_ActiveSheet->getRowDimension($this->xls_row)->setRowHeight($this->NM_Row_din[$this->xls_row]);
         } 
         $rs->MoveNext();
      }
      if (isset($this->NM_Col_din))
      { 
          foreach ($this->NM_Col_din as $col => $width)
          { 
              $this->Nm_ActiveSheet->getColumnDimension($col)->setWidth($width / 5);
          } 
      } 
      $rs->Close();
      $objWriter = new PHPExcel_Writer_Excel5($this->xls_dados);
      $objWriter->save($this->xls_f);
   }
   //----- wtid
   function NM_export_wtid()
   {
         if (!NM_is_utf8($this->wtid))
         {
             $this->wtid = sc_convert_encoding($this->wtid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtid))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtid);
         $this->xls_col++;
   }
   //----- wtprofilid
   function NM_export_wtprofilid()
   {
         if (!NM_is_utf8($this->look_wtprofilid))
         {
             $this->look_wtprofilid = sc_convert_encoding($this->look_wtprofilid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->look_wtprofilid))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->look_wtprofilid);
         $this->xls_col++;
   }
   //----- intnumber
   function NM_export_intnumber()
   {
         if (!NM_is_utf8($this->intnumber))
         {
             $this->intnumber = sc_convert_encoding($this->intnumber, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->intnumber))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->intnumber);
         $this->xls_col++;
   }
   //----- wtrequestdate
   function NM_export_wtrequestdate()
   {
         $conteudo_x =  $this->wtrequestdate;
         nm_conv_limpa_dado($conteudo_x, "YYYY-MM-DD");
         if (is_numeric($conteudo_x) && $conteudo_x > 0) 
         { 
             $this->nm_data->SetaData($this->wtrequestdate, "YYYY-MM-DD");
             $this->wtrequestdate = $this->nm_data->FormataSaida($this->nm_data->FormatRegion("DT", "ddmmaaaa"));
         } 
         if (!NM_is_utf8($this->wtrequestdate))
         {
             $this->wtrequestdate = sc_convert_encoding($this->wtrequestdate, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtrequestdate);
         $this->xls_col++;
   }
   //----- wtproducerbranchid
   function NM_export_wtproducerbranchid()
   {
         if (!NM_is_utf8($this->look_wtproducerbranchid))
         {
             $this->look_wtproducerbranchid = sc_convert_encoding($this->look_wtproducerbranchid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->look_wtproducerbranchid))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->look_wtproducerbranchid);
         $this->xls_col++;
   }
   //----- wtproducerperiferia
   function NM_export_wtproducerperiferia()
   {
         if (!NM_is_utf8($this->wtproducerperiferia))
         {
             $this->wtproducerperiferia = sc_convert_encoding($this->wtproducerperiferia, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtproducerperiferia))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtproducerperiferia);
         $this->xls_col++;
   }
   //----- wtproducerewc
   function NM_export_wtproducerewc()
   {
         $this->look_wtproducerewc = html_entity_decode($this->look_wtproducerewc, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         if (!NM_is_utf8($this->look_wtproducerewc))
         {
             $this->look_wtproducerewc = sc_convert_encoding($this->look_wtproducerewc, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->look_wtproducerewc);
         $this->xls_col++;
   }
   //----- ewc1
   function NM_export_ewc1()
   {
         $this->ewc1 = html_entity_decode($this->ewc1, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->ewc1 = strip_tags($this->ewc1);
         if (!NM_is_utf8($this->ewc1))
         {
             $this->ewc1 = sc_convert_encoding($this->ewc1, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->ewc1);
         $this->xls_col++;
   }
   //----- wtproduceracceptweigth
   function NM_export_wtproduceracceptweigth()
   {
         $this->look_wtproduceracceptweigth = html_entity_decode($this->look_wtproduceracceptweigth, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         if (!NM_is_utf8($this->look_wtproduceracceptweigth))
         {
             $this->look_wtproduceracceptweigth = sc_convert_encoding($this->look_wtproduceracceptweigth, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->look_wtproduceracceptweigth);
         $this->xls_col++;
   }
   //----- wtproducerqty
   function NM_export_wtproducerqty()
   {
         if (!NM_is_utf8($this->wtproducerqty))
         {
             $this->wtproducerqty = sc_convert_encoding($this->wtproducerqty, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtproducerqty))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0.000');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtproducerqty);
         $this->xls_col++;
   }
   //----- wtprducerm3
   function NM_export_wtprducerm3()
   {
         if (!NM_is_utf8($this->wtprducerm3))
         {
             $this->wtprducerm3 = sc_convert_encoding($this->wtprducerm3, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtprducerm3))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtprducerm3);
         $this->xls_col++;
   }
   //----- wtproducerremarks
   function NM_export_wtproducerremarks()
   {
         $this->wtproducerremarks = html_entity_decode($this->wtproducerremarks, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wtproducerremarks = strip_tags($this->wtproducerremarks);
         if (!NM_is_utf8($this->wtproducerremarks))
         {
             $this->wtproducerremarks = sc_convert_encoding($this->wtproducerremarks, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtproducerremarks);
         $this->xls_col++;
   }
   //----- wtproducervalidate
   function NM_export_wtproducervalidate()
   {
         $this->wtproducervalidate = html_entity_decode($this->wtproducervalidate, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wtproducervalidate = strip_tags($this->wtproducervalidate);
         if (!NM_is_utf8($this->wtproducervalidate))
         {
             $this->wtproducervalidate = sc_convert_encoding($this->wtproducervalidate, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtproducervalidate);
         $this->xls_col++;
   }
   //----- wttransportdate
   function NM_export_wttransportdate()
   {
         $conteudo_x =  $this->wttransportdate;
         nm_conv_limpa_dado($conteudo_x, "YYYY-MM-DD");
         if (is_numeric($conteudo_x) && $conteudo_x > 0) 
         { 
             $this->nm_data->SetaData($this->wttransportdate, "YYYY-MM-DD");
             $this->wttransportdate = $this->nm_data->FormataSaida($this->nm_data->FormatRegion("DT", "ddmmaaaa"));
         } 
         if (!NM_is_utf8($this->wttransportdate))
         {
             $this->wttransportdate = sc_convert_encoding($this->wttransportdate, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransportdate);
         $this->xls_col++;
   }
   //----- wttransporterid
   function NM_export_wttransporterid()
   {
         if (!NM_is_utf8($this->wttransporterid))
         {
             $this->wttransporterid = sc_convert_encoding($this->wttransporterid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wttransporterid))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransporterid);
         $this->xls_col++;
   }
   //----- wttransporterperiferiaid
   function NM_export_wttransporterperiferiaid()
   {
         if (!NM_is_utf8($this->wttransporterperiferiaid))
         {
             $this->wttransporterperiferiaid = sc_convert_encoding($this->wttransporterperiferiaid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wttransporterperiferiaid))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransporterperiferiaid);
         $this->xls_col++;
   }
   //----- wttransporterewc
   function NM_export_wttransporterewc()
   {
         $this->wttransporterewc = html_entity_decode($this->wttransporterewc, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wttransporterewc = strip_tags($this->wttransporterewc);
         if (!NM_is_utf8($this->wttransporterewc))
         {
             $this->wttransporterewc = sc_convert_encoding($this->wttransporterewc, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransporterewc);
         $this->xls_col++;
   }
   //----- wttransportervechicle
   function NM_export_wttransportervechicle()
   {
         $this->wttransportervechicle = html_entity_decode($this->wttransportervechicle, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wttransportervechicle = strip_tags($this->wttransportervechicle);
         if (!NM_is_utf8($this->wttransportervechicle))
         {
             $this->wttransportervechicle = sc_convert_encoding($this->wttransportervechicle, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransportervechicle);
         $this->xls_col++;
   }
   //----- wttransportervalidate
   function NM_export_wttransportervalidate()
   {
         $this->wttransportervalidate = html_entity_decode($this->wttransportervalidate, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wttransportervalidate = strip_tags($this->wttransportervalidate);
         if (!NM_is_utf8($this->wttransportervalidate))
         {
             $this->wttransportervalidate = sc_convert_encoding($this->wttransportervalidate, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransportervalidate);
         $this->xls_col++;
   }
   //----- wttransportervalidateip
   function NM_export_wttransportervalidateip()
   {
         $this->wttransportervalidateip = html_entity_decode($this->wttransportervalidateip, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wttransportervalidateip = strip_tags($this->wttransportervalidateip);
         if (!NM_is_utf8($this->wttransportervalidateip))
         {
             $this->wttransportervalidateip = sc_convert_encoding($this->wttransportervalidateip, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransportervalidateip);
         $this->xls_col++;
   }
   //----- wttransporternumberid
   function NM_export_wttransporternumberid()
   {
         $this->wttransporternumberid = html_entity_decode($this->wttransporternumberid, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wttransporternumberid = strip_tags($this->wttransporternumberid);
         if (!NM_is_utf8($this->wttransporternumberid))
         {
             $this->wttransporternumberid = sc_convert_encoding($this->wttransporternumberid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransporternumberid);
         $this->xls_col++;
   }
   //----- wtfdestdate
   function NM_export_wtfdestdate()
   {
         $conteudo_x =  $this->wtfdestdate;
         nm_conv_limpa_dado($conteudo_x, "YYYY-MM-DD");
         if (is_numeric($conteudo_x) && $conteudo_x > 0) 
         { 
             $this->nm_data->SetaData($this->wtfdestdate, "YYYY-MM-DD");
             $this->wtfdestdate = $this->nm_data->FormataSaida($this->nm_data->FormatRegion("DT", "ddmmaaaa"));
         } 
         if (!NM_is_utf8($this->wtfdestdate))
         {
             $this->wtfdestdate = sc_convert_encoding($this->wtfdestdate, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestdate);
         $this->xls_col++;
   }
   //----- wtfdestid
   function NM_export_wtfdestid()
   {
         if (!NM_is_utf8($this->look_wtfdestid))
         {
             $this->look_wtfdestid = sc_convert_encoding($this->look_wtfdestid, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->look_wtfdestid))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->look_wtfdestid);
         $this->xls_col++;
   }
   //----- wtfdestperiferia
   function NM_export_wtfdestperiferia()
   {
         if (!NM_is_utf8($this->wtfdestperiferia))
         {
             $this->wtfdestperiferia = sc_convert_encoding($this->wtfdestperiferia, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtfdestperiferia))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestperiferia);
         $this->xls_col++;
   }
   //----- wtfdestewc
   function NM_export_wtfdestewc()
   {
         $this->wtfdestewc = html_entity_decode($this->wtfdestewc, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wtfdestewc = strip_tags($this->wtfdestewc);
         if (!NM_is_utf8($this->wtfdestewc))
         {
             $this->wtfdestewc = sc_convert_encoding($this->wtfdestewc, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestewc);
         $this->xls_col++;
   }
   //----- ewc2
   function NM_export_ewc2()
   {
         $this->look_ewc2 = html_entity_decode($this->look_ewc2, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         if (!NM_is_utf8($this->look_ewc2))
         {
             $this->look_ewc2 = sc_convert_encoding($this->look_ewc2, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->look_ewc2);
         $this->xls_col++;
   }
   //----- wtfdestrd
   function NM_export_wtfdestrd()
   {
         $this->wtfdestrd = html_entity_decode($this->wtfdestrd, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wtfdestrd = strip_tags($this->wtfdestrd);
         if (!NM_is_utf8($this->wtfdestrd))
         {
             $this->wtfdestrd = sc_convert_encoding($this->wtfdestrd, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestrd);
         $this->xls_col++;
   }
   //----- wtfdestqty
   function NM_export_wtfdestqty()
   {
         if (!NM_is_utf8($this->wtfdestqty))
         {
             $this->wtfdestqty = sc_convert_encoding($this->wtfdestqty, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtfdestqty))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0.000');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestqty);
         $this->xls_col++;
   }
   //----- wtfdestm3
   function NM_export_wtfdestm3()
   {
         if (!NM_is_utf8($this->wtfdestm3))
         {
             $this->wtfdestm3 = sc_convert_encoding($this->wtfdestm3, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
         if (is_numeric($this->wtfdestm3))
         {
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getNumberFormat()->setFormatCode('#,##0');
         }
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestm3);
         $this->xls_col++;
   }
   //----- wtfdestvlidated
   function NM_export_wtfdestvlidated()
   {
         $this->wtfdestvlidated = html_entity_decode($this->wtfdestvlidated, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wtfdestvlidated = strip_tags($this->wtfdestvlidated);
         if (!NM_is_utf8($this->wtfdestvlidated))
         {
             $this->wtfdestvlidated = sc_convert_encoding($this->wtfdestvlidated, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestvlidated);
         $this->xls_col++;
   }
   //----- wtfdestvalidateip
   function NM_export_wtfdestvalidateip()
   {
         $this->wtfdestvalidateip = html_entity_decode($this->wtfdestvalidateip, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->wtfdestvalidateip = strip_tags($this->wtfdestvalidateip);
         if (!NM_is_utf8($this->wtfdestvalidateip))
         {
             $this->wtfdestvalidateip = sc_convert_encoding($this->wtfdestvalidateip, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wtfdestvalidateip);
         $this->xls_col++;
   }
   //----- wtproducersign
   function NM_export_wtproducersign()
   {
         if (empty($this->wtproducersign))
         { 
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, ' ');
             $this->xls_col++;
             return;
         } 
         $in_wtproducersign = $this->Ini->root . $this->Ini->path_imag_temp . "/sc_wtproducersign_" . $_SESSION['scriptcase']['sc_num_img'] . session_id() . ".jpg";
         $_SESSION['scriptcase']['sc_num_img']++;
         $arq_wtproducersign = fopen($in_wtproducersign, "w");
         if (substr($this->wtproducersign, 0, 4) == "*nm*")
         { 
             $this->wtproducersign = substr($this->wtproducersign, 4);
             $this->wtproducersign = base64_decode($this->wtproducersign);
         } 
         $img_pos_bm = strpos($this->wtproducersign, "BM");
         if (!$img_pos_bm === FALSE && $img_pos_bm == 78)
         { 
             $this->wtproducersign = substr($this->wtproducersign, $img_pos_bm);
         } 
         fwrite($arq_wtproducersign, $this->wtproducersign);
         fclose($arq_wtproducersign);
         $md5_wtproducersign  = md5($this->wtproducersign);
         if (is_file($in_wtproducersign) && !$this->Ini->Gd_missing)
         { 
             $out_wtproducersign = $this->Ini->path_imag_temp . "/sc_wtproducersign_" . $md5_wtproducersign . ".jpg";
             $tmp_wtproducersign = fopen($in_wtproducersign, "r");
             $reg_wtproducersign = fread($tmp_wtproducersign, filesize($in_wtproducersign));
             fclose($tmp_wtproducersign);
             $arq_wtproducersign = fopen($this->Ini->root . $out_wtproducersign, "w");
             fwrite($arq_wtproducersign, $reg_wtproducersign);
             fclose($arq_wtproducersign);
             $in_wtproducersign = $this->Ini->root . $out_wtproducersign;
             $sc_obj_img = new nm_trata_img($in_wtproducersign);
             $sc_obj_img->setWidth(85);
             $sc_obj_img->setHeight(28);
             $sc_obj_img->createImg($this->Ini->root . $out_wtproducersign);
         } 
         if (is_file($in_wtproducersign))
         { 
             $sc_obj_img = new nm_trata_img($in_wtproducersign);
             $nm_image_altura  = $sc_obj_img->getHeight();
             $nm_image_largura = $sc_obj_img->getWidth();
             $objDrawing = new PHPExcel_Worksheet_Drawing();
             $objDrawing->setPath($in_wtproducersign);
             $objDrawing->setHeight($nm_image_altura);
             $col = $this->calc_cell($this->xls_col);
             $objDrawing->setCoordinates($col . $this->xls_row);
             $objDrawing->setWorksheet($this->Nm_ActiveSheet);
             if (!isset($this->NM_Col_din[$col]) || $this->NM_Col_din[$col] < $nm_image_largura)
             { 
                 $this->NM_Col_din[$col] = $nm_image_largura;
             } 
             if (!isset($this->NM_Row_din[$this->xls_row]) || $this->NM_Row_din[$this->xls_row] < $nm_image_altura)
             { 
                 $this->NM_Row_din[$this->xls_row] = $nm_image_altura;
             } 
         } 
         else 
         { 
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, ' ');
         } 
         $this->xls_col++;
   }
   //----- wttransportersign
   function NM_export_wttransportersign()
   {
         if (empty($this->wttransportersign))
         { 
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, ' ');
             $this->xls_col++;
             return;
         } 
         $in_wttransportersign = $this->Ini->root . $this->Ini->path_imag_temp . "/sc_wttransportersign_" . $_SESSION['scriptcase']['sc_num_img'] . session_id() . ".jpg";
         $_SESSION['scriptcase']['sc_num_img']++;
         $arq_wttransportersign = fopen($in_wttransportersign, "w");
         if (substr($this->wttransportersign, 0, 4) == "*nm*")
         { 
             $this->wttransportersign = substr($this->wttransportersign, 4);
             $this->wttransportersign = base64_decode($this->wttransportersign);
         } 
         $img_pos_bm = strpos($this->wttransportersign, "BM");
         if (!$img_pos_bm === FALSE && $img_pos_bm == 78)
         { 
             $this->wttransportersign = substr($this->wttransportersign, $img_pos_bm);
         } 
         fwrite($arq_wttransportersign, $this->wttransportersign);
         fclose($arq_wttransportersign);
         $md5_wttransportersign  = md5($this->wttransportersign);
         if (is_file($in_wttransportersign) && !$this->Ini->Gd_missing)
         { 
             $out_wttransportersign = $this->Ini->path_imag_temp . "/sc_wttransportersign_" . $md5_wttransportersign . ".jpg";
             $tmp_wttransportersign = fopen($in_wttransportersign, "r");
             $reg_wttransportersign = fread($tmp_wttransportersign, filesize($in_wttransportersign));
             fclose($tmp_wttransportersign);
             $arq_wttransportersign = fopen($this->Ini->root . $out_wttransportersign, "w");
             fwrite($arq_wttransportersign, $reg_wttransportersign);
             fclose($arq_wttransportersign);
             $in_wttransportersign = $this->Ini->root . $out_wttransportersign;
             $sc_obj_img = new nm_trata_img($in_wttransportersign);
             $sc_obj_img->setWidth(75);
             $sc_obj_img->setHeight(25);
             $sc_obj_img->createImg($this->Ini->root . $out_wttransportersign);
         } 
         if (is_file($in_wttransportersign))
         { 
             $sc_obj_img = new nm_trata_img($in_wttransportersign);
             $nm_image_altura  = $sc_obj_img->getHeight();
             $nm_image_largura = $sc_obj_img->getWidth();
             $objDrawing = new PHPExcel_Worksheet_Drawing();
             $objDrawing->setPath($in_wttransportersign);
             $objDrawing->setHeight($nm_image_altura);
             $col = $this->calc_cell($this->xls_col);
             $objDrawing->setCoordinates($col . $this->xls_row);
             $objDrawing->setWorksheet($this->Nm_ActiveSheet);
             if (!isset($this->NM_Col_din[$col]) || $this->NM_Col_din[$col] < $nm_image_largura)
             { 
                 $this->NM_Col_din[$col] = $nm_image_largura;
             } 
             if (!isset($this->NM_Row_din[$this->xls_row]) || $this->NM_Row_din[$this->xls_row] < $nm_image_altura)
             { 
                 $this->NM_Row_din[$this->xls_row] = $nm_image_altura;
             } 
         } 
         else 
         { 
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, ' ');
         } 
         $this->xls_col++;
   }
   //----- wtfdestsign
   function NM_export_wtfdestsign()
   {
         if (empty($this->wtfdestsign))
         { 
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, ' ');
             $this->xls_col++;
             return;
         } 
         $in_wtfdestsign = $this->Ini->root . $this->Ini->path_imag_temp . "/sc_wtfdestsign_" . $_SESSION['scriptcase']['sc_num_img'] . session_id() . ".jpg";
         $_SESSION['scriptcase']['sc_num_img']++;
         $arq_wtfdestsign = fopen($in_wtfdestsign, "w");
         if (substr($this->wtfdestsign, 0, 4) == "*nm*")
         { 
             $this->wtfdestsign = substr($this->wtfdestsign, 4);
             $this->wtfdestsign = base64_decode($this->wtfdestsign);
         } 
         $img_pos_bm = strpos($this->wtfdestsign, "BM");
         if (!$img_pos_bm === FALSE && $img_pos_bm == 78)
         { 
             $this->wtfdestsign = substr($this->wtfdestsign, $img_pos_bm);
         } 
         fwrite($arq_wtfdestsign, $this->wtfdestsign);
         fclose($arq_wtfdestsign);
         $md5_wtfdestsign  = md5($this->wtfdestsign);
         if (is_file($in_wtfdestsign) && !$this->Ini->Gd_missing)
         { 
             $out_wtfdestsign = $this->Ini->path_imag_temp . "/sc_wtfdestsign_" . $md5_wtfdestsign . ".jpg";
             $tmp_wtfdestsign = fopen($in_wtfdestsign, "r");
             $reg_wtfdestsign = fread($tmp_wtfdestsign, filesize($in_wtfdestsign));
             fclose($tmp_wtfdestsign);
             $arq_wtfdestsign = fopen($this->Ini->root . $out_wtfdestsign, "w");
             fwrite($arq_wtfdestsign, $reg_wtfdestsign);
             fclose($arq_wtfdestsign);
             $in_wtfdestsign = $this->Ini->root . $out_wtfdestsign;
             $sc_obj_img = new nm_trata_img($in_wtfdestsign);
             $sc_obj_img->setWidth(75);
             $sc_obj_img->setHeight(25);
             $sc_obj_img->createImg($this->Ini->root . $out_wtfdestsign);
         } 
         if (is_file($in_wtfdestsign))
         { 
             $sc_obj_img = new nm_trata_img($in_wtfdestsign);
             $nm_image_altura  = $sc_obj_img->getHeight();
             $nm_image_largura = $sc_obj_img->getWidth();
             $objDrawing = new PHPExcel_Worksheet_Drawing();
             $objDrawing->setPath($in_wtfdestsign);
             $objDrawing->setHeight($nm_image_altura);
             $col = $this->calc_cell($this->xls_col);
             $objDrawing->setCoordinates($col . $this->xls_row);
             $objDrawing->setWorksheet($this->Nm_ActiveSheet);
             if (!isset($this->NM_Col_din[$col]) || $this->NM_Col_din[$col] < $nm_image_largura)
             { 
                 $this->NM_Col_din[$col] = $nm_image_largura;
             } 
             if (!isset($this->NM_Row_din[$this->xls_row]) || $this->NM_Row_din[$this->xls_row] < $nm_image_altura)
             { 
                 $this->NM_Row_din[$this->xls_row] = $nm_image_altura;
             } 
         } 
         else 
         { 
             $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
             $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, ' ');
         } 
         $this->xls_col++;
   }
   //----- email
   function NM_export_email()
   {
         $this->email = html_entity_decode($this->email, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->email = strip_tags($this->email);
         if (!NM_is_utf8($this->email))
         {
             $this->email = sc_convert_encoding($this->email, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->email);
         $this->xls_col++;
   }
   //----- envregistrationno
   function NM_export_envregistrationno()
   {
         $this->envregistrationno = html_entity_decode($this->envregistrationno, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->envregistrationno = strip_tags($this->envregistrationno);
         if (!NM_is_utf8($this->envregistrationno))
         {
             $this->envregistrationno = sc_convert_encoding($this->envregistrationno, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->envregistrationno);
         $this->xls_col++;
   }
   //----- fdestaddress
   function NM_export_fdestaddress()
   {
         $this->fdestaddress = html_entity_decode($this->fdestaddress, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->fdestaddress = strip_tags($this->fdestaddress);
         if (!NM_is_utf8($this->fdestaddress))
         {
             $this->fdestaddress = sc_convert_encoding($this->fdestaddress, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->fdestaddress);
         $this->xls_col++;
   }
   //----- fdestaepo
   function NM_export_fdestaepo()
   {
         $this->fdestaepo = html_entity_decode($this->fdestaepo, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->fdestaepo = strip_tags($this->fdestaepo);
         if (!NM_is_utf8($this->fdestaepo))
         {
             $this->fdestaepo = sc_convert_encoding($this->fdestaepo, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->fdestaepo);
         $this->xls_col++;
   }
   //----- fdestphone
   function NM_export_fdestphone()
   {
         $this->fdestphone = html_entity_decode($this->fdestphone, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->fdestphone = strip_tags($this->fdestphone);
         if (!NM_is_utf8($this->fdestphone))
         {
             $this->fdestphone = sc_convert_encoding($this->fdestphone, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->fdestphone);
         $this->xls_col++;
   }
   //----- fdestrespone
   function NM_export_fdestrespone()
   {
         $this->fdestrespone = html_entity_decode($this->fdestrespone, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->fdestrespone = strip_tags($this->fdestrespone);
         if (!NM_is_utf8($this->fdestrespone))
         {
             $this->fdestrespone = sc_convert_encoding($this->fdestrespone, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->fdestrespone);
         $this->xls_col++;
   }
   //----- fdestresponseemail
   function NM_export_fdestresponseemail()
   {
         $this->fdestresponseemail = html_entity_decode($this->fdestresponseemail, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->fdestresponseemail = strip_tags($this->fdestresponseemail);
         if (!NM_is_utf8($this->fdestresponseemail))
         {
             $this->fdestresponseemail = sc_convert_encoding($this->fdestresponseemail, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->fdestresponseemail);
         $this->xls_col++;
   }
   //----- phone
   function NM_export_phone()
   {
         $this->phone = html_entity_decode($this->phone, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->phone = strip_tags($this->phone);
         if (!NM_is_utf8($this->phone))
         {
             $this->phone = sc_convert_encoding($this->phone, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->phone);
         $this->xls_col++;
   }
   //----- produceraepo
   function NM_export_produceraepo()
   {
         $this->produceraepo = html_entity_decode($this->produceraepo, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->produceraepo = strip_tags($this->produceraepo);
         if (!NM_is_utf8($this->produceraepo))
         {
             $this->produceraepo = sc_convert_encoding($this->produceraepo, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->produceraepo);
         $this->xls_col++;
   }
   //----- producerb_address
   function NM_export_producerb_address()
   {
         $this->producerb_address = html_entity_decode($this->producerb_address, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->producerb_address = strip_tags($this->producerb_address);
         if (!NM_is_utf8($this->producerb_address))
         {
             $this->producerb_address = sc_convert_encoding($this->producerb_address, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->producerb_address);
         $this->xls_col++;
   }
   //----- responsename
   function NM_export_responsename()
   {
         $this->responsename = html_entity_decode($this->responsename, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         $this->responsename = strip_tags($this->responsename);
         if (!NM_is_utf8($this->responsename))
         {
             $this->responsename = sc_convert_encoding($this->responsename, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->responsename);
         $this->xls_col++;
   }
   //----- wttransporterresponse
   function NM_export_wttransporterresponse()
   {
         $this->wttransporterresponse = html_entity_decode($this->wttransporterresponse, ENT_COMPAT, $_SESSION['scriptcase']['charset']);
         if (!NM_is_utf8($this->wttransporterresponse))
         {
             $this->wttransporterresponse = sc_convert_encoding($this->wttransporterresponse, "UTF-8", $_SESSION['scriptcase']['charset']);
         }
         $this->Nm_ActiveSheet->getStyle($this->calc_cell($this->xls_col) . $this->xls_row)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_LEFT);
         $this->Nm_ActiveSheet->setCellValue($this->calc_cell($this->xls_col) . $this->xls_row, $this->wttransporterresponse);
         $this->xls_col++;
   }

   function calc_cell($col)
   {
       $arr_alfa = array("","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
       $val_ret = "";
       $result = $col + 1;
       while ($result > 26)
       {
           $cel      = $result % 26;
           $result   = $result / 26;
           if ($cel == 0)
           {
               $cel    = 26;
               $result--;
           }
           $val_ret = $arr_alfa[$cel] . $val_ret;
       }
       $val_ret = $arr_alfa[$result] . $val_ret;
       return $val_ret;
   }

   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 monta_html()
   {
      global $nm_url_saida, $nm_lang;
      include($this->Ini->path_btn . $this->Ini->Str_btn_grid);
      unset($_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['xls_file']);
      if (is_file($this->xls_f))
      {
          $_SESSION['sc_session'][$this->Ini->sc_page]['pdfreport_wastetransactions']['xls_file'] = $this->xls_f;
      }
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
            "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML<?php echo $_SESSION['scriptcase']['reg_conf']['html_dir'] ?>>
<HEAD>
 <TITLE><?php echo $this->Ini->Nm_lang['lang_othr_grid_titl'] ?> - wastetransactions :: Excel</TITLE>
 <META http-equiv="Content-Type" content="text/html; charset=<?php echo $_SESSION['scriptcase']['charset_html'] ?>" />
<?php
if ($_SESSION['scriptcase']['proc_mobile'])
{
?>
  <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<?php
}
?>
 <META http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT"/>
 <META http-equiv="Last-Modified" content="<?php echo gmdate("D, d M Y H:i:s"); ?> GMT"/>
 <META http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate"/>
 <META http-equiv="Cache-Control" content="post-check=0, pre-check=0"/>
 <META http-equiv="Pragma" content="no-cache"/>
  <link rel="stylesheet" type="text/css" href="../_lib/css/<?php echo $this->Ini->str_schema_all ?>_export.css" /> 
  <link rel="stylesheet" type="text/css" href="../_lib/css/<?php echo $this->Ini->str_schema_all ?>_export<?php echo $_SESSION['scriptcase']['reg_conf']['css_dir'] ?>.css" /> 
  <link rel="stylesheet" type="text/css" href="../_lib/buttons/<?php echo $this->Ini->Str_btn_css ?>" /> 
</HEAD>
<BODY class="scExportPage">
<?php echo $this->Ini->Ajax_result_set ?>
<table style="border-collapse: collapse; border-width: 0; height: 100%; width: 100%"><tr><td style="padding: 0; text-align: center; vertical-align: middle">
 <table class="scExportTable" align="center">
  <tr>
   <td class="scExportTitle" style="height: 25px">XLS</td>
  </tr>
  <tr>
   <td class="scExportLine" style="width: 100%">
    <table style="border-collapse: collapse; border-width: 0; width: 100%"><tr><td class="scExportLineFont" style="padding: 3px 0 0 0" id="idMessage">
    <?php echo $this->Ini->Nm_lang['lang_othr_file_msge'] ?>
    </td><td class="scExportLineFont" style="text-align:right; padding: 3px 0 0 0">
     <?php echo nmButtonOutput($this->arr_buttons, "bexportview", "document.Fview.submit()", "document.Fview.submit()", "idBtnView", "", "", "", "", "", "", $this->Ini->path_botoes, "", "", "", "", "", "only_text", "text_right", "", "", "", "");
 ?>
     <?php echo nmButtonOutput($this->arr_buttons, "bdownload", "document.Fdown.submit()", "document.Fdown.submit()", "idBtnDown", "", "", "", "", "", "", $this->Ini->path_botoes, "", "", "", "", "", "only_text", "text_right", "", "", "", "");
 ?>
     <?php echo nmButtonOutput($this->arr_buttons, "bvoltar", "document.F0.submit()", "document.F0.submit()", "idBtnBack", "", "", "", "", "", "", $this->Ini->path_botoes, "", "", "", "", "", "only_text", "text_right", "", "", "", "");
 ?>
    </td></tr></table>
   </td>
  </tr>
 </table>
</td></tr></table>
<form name="Fview" method="get" action="<?php echo $this->Ini->path_imag_temp . "/" . $this->arquivo ?>" target="_blank" style="display: none"> 
</form>
<form name="Fdown" method="get" action="pdfreport_wastetransactions_download.php" target="_blank" style="display: none"> 
<input type="hidden" name="nm_tit_doc" value="<?php echo NM_encode_input($this->tit_doc); ?>"> 
<input type="hidden" name="nm_name_doc" value="<?php echo NM_encode_input($this->Ini->path_imag_temp . "/" . $this->arquivo) ?>"> 
</form>
<FORM name="F0" method=post action="./"> 
<INPUT type="hidden" name="script_case_init" value="<?php echo NM_encode_input($this->Ini->sc_page); ?>"> 
<INPUT type="hidden" name="script_case_session" value="<?php echo NM_encode_input(session_id()); ?>"> 
<INPUT type="hidden" name="nmgp_opcao" value="volta_grid"> 
</FORM> 
</BODY>
</HTML>
<?php
   }
   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;
   } 
function loadDetails()
{
$_SESSION['scriptcase']['pdfreport_wastetransactions']['contr_erro'] = 'on';
   



$check_sql = "SELECT Response,ResponsePhone,email,ENV_RegNo,ResponseFax "
  . " FROM transporter"
 . " WHERE TransporterID = '" . $this->wttransporterid  . "'";
 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($rx = $this->Db->Execute($nm_select)) 
      { 
          $y = 0; 
          $nm_count = $rx->FieldCount();
          while (!$rx->EOF)
          { 
                 for ($x = 0; $x < $nm_count; $x++)
                 { 
                        $this->rs[$y] [$x] = $rx->fields[$x];
                 }
                 $y++; 
                 $rx->MoveNext();
          } 
          $rx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 
;

if (isset($this->rs[0][0]))     
{
  $this->wttransporterresponse  = $this->rs[0][0];




}
		else     
{
	$transporterresponse  = '';




}


$check_sql = "SELECT Address, ResponseName,Phone,email,Periferia,AEPO "
  . " FROM producerbranch"
 . " WHERE PrBID = '" . $this->wtproducerbranchid  . "'";
 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($rx = $this->Db->Execute($nm_select)) 
      { 
          $y = 0; 
          $nm_count = $rx->FieldCount();
          while (!$rx->EOF)
          { 
                 for ($x = 0; $x < $nm_count; $x++)
                 { 
                        $this->rs[$y] [$x] = $rx->fields[$x];
                 }
                 $y++; 
                 $rx->MoveNext();
          } 
          $rx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 
;

if (isset($this->rs[0][0]))     
{
  $this->producerb_address  = $this->rs[0][0];
  $this->responsename  = $this->rs[0][1];
$this->phone  = $this->rs[0][2];
$this->email  = $this->rs[0][3];
$this->produceraepo  = $this->rs[0][5];
}
		else     
{
	$this->producerb_address  = '......';
   $this->responsename  = '';
	$this->phone  = '';
	$this->email  = '';
	$this->produceraepo  = '';
}




$check_sql = "SELECT Address, ResponseName,Phone,email,Periferia,AEPO,EnvRegistrationNo "
   . " FROM fdestbranch "
   . " WHERE PrBID = '" . $this->wtfdestid  . "'";
 
      $nm_select = $check_sql; 
      $_SESSION['scriptcase']['sc_sql_ult_comando'] = $nm_select; 
      $_SESSION['scriptcase']['sc_sql_ult_conexao'] = ''; 
      $this->rs = array();
      if ($rx = $this->Db->Execute($nm_select)) 
      { 
          $y = 0; 
          $nm_count = $rx->FieldCount();
          while (!$rx->EOF)
          { 
                 for ($x = 0; $x < $nm_count; $x++)
                 { 
                        $this->rs[$y] [$x] = $rx->fields[$x];
                 }
                 $y++; 
                 $rx->MoveNext();
          } 
          $rx->Close();
      } 
      elseif (isset($GLOBALS["NM_ERRO_IBASE"]) && $GLOBALS["NM_ERRO_IBASE"] != 1)  
      { 
          $this->rs = false;
          $this->rs_erro = $this->Db->ErrorMsg();
      } 
;

if (isset($this->rs[0][0]))     
{
   $this->fdestaddress  = $this->rs[0][0];
  $this->fdestrespone  = $this->rs[0][1];
   $this->fdestphone  = $this->rs[0][2];
	$this->fdestresponseemail  = $this->rs[0][3];
	$this->fdestaepo  = $this->rs[0][5];
	$this->envregistrationno  = $this->rs[0][6];
}
		else     
{
$this->fdestaddress  = '';
$this->fdestrespone  = '';
$this->fdestphone  = '';
$this->fdestresponseemail  = '';
$this->fdestaepo   = '';
$this->envregistrationno ='';
}
$_SESSION['scriptcase']['pdfreport_wastetransactions']['contr_erro'] = 'off';
}
}

?>
