;* Exp_site *******************************************************************
;* Geracao de dados p/ site Divina Panela                                     *
;******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido    : 04/05/2017 por Rafael Matos
;Ultima Alteracao: 19/09/2017 por Bruno Carvalho 
;Motivo Alteracao: Nova implementa‡Æo p/ imprimir em XML *SCRIPT COMPLETAMENTE ALTERADO 
;Ultima Alteracao: 09/11/2017 por Bruno Carvalho 
;Motivo Alteracao: Ajustes de campos obs, departamento e acentua‡Æo no cat logo
;Ultima Alteracao: 21/11/2017 por Bruno Carvalho 
;Motivo Alteracao: Adicionado encoding="ISO-8859-1" na primeira linha do XML -> Instru‡Æä p/ Portuguˆs 
;Ultima Alteracao: 28/03/2018 por Bruno Carvalho 
;Motivo Alteracao: Removido acentua‡Æo da palavra cat logo
;Ultima Alteracao: 10/05/2018 por Bruno Carvalho 
;Motivo Alteracao: Adicionado caminho da imagem -> CAMINHO_IMAGEM
;Ultima Alteracao: 02/01/2019 por Bruno Carvalho 
;Motivo Alteracao: Vari vel TabelaREF sendo ignorada quando op‡Æo for somente tabela de pre‡o na proc Produtos()  
;Ultima Alteracao: 09/01/2019 por Bruno Carvalho 
;Motivo Alteracao: Ajustado o caminho do arquivo do XML ao ser gerado para "\\Sistemas\\Exporta\\Dados\\importacao.xml"
;Ultima Alteracao: 11/01/2019 por Bruno Carvalho 
;Motivo Alteracao: Alterado DEPARTAMENTO p/ CATEGORIA -> Produtos()

;*******************************************************************************
;* Monta Cabe‡alho XMLROTINA PRINCIPAL                                         *
;*******************************************************************************
Proc Cabecalho_XML()

Print File ARQIMP "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"+"\n"                                          
Print File ARQIMP "<?mso-application progid=\"Excel.Sheet\"?>"+"\n"
Print File ARQIMP "<Workbook xmlns=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-"
Print File ARQIMP "instance\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns:x2=\"http://schemas.microsoft.com/office/e"
Print File ARQIMP "xcel/2003/xml\" xmlns:ss=\"urn:schemas-microsoft-com:office:spreadsheet\" xmlns:o=\"urn:schemas-microsoft-com:"
Print File ARQIMP "office:office\" xmlns:html=\"http://www.w3.org/TR/REC-html40\" xmlns:c=\"urn:schemas-microsoft-com:office:comp"
Print File ARQIMP "onent:spreadsheet\">"+"\n"
Print File ARQIMP "  <OfficeDocumentSettings xmlns=\"urn:schemas-microsoft-com:office:office\"></OfficeDocumentSettings>"+"\n"
Print File ARQIMP "  <ExcelWorkbook xmlns=\"urn:schemas-microsoft-com:office:excel\"></ExcelWorkbook>"+"\n"
Print File ARQIMP "  <Worksheet ss:Name=\"Sheet 1\">"+"\n"
Print File ARQIMP "    <Table>"+"\n"
Print File ARQIMP "      <Row>"+"\n"
;----- Coluna A ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">store</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna B ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">websites</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna C ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">attribute_set</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna D ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"                                 
Print File ARQIMP "          <Data ss:Type=\"String\">type</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna E ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">category_ids</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna F ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">sku</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna G ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">has_options</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna H ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">name</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna I ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">meta_title</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna J ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">meta_description</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna K ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">image</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna L ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">small_image</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna M ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">thumbnail</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna N ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">url_key</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna O ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">url_path</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna P ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">custom_design</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna Q ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">page_layout</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna R ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">options_container</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna S ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">image_label</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna T ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">small_image_label</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna U ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">thumbnail_label</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna V ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">country_of_manufacture</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna W ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">msrp_enabled</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna X ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">msrp_display_actual_price_type</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna Y ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">gift_message_available</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna Z ----------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">price</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AA ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">special_price</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AB ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">weight</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AC ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">msrp</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AD ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">status</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AE ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">is_recurring</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AF ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">visibility</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AG ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">tax_class_id</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AH ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">featured</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AI ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">description</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AJ ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">short_description</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AK ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">meta_keyword</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AL ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">custom_layout_update</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AM ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"                                               
Print File ARQIMP "          <Data ss:Type=\"String\">special_from_date</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AN ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">special_to_date</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AO ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">news_from_date</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AP ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">news_to_date</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AQ ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">custom_design_from</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AR ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">custom_design_to</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AS ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AT ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">min_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AU ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_min_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AV ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">is_qty_decimal</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AW ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">backorders</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AX ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_backorders</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AY ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">min_sale_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna AZ ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_min_sale_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BA ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">max_sale_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BB ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_max_sale_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BC ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">is_in_stock</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BD ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">low_stock_date</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BE ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">notify_stock_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BF ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_notify_stock_qty</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BG ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">manage_stock</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BH ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_manage_stock</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BI ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">stock_status_changed_auto</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BJ ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_qty_increments</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BK ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">qty_increments</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BL ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_enable_qty_inc</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BM ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">enable_qty_increments</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BN ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">is_decimal_divided</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BO ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"                                                             
Print File ARQIMP "          <Data ss:Type=\"String\">stock_status_changed_automatically</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BP ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">use_config_enable_qty_increments</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BQ ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">product_name</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BR ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">store_id</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BS ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">product_type_id</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BT ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">product_status_changed</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"                                              
;----- Coluna BU ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">product_changed_websites</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BV ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">loja_virtual</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BW ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"                                               
Print File ARQIMP "          <Data ss:Type=\"String\">color</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BX ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">familia</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BY ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">recurring_profile</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna BZ ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">fit_size</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CA ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">marca</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CB ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">grupo</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CC ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">volume_comprimento</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CD ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">volume_altura</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CE ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">volume_largura</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CF ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">posting_days</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"
;----- Coluna CG ---------------------------------------------------------------
Print File ARQIMP "        <Cell>"+"\n"
Print File ARQIMP "          <Data ss:Type=\"String\">postmethods</Data>"+"\n"
Print File ARQIMP "        </Cell>"+"\n"

