;** ET_0376 ********************************************************************
;** Imprime Etiqueta Personalizada                      ** ATUAL TECIDOS **    *
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido  em: 30/12/2015 por Kamila Gomes
;Alterado      em: 02/02/2016 por Kamila Gomes
;Motivo Alteracao: Ajustes OBS, ART add mais uma linha e REN add na sigla da unidade MT/
;Alterado      em: 17/03/2016 por Bruno Carvalho
;Motivo Alteracao: Ajustado o campo ART, para receber a descricao complementar do item ao inv‚s da descricao do item

;*******************************************************************************
;* Rotina para Impressao do Relatorio                                          *
;*******************************************************************************
Proc IMPETIQUETA()
Private Wh

If VSDGQUAN = BlankNum()
   Then VSDGQUAN = 1
EndIf

COLUNA = VSDGQUAN 
LINHA  = 0

GetRecord "\\Sistemas\\Estoque\\Itens" VSDGITEM To REG_ITEM
If Not RetVal
   Then Mensagem("Item "+VSDGITEM+" n„o encontrado no cadastro de clientes!")
        Return
EndIf   

Print File ARQIMP "\n\n\n\n"

For Wh From 1 To VSDGQUAN

    Print File ARQIMP CI_12CPP
    Print File ARQIMP "\014" 
    
    Switch
      Case COLUNA >= 2 :
           FAZ = 2
           COLUNA = COLUNA - 2
      Case COLUNA = 1 :
           FAZ = 1
           COLUNA = COLUNA - 1
      OtherWise : QuitLoop
    EndSwitch  
    
    For i From 1 To FAZ
      Print File ARQIMP "\014" 
      Print File ARQIMP "\027E"+"  REF: "+"\027F"+Format("W15,AL",Ref_Item)
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(4)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor  
    
    For i From 1 To FAZ 
      Print File ARQIMP "\014" 
      Print File ARQIMP "\027E"+"  ART: "+"\027F"+Format("W15,AL",SubStr(REG_ITEM["Descricao Complementar"],1,15))
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(4)
         Else Print File ARQIMP "\n"
      EndIf
    EndFor
    
    For i From 1 To FAZ  
      Print File ARQIMP "\014"  
      Print File ARQIMP Spaces(07)+Format("W15,AL",SubStr(REG_ITEM["Descricao Complementar"],16,15))
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(4)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor  
    
    For i From 1 To FAZ  
      Print File ARQIMP "\014"  
      Print File ARQIMP Spaces(07)+Format("W15,AL",SubStr(REG_ITEM["Descricao Complementar"],31,15))
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(4)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor 
    
    For i From 1 To FAZ
      Print File ARQIMP "\014" 
      Print File ARQIMP "\027E"+"ORDEM: "+"\027F"+Format("W7,AL",VSDGCOD)+Spaces(01)
                        ;"\027E"+"PRECO: "+"\027F";+"\n" ;Substr(Format("W9.2,EIC",VSDGPRECO),1,9)+"\n" 
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(11)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor 
          
    For i From 1 To FAZ
      Print File ARQIMP "\014"  
      Print File ARQIMP "\027E"+" OBS.: "+"\027F"+Format("W15,AL",SubStr(VSDGNOME,1,15))
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(4)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor 
        
    ;For i From 1 To FAZ
    ;  Print File ARQIMP "\014" 
    ;  Print File ARQIMP Spaces(07)+Format("W15,AL",SubStr(VSDGNOME,16,15))
    ;  If i = 1 And FAZ = 2
    ;     Then Print File ARQIMP Spaces(4)
    ;     Else Print File ARQIMP "\n"
    ;  EndIf   
    ;EndFor 
    
    For i From 1 To FAZ
      Print File ARQIMP "\014"  
      Print File ARQIMP "\027E"+"  REN: "  +"\027F"+Format("W5,AL",Substr(VSDGREND,1,5))+" MT/KG"
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(08)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor 
        
    For i From 1 To FAZ                  
      Print File ARQIMP "\014"                    
      Print File ARQIMP "\027E"+"  PCA: "+"\027F"+Format("W5,AL",Substr(VSDGPEC,1,5))+" MT"
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(11)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor 
        
    For i From 1 To FAZ
      Print File ARQIMP "\014"
      Print File ARQIMP "\027E"+"  LAR: "+"\027F"+Format("W15,AL",Substr(VSDGLARG,1,4))
      If i = 1 And FAZ = 2
         Then Print File ARQIMP Spaces(4)
         Else Print File ARQIMP "\n"
      EndIf   
    EndFor 
    
    Print File ARQIMP CI_12CPP
    Print File ARQIMP CI_6LPP    
    
    LINHA = LINHA + 1
    
    If Wh <> VSDGQUAN  
       Then If LINHA <> 5
               Then Print File ARQIMP "\n\n\n"
               Else Print File ARQIMP "\n\n\n\n\n\n\n\n\n\n\n"
                    LINHA = 0
            EndIf
    EndIf
    
EndFor

EndProc ;IMPETIQUETA()
;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
ARQIMP=PrivDir()+"ET_0352.Txt"
If IsFile(ARQIMP)
   Then Deleta_Arquivo(ARQIMP)
EndIf
AGUARDE("Imprimindo Etiqueta ...")

Ref_Item=""

GetRecord "\\Sistemas\\Estoque\\Itens" VSDGITEM To ET_ITEM
If RetVal
   Then Ref_Item= ET_ITEM["Referencia"]
EndIf

IMPETIQUETA()

;---- Imprime Arquivo Impressao ------------------------------------------------
ImpriArq(ARQIMP)

Release Vars COLUNA, LINHA
Release Procs IMPETIQUETA

LIMPAGUARDE()
