;** ET_0355  *******************************************************************
;** Impressao de Etiqueta - Laser              ** ESCAPAMENTO FREITAS **       *
;** Etiqueta com 3 Colunas e 10 Linhas de Etiqueta (6,7cm x 2,5cm)
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido em : 14/10/2015 por Andrey Fillipe
;Ultima Alteracao:   /  /     por  
;Motivo Alteracao: 

;*******************************************************************************
;* Rotina de Impressao das Etiquetas                                           *
;*******************************************************************************
Proc MONTA_ETIQUETA()

If QUEBRA_PAGINA > 30
   Then QUEBRA_PAGINA = 3
        Print File ARQIMP "\f"
        Print File ARQIMP "\n\n\n"
EndIf

Print File ARQIMP CI_INEG
Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K
  Print File ARQIMP Format("W24",DESCRI_COMPL[I])+Spaces(03)  
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP "\n"


Print File ARQIMP CI_INEG
Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K
  Print File ARQIMP Format("W24",DESCRI_COMPL2[I])+Spaces(03)  
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP "\n"


Print File ARQIMP CI_INEG
Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K
  Print File ARQIMP Format("W24,AL",CODIGO_ITEM[I])+Spaces(03)
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP "\n"


Print File ARQIMP CI_INEG
Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K
  Print File ARQIMP Format("W24",DESCRI_MARCA[I])+Spaces(03)  
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP "\n"


Print File ARQIMP CI_INEG
Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K
  Print File ARQIMP Format("W24",DESCRI_GRUPO[I])+Spaces(03)   
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP CI_FNEG
Print File ARQIMP "\n\n"

EndProc

;*******************************************************************************
;* Rotina Principal                                                            *
;*******************************************************************************
If Not IsAssigned(SYS_NOMEMP_DEFAULT) Then SYS_NOMEMP_DEFAULT="" EndIf

View "Answer"

ArqImp=PrivDir()+"Et_0355.Txt"
If IsFile(ArqImp)
   Then Deleta_Arquivo(ARQIMP)
EndIf

Array DESCRI_COMPL[3]
Array DESCRI_COMPL2[3]
Array CODIGO_ITEM[3]
Array DESCRI_MARCA[3]
Array DESCRI_GRUPO[3]

K=0
CONTADOR = 0
QUEBRA_PAGINA = 0                                         

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

While [Quantidade] > CONTADOR      
      CONTADOR = CONTADOR + 1  
      QUEBRA_PAGINA = QUEBRA_PAGINA + 1
      K=K+1                                                       
      
      CODIGO_ITEM[K] = StrVal(NumVal([Codigo do Item]))
      GetRecord "\\Sistemas\\Estoque\\Itens" [Codigo do Item] To ET_ITEM
      If RetVal
         Then DESCRI_COMPL[K]  = Substr(ET_ITEM["Descricao Complementar"],1,24)
              DESCRI_COMPL2[K] = Substr(ET_ITEM["Descricao Complementar"],25,24)
              DESCRI_MARCA[K]  = ET_ITEM["Descricao da Marca"]
              DESCRI_GRUPO[K]  = ET_ITEM["Descricao do Grupo"]
         Else DESCRI_COMPL[K]  = ""
              DESCRI_COMPL2[K] = ""
              DESCRI_MARCA[K]  = ""
              DESCRI_GRUPO[K]  = ""
      EndIf   
      
      If K=3                    
         Then MONTA_ETIQUETA()
              K=0
      EndIf                                  
            
      If [Quantidade] = CONTADOR
         Then CONTADOR = 0
              Skip                      
              If EOT() Then QuitLoop EndIf
      EndIf
EndWhile
                                                                                                           
If K>0
   Then MONTA_ETIQUETA()
EndIf

Print File ARQIMP "\n"

LIMPAGUARDE()

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