Print File ARQIMP "      </Row>"+"\n"

EndProc ;Cabecalho_XML()

;*******************************************************************************
;* Monta Rodap‚e‡alh   o XML                                                   *
;*******************************************************************************
Proc Rodape_XML()

Print File ARQIMP "    </Table>"+"\n"
Print File ARQIMP "  </Worksheet>"+"\n"
Print File ARQIMP "</Workbook>"+"\n"

EndProc ;Rodape_XML()

;********************************************************************************
;* CONVERTE VALOR PARA STRING                                                  *
;********************************************************************************
Proc Valor_Str(Valor,Tam,Dec)
Private VrTit,Valor,Tam,Dec,Part1,Part2

VrTit=StrVal(Valor)
If SearchFrom(".",VrTit,1)>0
   Then Part1=SubStr(VrTit,1,SearchFrom(".",VrTit,1)-1)
        Part2=SubStr(VRTit,SearchFrom(".",VrTit,1)+1,Dec)
        Part2=PART2+Fill(0,DEC-Len(Part2))
   Else Part1=VrTit
        Part2=Fill(0,Dec)
EndIf
Vrtit=Part1+Part2
VrTit=Fill("0",Tam-Len(VrTit))+VrTit
Return VrTit

EndProc  ; (Valor_Str)

;********************************************************************************
;* CONVERTE VALOR PARA STRING                                                  *
;********************************************************************************
Proc Tira_PontoVirgula(Valor)

PosI=Search(";",Valor)
If PosI>0
   Then While PosI>0
          Valor = Substr(Valor,1,PosI-1)+Substr(Valor,PosI+1,LEN(Valor))
          PosI=Search(";",Valor)
        Endwhile  
EndIf
Return Valor

EndProc       

;*******************************************************************************
;* Gera Arquivo Texto p/ Produtos                                              *
;*******************************************************************************
Proc Produtos()                      
Private DESC_NCM,REG_ITEM
ClearAll

If Not IsAssigned(TabelaREF) Or IsEmpty(TabelaREF)
   Then Return
EndIf  

ARQIMP = PrivDir()+"imp.txt"
If IsFile(ARQIMP) Then Deleta_Arquivo(ARQIMP) EndIf

ARQ_XML = SubStr(Directory(),1,2)+"\\Sistemas\\Exporta\\Dados\\importacao.xml"

;---- Excluindo arquivo anterior --------------------------------------
AUX_ARQ = ARQIMP
ExecVise("REN "+ARQ_XML+" "+AUX_ARQ)
If IsFile(AUX_ARQ) Then Deleta_Arquivo(AUX_ARQ) EndIf
Sleep 1000

Cabecalho_XML() 
         
NR=NRecords(TabelaREF)

CONTA = 0

View TabelaREF                                                   
Scan
  Barra(NR, RecNo())
  AGUARDE("Aguarde, Exportando Produtos "+BARRA_STRING)

  ;SE UTILIZAR OBS, QUAL O CAMPO NO XML QUE REPRESENTA A OBSERVACAO DO ITEM
  ;Como Funciona a Imagem?
  ;Pre‡o Promocional?
  ;Tempo que o produto ir  ficar no site (no script informei 1 ano)
  ;Ir  utilizar o estoque de hoje ou de ontem? 
  ;Quantidade Minima?

  PRECO_ITEM          = Ltrim(Rtrim(format("W12.2",[Preco Unitario])))
  PRECO_ITEM_PROMOCAO = PRECO_ITEM
  QUANTIDADE          = Ltrim(Rtrim(format("W10,3",[Saldo Atual Hoje])))
  QUANTIDADE_MINIMA   = "0"
  
  DESCRICAO_MARKETING = ""                                                      ;Exemplo: "Cafeteira luxo. Perfeita para vocˆ!"
  UTILIZA_QUANTIDADE_MINIMA = StrVal(1)                                         ;No Exemplo estava 1 ???
  
  If [Inativo]="S"
     Then STATUS_ITEM="Desabilitado"
     Else STATUS_ITEM="Habilitado" 
  EndIf
  
  DESCRICAO              = Ltrim(Rtrim(Tira_CharEspecial([Descricao do Item      ])))
  DESCRICAO_COMPLEMENTAR = Ltrim(Rtrim(Tira_CharEspecial([Descricao Complementar])))
  AUX_OBS                = Tira_QuebraLinha(Ltrim(Rtrim((Tira_CharEspecial([Observacao])))))
  AUX_OBS2               = AUX_OBS  
  DEPARTAMENTO           = Tira_CharEspecial([Codigo do Departamento])
  
  GetRecord "\\Sistemas\\Estoque\\Iten_Com" [Codigo do Item] To REG_ITENCOM
  If RetVal
     Then CATEGORIA = Rtrim(REG_ITENCOM["Codigo da Categoria"])
          If CATEGORIA<>"" And Type(NumVal(CATEGORIA))="N"
             Then CATEGORIA = Strval(NumVal(CATEGORIA))     ;Removendo o zero … esquerda do c¢digo
          EndIf    
     Else CATEGORIA = ""
  EndIf  
  
  If Len(AUX_OBS)>200
     Then CONT = 0
          DynArrAy AUX_OBS_DynArray[]
          While True
            CONT = CONT + 1
            AUX_OBS_DynArray[CONT] = Format("W5",Strval(CONT))+SubStr(AUX_OBS,1,200)
            AUX_OBS = SubStr(AUX_OBS,201,Len(AUX_OBS))
            If Rtrim(Ltrim(AUX_OBS))=""
               Then QuitLoop
            EndIf 
          EndWhile
          Release Vars OBS,CONT,AUX_OBS
          Array OBS[DynArraySize(AUX_OBS_DynArray)]
          For i From 1 To DynArraySize(AUX_OBS_DynArray)
            OBS[i] = SubStR(AUX_OBS_DynArray[i],6,Len(AUX_OBS_DynArray[i])) 
          EndFor
          Release Vars AUX_OBS_DynArray
     Else Array OBS[1]
          OBS[1] = AUX_OBS 
  EndIf
  
  CAMINHO_IMAGEM=""
  GetRecord "\\Sistemas\\Estoque\\Iten_eco" [Codigo do Item] To REG_ITEN_ECO
  If RetVal
     Then CAMINHO_IMAGEM=REG_ITEN_ECO["Link_Imagem"]
  EndIf
  
  CODIGO_ITEM            = [Codigo do Item]
  PESO_LIQUIDO           = Ltrim(Rtrim(format("W10.3",[Peso Liquido])))  
  PAIS_ORIGEM            = Tira_CharEspecial([Pais])
  DESCRICAO_FAMILIA      = Ltrim(Rtrim(Tira_CharEspecial([Descricao da Familia])))
  DESCRICAO_GRUPO        = Ltrim(Rtrim(Tira_CharEspecial([Descricao do Grupo])))
  DESCRICAO_MARCA        = Ltrim(Rtrim(Tira_CharEspecial([Descricao da Marca])))
  
  ;---- DATA INICIO E DATA FIM DO PRODUTO NO SITE ------------------------------
  AUX_HORA        = ""
  AUX_DATA_INICIAL= ""
  AUX_DATA_FINAL  = ""
  
  ;XXXX-XX-XX XX:XX:XX
  DATA_CADASTRO   = [Data_Cadastro]
  If IsBlank(DATA_CADASTRO) Then DATA_CADASTRO = [Data Ultimo Reajuste] EndIf
  
  HORA_MANUTENCAO = [Hora da Manutencao]  If Len(HORA_MANUTENCAO)=5 Then AUX_HORA = HORA_MANUTENCAO + ":00" EndIf
  If Not IsBlank(DATA_CADASTRO) And Type(DATA_CADASTRO)="D"
     Then AUX_DATA_INICIAL = StrVal(Year(DATA_CADASTRO))+"-"+AlinhM(StrVal(Month(DATA_CADASTRO)),2)+"-"+AlinhM(StrVal(Day(DATA_CADASTRO)),2)+" "+HORA_MANUTENCAO
          
          ;Teste ??? - Produto vai ficar 1 Ano no site   
          AUX_DATA_FINAL = StrVal(NumVal(Year(DATA_CADASTRO))+1)+"-"+AlinhM(StrVal(Month(DATA_CADASTRO)),2)+"-"+AlinhM(StrVal(Day(DATA_CADASTRO)),2)+" "+HORA_MANUTENCAO
  EndIf   
  DATA_INICIAL = AUX_DATA_INICIAL 
  DATA_FINAL   = AUX_DATA_FINAL
  ;-----------------------------------------------------------------------------   
  
  Print File ARQIMP "      <Row>"+"\n"
 ;----- Coluna A - STORE ------------------------------------------------------- 
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">admin</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna B - WEBSITE -----------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">base</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna C - ATRIBUTTE ---------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Familia/Grupo</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna D - TYPE --------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">simple</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna E - CATEGORIA/DEPARTAMENTO --------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+CATEGORIA+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna F - CODIGO DO ITEM ----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+CODIGO_ITEM+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna G - OPTIONS -----------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"      
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna H - DESCRICAO CURTA ---------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna I ---------------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna J ---------------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna K - IMAGEM ------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+CAMINHO_IMAGEM+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna L - IMAGEM ------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna M - IMAGEM ------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna N - URL KEY -----------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna O - URL PATCH ---------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna P - CUSTOM DESIGN -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna Q - PAGE LAYOUT -------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Sem atualizacoes de leiaute</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna R - OPTIONSS-----------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Info Coluna de Produto</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna S - IMAGE LABEL -------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna T - SMALL IMAGE LABEL -------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna U - THUMBS LABEL ------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna V - PAIS DE ORIGEM ----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+PAIS_ORIGEM+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna W - MSRP --------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Utilizar configuracao</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna X - MSRP---------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Utilizar configuracao</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna Y - GIFT---------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Nao</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna Z - PRECO -------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">"+PRECO_ITEM+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AA - PRECO EM PROMOCAO ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"                                         
  Print File ARQIMP "          <Data ss:Type=\"String\">"+PRECO_ITEM_PROMOCAO+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AB - PESO -------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">"+PESO_LIQUIDO+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AC - MSRP -------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AD - STATUS DO ITEM: ATIVO/INATIVO ------------------------------
  Print File ARQIMP "        <Cell>"+"\n"  
  Print File ARQIMP "          <Data ss:Type=\"String\">"+STATUS_ITEM+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AE - IS_RECURRIGN -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Nao</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna AF - VISIBILITY -------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Catalogo, Busca</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AG - TAX CLASSIFICACAO ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Nenhum</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AH - FEATURE ----------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Nao</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AI - DESCRICAO DE MARKETING -------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO_MARKETING+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AJ - OBSERVACAO -------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"
  For i From 1 To ArraySize(OBS)
     Print File ARQIMP OBS[i]
  EndFor   
  Print File ARQIMP "</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AK - META KEYWORD -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AL - DESCRICAO COMPLEMENTAR -------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO_COMPLEMENTAR+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AM - SPECIAL FROM DATE ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AN - SPECIAL TO DATE --------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AO - NEW FROM DATE ----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DATA_INICIAL+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AP - NEW TO DATE ------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DATA_FINAL+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AQ - CUSTOM DESIGN FROM -----------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AR - CUSTOM DESIGN TO -------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AS - QUANTIDADE EM ESTOQUE --------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">"+QUANTIDADE+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AT - QUANTIDADE MINIMA ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">"+QUANTIDADE_MINIMA+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AU - USE CONFIG MIN ---------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">"+UTILIZA_QUANTIDADE_MINIMA+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AV - SE QUANTIDADE DECIMAL --------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AW - BACKORDERS -------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna AX - USE CONFIG BACKORDERS --------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AY - MIN CONFIG BACKORDERS --------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1.0000</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna AZ - USE CONFIG MIN SALE ----------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BA - MAX SALE ---------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0.0000</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna BB - USE CONFIG MAX SALE ----------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BC - IS IN STOCK -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BD - LOW STOCK --------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BE - NOTIFY STOCK -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BF - USE CONFIG NOTIFY ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n" 
 ;----- Coluna BG - MANAGE STOCK -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BH - USE CONFIG MANAGE STOCK ------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BI - STOCK STATUS -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BJ - USE CONFIG QUANTIDADE INCREMENTS ---------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BK - QUANTIDADE INCREMENTS --------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0.0000</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BL - USE CONFIG ENABLE QUANTIDADE INC ---------------------------
  Print File ARQIMP "        <Cell>"+"\n"                            
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BM - ENABLE QUANTIDADE INCREMENTS -------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BN - IS DECIMAL DIVIDED -----------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BO - STOCK STATUS CHANGED ---------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BP - USE CONFIG ENABLE ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">1</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BQ - DESCRICAO DO PRODUTO ---------------------------------------
 Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BR - STORE ID ---------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"Number\">0</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BS - PRODUTO TIPO ID --------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">simple</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BT - PRODUTO STATUS CHANGED -------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BU - PRODUTO CHANGED WEBSITE ------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BV - LOJA VIRTUAL -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">Sim</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BW - COLOR ------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BX - FAMILIA ----------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO_FAMILIA+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BY - RECURRING PROFILE ------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna BZ - FIT SIZE ---------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CA - MARCA ------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO_MARCA+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CB - GRUPO ------------------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\">"+DESCRICAO_GRUPO+"</Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CC - VOLUME COMPRIMENTO -----------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CD - VOLUME ALTURA ----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CE - VOLUME LARGURA ---------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CF - POSTING DAYS -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
 ;----- Coluna CG - POST METHODS -----------------------------------------------
  Print File ARQIMP "        <Cell>"+"\n"
  Print File ARQIMP "          <Data ss:Type=\"String\"></Data>"+"\n"
  Print File ARQIMP "        </Cell>"+"\n"
  Print File ARQIMP "      </Row>"+"\n"  
EndScan                                       
ClearAll

Rodape_XML()

Aguarde("Aguarde, renomeando arquivo importado")
ExecVise("REN "+ARQIMP+" "+ARQ_XML)
Sleep 1000  

COR_MENSAGEM="1"
Mensagem("//Gerado o arquivo:////"+ARQ_XML)

Release Vars COR_MENSAGEM

EndProc ;Produtos()

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc Gera_Tabela()
Private i,ii,prec,AUX_DATA,CODTAB,PARAM_ASK

ItemInativo              = ""
AuxItem                  = ""
ItemPreco                = ""
ItemEstoqueAtual         = ""
ItemAExcluirDtManutencao = ""

For i From 1 To 4
  Switch
    Case i = 1 : ;---- Itens Inativos por mais de 30 Dias ----------------------
                 {Ask} {\\Sistemas\\Estoque\\Itens} 
                 Moveto [Codigo do Item          ] Check TypeIn "_CodI"
                 Moveto [Tipo do Item            ]       TypeIn "P Or C Or T Or E"
                 Moveto [Inativo                 ]       TypeIn "S"
                 Moveto [Codigo da Cor_Tecido    ]       TypeIn "~VSDGCORTECIDO.."
                 {Ask} {\\Sistemas\\Estoque\\EstqPrm}
                 Moveto [Codigo da Empresa       ] TypeIn "~VSDGEMPRESA"
                 Moveto [Codigo do Item          ] TypeIn "_CodI"
                 Moveto [Data de Inatividade     ] Check TyPein "Not Blank"
                 Do_it!
                 ClearAll
                 
                 If Not IsEmpty("Answer")
                    Then AUX_DATA = Today()-30
                         {Ask} {Answer}
                         Moveto [Codigo do Item     ] Check
                         Moveto [Data de Inatividade] TyPein "<=~AUX_DATA"
                         Do_it!
                         CleaRall
                 EndIf   
                 ItemInativo = Adiciona_Indice_Temp("Codigo do Item")
                 
    Case i = 2 : If VSDGDTINI = BlankDate() And VSDGDTFIM=BlankDate() Then Loop EndIf    
                 ;---- Data de Manuten‡Æo --------------------------------------
                 {Ask} {\\Sistemas\\Estoque\\Itens} 
                 Moveto [Codigo do Item          ] Check
                 Moveto [Tipo do Item            ]       TypeIn "P Or C Or T Or E" 
                 Moveto [Codigo da Cor_Tecido    ]       TypeIn "~VSDGCORTECIDO.."
                 Moveto [Data_Cadastro           ] Check
                 Moveto [Data da Manutencao      ] Check
                 Do_it!
                 ClearAll
                 AuxItem = Adiciona_Indice_Temp("Codigo do Item")        
                 
                 For ii From 1 To 2
                    Switch
                      Case ii = 1 : {Ask} TypeIn AuxItem Enter Check
                                    Moveto [Data da Manutencao] TypeIn "Blank"
                                    Moveto [Data_Cadastro     ] TypeIn "<~VSDGDTINI Or >~VSDGDTFIM"
                                    Do_it!
                                    ClearAll
                                    
                                    ItemAExcluirDtManutencao = Adiciona_Indice_Temp("Codigo do Item")
                                     
                      Case ii = 2 : {Ask} TypeIn AuxItem Enter Check
                                    Moveto [Data da Manutencao] TypeIn "Not Blank, <~VSDGDTINI Or >~VSDGDTFIM"
                                    Do_it!
                                    ClearAll
                                    
                                    Add "Answer" ItemAExcluirDtManutencao
                    EndSwitch
                 EndFor
                 If Istable(AuxItem) Then Delete AuxItem EndIf
                 Release Vars AuxItem   
    
    Case i = 3 : If Not VSDGOPCAO[1]    Then Loop EndIf
                 If IsBlank(VSDGTABELA) Then Loop EndIf
                  
                 If VSDGDTINI = BlankDate() And VSDGDTFIM=BlankDate() 
                    Then PARAM_ASK = 1
                    Else PARAM_ASK = 2 
                 EndIf   
                  
                 For ii From 1 To PARAM_ASK
                   {Ask} {\\Sistemas\\Vendas\\TbPrIte}
                   Moveto [Codigo da Tabela    ] TypeIn "~VSDGTABELA" 
                   Moveto [Codigo do Item      ] Check 
                   Moveto [Preco Unitario      ] Check TypeIn ">0"
                   Switch
                     Case ii=1 : Moveto [Data Ultimo Reajuste] Check 
                                 If PARAM_ASK = 2 
                                    Then TyPeIn "Blank"
                                 EndIf   
                     Case ii=2 : Moveto [Data Ultimo Reajuste] Check TyPeIn "Not Blank, >=~VSDGDTINI,<=~VSDGDTFIM"
                   EndSwitch  
                   Do_It!
                   ClearAll
                   If ii=1
                      Then ItemPreco = Adiciona_Indice_Temp("Codigo do Item")
                     Else Add "Answer" ItemPreco
                   EndIf
                 EndFor            
                
                 If Not IsEmpty(ItemInativo)
                    Then {Ask} TypeIn ItemInativo Enter 
                         Moveto [Codigo do Item] Example "Ite"
                         {Ask} TypeIn ItemPreco Enter TypeIn "Fast Delete" Enter
                         Moveto [Codigo do Item] Example "Ite"
                         Do_it!
                         Clearall
                 EndIf
    Case i = 4 : If Not VSDGOPCAO[2] Then Loop EndIf
                 {Ask} {\\Sistemas\\Estoque\\SdEstq}
                 Moveto [Codigo da Empresa] Check TypeIn "~VSDGEMPRESA" 
                 Moveto [Codigo do Item   ] Check 
                 Moveto [Ano Referencia   ] TypeIn "~VSDGANO"
                 Moveto [Mes Referencia   ] TypeIn "~VSDGMES"
                 Moveto [Saldo Atual      ] Check
                 Do_It!
                 ClearAll
                 ItemEstoqueAtual = Adiciona_Indice_Temp("Codigo da Empresa,Codigo do Item")
  EndSwitch     
EndFor  

;**** Itens ***************************************************** 
{Ask} {\\Sistemas\\Estoque\\Itens} 
Moveto [Codigo do Item          ] Check TypeIn "_Ite!"
Moveto [Codigo de Barras        ] Check
Moveto [Descricao do Item       ] Check
Moveto [Descricao Complementar  ] Check
Moveto [Codigo do Grupo         ] Check
Moveto [Descricao do Grupo      ] Check
Moveto [Codigo da Familia       ] Check
Moveto [Descricao da Familia    ] Check
Moveto [Codigo da Marca         ] Check
Moveto [Descricao da Marca      ] Check
Moveto [Codigo da Cor_Tecido    ]       TypeIn "~VSDGCORTECIDO.."
Moveto [Codigo do Departamento  ] Check
Moveto [Codigo Fornecedor       ] Check
Moveto [Inativo                 ] Check
Moveto [Observacao              ] Check
Moveto [Pais                    ] Check
Moveto [Peso Liquido            ] Check
Moveto [Data_Cadastro           ] Check
Moveto [Hora da Manutencao      ] Check
Do_It!
ClearAll
                       
CRIAR_TABELA = False
Adiciona_Campo("Answer","Codigo da Empresa(A4),"+
                        "Preco Unitario($),"+     
                        "Saldo Atual Hoje(N),"+
                        "Saldo Atual(N),"+
                        "Valor Unitario($),"+
                        "Custo Total Atual($),"+
                        "Sdestq(A1),"+
                        "Data Ultimo Reajuste(D),"+
                        "Data de Inatividade(D),"+
                        "Flag(A1),"+
                        "TbPreco(A1)")
                                                
TabelaREF=Adiciona_Indice_Temp("Codigo da Empresa,Codigo do Item")

{Ask} TypeIn TabelaREF Enter
Moveto [Codigo da Empresa] TypeIn "Changeto ~VSDGEMPRESA"
Do_It!
ClearAll 

;----- Excluindo Itens Inativos a partir de determinado per¡odo -----------
{Ask} TypeIn ItemInativo Enter 
Moveto [Codigo do Item] Example "Ite"
{Ask} TypeIn TabelaRef Enter TypeIn "Fast Delete" Enter
Moveto [Codigo do Item] Example "Ite"
Do_it!
Clearall

;---- Desprezando Itens com Data de Manuten‡Æo inferior ao informado ------
If IsTable(ItemAExcluirDtManutencao)
   Then {Ask} TypeIn ItemAExcluirDtManutencao Enter 
        Moveto [Codigo do Item] Example "Ite"
        {Ask} TypeIn TabelaRef Enter 
        Moveto [Codigo do Item] Example "Ite"
        Moveto [Flag          ] TypeIn "Changeto X"
        Do_it!
        Clearall
EndIf
  
If VSDGOPCAO[3] 
   Then ;*****Invent rio do dia anterior *****************************
         SetDir "\\Sistemas\\Estoque"
         Play "RM_0011C"
         SetDir "\\Sistemas\\Exporta"
EndIf 
  
If VSDGOPCAO[2]
   Then {Ask} TypeIn ItemEstoqueAtual Enter
        Moveto [Codigo da Empresa] Example "Cemp" 
        Moveto [Codigo do Item   ] Example "CodI"
        Moveto [Saldo Atual      ] Example "Sald" 
        {Ask} TypeIn TabelaREF Enter TypeIn "Fast"
        Moveto [Codigo da Empresa] Example "Cemp" 
        Moveto [Codigo do Item   ] Example "CodI"
        Moveto [Saldo Atual Hoje ] TypeIn "Changeto _Sald"
        Moveto [Sdestq           ] TypeIn "Changeto X" 
        Do_It!
        ClearAll
EndIf

If VSDGOPCAO[1]  
   Then If Not IsTable(ItemPreco) Or (IsTable(ItemPreco) And IsEmpty(ItemPreco)) 
           Then 
           Else {Ask} TypeIn ItemPreco Enter
                Moveto [Codigo do Item      ] TypeIn "_CodI"
                Moveto [Preco Unitario      ] TypeIn "_PrUn"
                Moveto [Data Ultimo Reajuste] TypeIn "_datp"
                {Ask} TypeIn TabelaREF Enter
                Moveto [Codigo do Item      ] TypeIn "_CodI"
                Moveto [TbPreco             ] TypeIn "Changeto X"
                Moveto [Data Ultimo Reajuste] TypeIn "Changeto _datp"
                Moveto [Preco Unitario      ] TypeIn "Changeto _PrUn"
                Do_It!
                ClearAll
        EndIf
EndIf
   
If IsTable(ItemInativo)      Then Delete ItemInativo      EndIf         
If IsTable(ItemPreco)        Then Delete ItemPreco        EndIf                
If IsTable(ItemEstoqueAtual) Then Delete ItemEstoqueAtual EndIf

Release Vars ItemInativo, ItemPreco, ItemEstoqueAtual  

EndProc ;Gera_Tabela()                                                     

;*******************************************************************************
;* Rotina                                                                      *
;*******************************************************************************
Proc SD_Dialog(Disparo,Campo,Evento,Elemento)
Temp=True
TECLA=""
MSG_CAMPO=""
If Disparo="OPEN"  Then AoCriarShowDialog() EndIf
If Disparo="EVENT" And Evento["Type"]="KEY" Then
   Switch
     Case Evento["KeyCode"] = -59: 
          Dialog_F1()            
     Case Evento["KeyCode"] =  27:
          Temp=False
          Switch
            Case Campo="TG_EMPRESA"       : Campo="NO"
            Case Campo="TG_TABELA"        : Campo="TG_EMPRESA"
            Case Campo="TG_COR_TECIDO"    : Campo="TG_TABELA"
            Case Campo="TG_DTINI"         : Campo="TG_COR_TECIDO"
            Case Campo="TG_DTFIM"         : Campo="TG_DTINI"
            Case Campo="TG_OPCOES"        : Campo="TG_DTFIM"
            Case Campo="YES" Or Campo="NO": Campo="TG_EMPRESA"
          EndSwitch
     Case (Evento["KeyCode"] <= -104 And Evento["KeyCode"] >= -113) Or 
           Evento["KeyCode"]  = -139 Or  Evento["KeyCode"]  = -140:
           SYS_TECLA_ACIONADA=Evento["KeyCode"]
           Seta_Tecla_Acionada()
           CancelDialog
     Case Evento["KeyCode"] = 13:
          Temp=False
          If Checa_TAG()
             Then Switch
                    Case Campo="TG_EMPRESA"         : 
                         VSDGEMPRESA=ControlValue("TG_EMPRESA")
                         If Not IsBlanK(VSDGEMPRESA)
                            Then VSDGEMPRESA=AlinhM(VSDGEMPRESA,4)
                                 Campo="TG_TABELA"              
                         EndIf     
                    Case Campo="TG_TABELA"          : 
                    If Not IsBlank(VSDGTABELA)
                       Then Campo="TG_COR_TECIDO"
                       Else FastMsg("Tabela Inv lida !")
                            Campo="TG_TABELA"
                            VSDGNOMTAB=""
                    EndIf        
                    Case Campo="TG_COR_TECIDO"      : Campo="TG_DTINI"
                    Case Campo="TG_DTINI"           : Campo="TG_DTFIM"
                    Case Campo="TG_DTFIM"           : Campo="TG_OPCOES"
                    Case Campo="TG_OPCOES"          : 
                         If (VSDGOPCAO[1]=False) And
                            (VSDGOPCAO[2]=False) And
                            (VSDGOPCAO[3]=False) 
                            Then Campo="TG_OPCOES"
                            Else Campo="YES"
                         EndIf
                  EndSwitch
          EndIf
          RefreshDialog
   EndSwitch
EndIf
Switch
 Case Campo=""           : MSG_CAMPO=""
 Case Campo="TG_OPCOES"  : MensagemCheckBoxes()
EndSwitch
Monta_Prompt(MSG_CAMPO,TECLA)
Return Temp

EndProc ;SD_Dialog()                                                         

;*******************************************************************************
;* ROTINA PRINCIPAL                                                            *
;*******************************************************************************
AutoLib="\\Sistemas\\Cadastro\\Bib_Show,\\Sistemas\\Cadastro\\Bibliot"
If Not IsAssigned(SYS_CODIGO_CLIENTE)  Then SYS_CODIGO_CLIENTE=""  EndIf
SYS_VALOR()
LimpAguarde()

VSDGDIAREF = AlinhM(StrVal(Day(Today()-1)),2)
VSDGDIA    = AlinhM(StrVal(Day(Today())),2)
VSDGMES    = AlinhM(StrVal(Month(Today())),2)
VSDGANO    = AlinhM(StrVal( Year(Today())),4)
HORA       = Substr(Time(),1,2)+Substr(Time(),4,2)+Substr(Time(),7,2)

VSDGTABELA  = ""
VSDGNOMTAB  = ""
VSDGCORTECIDO  = ""
VSDGDTINI   = BlankDate()
VSDGDTFIM   = BlankDate()

DTFIMREF    = Today()-1
DATAR       = Format("D13",StrVal(DTFIMREF))

Array VSDGOPCAO[3]
VSDGOPCAO[1]=True
VSDGOPCAO[2]=True
VSDGOPCAO[3]=False

While True
 ShowDialog "Exporta‡„o de dados p/ Site" Proc "SD_Dialog"
   Trigger "OPEN","ARRIVE"
    Key "TAB","ReverseTab","ENTER","ESC","F1",
      -104, -105, -106, -107, -108, -109, -110, -111, -112, -113, -139, -140    
     @ 05,12 Height 13 Width 72
     
    Label  @ 00,00 "Empresa"  For "TG_EMPRESA"
    Accept @ 01,01 Width 07 "A4"  Picture "[&,#][#*#]" Tag "TG_EMPRESA" To VSDGEMPRESA
    Accept @ 01,09 Width 25 "A20" Picture "!*!" Tag "TG_NOMEMP" To VSDGNOMEMP

    Label  @ 02,00 "Tabela de Preco"  For "TG_TABELA"
    Accept @ 03,01 Width 08 "A5"  Picture "#*#" Tag "TG_TABELA" To VSDGTABELA
    Accept @ 03,09 Width 25 "A30" Picture "!*!" Tag "TG_NOMTAB" To VSDGNOMTAB
    
    Label  @ 04,00 "Cor" For "TG_COR_TECIDO"
    Accept @ 05,01 Width 07 "A4"  Picture "#*#" Tag "TG_COR_TECIDO"    To VSDGCORTECIDO
    Accept @ 05,09 Width 25 "A25" Picture "!*!" Tag "TG_NOMCOR_TECIDO" To VSDGNOMCORTECIDO
    
    Label  @ 06,00 "Per¡odo Referente de" For "TG_DTINI"
    Accept @ 07,03 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTINI" To VSDGDTINI
    Label  @ 07,16 "at‚" For "TG_DTFIM"
    Accept @ 07,21 Width 13 "D"  Picture "#[#];.##;.##[##]" Tag "TG_DTFIM" To VSDGDTFIM
        
    Label  @ 00,35 "Op‡oes " For "TG_OPCOES"
    CheckBoxes @01,36 Height 3 Width 26 Tag "TG_OPCOES"
    "Tabelas de Pre‡os" to VSDGOPCAO[1],
    "Estoque Atual    " to VSDGOPCAO[2],                       
    "Invent rio "+DATAR to VSDGOPCAO[3]
    
    Pushbutton @ 09,22 width 13 "~O~k"      OK     Default Value "Ok" Tag "YES" To BottonValue
    Pushbutton @ 09,36 width 13 "~C~ancela" CANCEL                    Tag "NO"  To BottonValue

  EndDialog
  If Not RetVal Then QuitLoop EndIf
  
  If IsBlank(VSDGEMPRESA)
     Then Mensagem("Empresa inv lida !")
          Loop
  EndIf
  
  If VSDGOPCAO[2] Or VSDGOPCAO[3] 
     Then Gera_Tabela()
  EndIf
  AGUARDE("Aguarde, exportando dados")
  Produtos()
      
EndWhile
ClearAll
Release Vars All
Release Procs All
