;** ET_0357  *******************************************************************
;** Impressao de Etiqueta c/ Pre‡o - Laser         ** IMPERIO TECIDOS **       *
;** Etiqueta Pimaco Com 2 Colunas e 5 Linhas de Etiqueta (10cm x 5cm)
;*******************************************************************************
;Autor           : Vise Informatica (VISERP)
;Desenvolvido em : 30/09/2014 por Andrey Fillipe
;Ultima Alteracao:   /  /     por  
;Motivo Alteracao: 

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

If QUEBRA_PAGINA > 10
   Then QUEBRA_PAGINA = 2
        Print File ARQIMP "\f"
        Print File ARQIMP "\n\n\n"
EndIf

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


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


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


Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K              
  Print File ARQIMP "LARG.: "+Format("W15",LARG_ITEM[I])+Spaces(03)
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP "\n\n"


Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K              
  Print File ARQIMP "REF..: "+Format("W15",REF_ITEM[I])+Spaces(03)
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP "\n\n"


Print File ARQIMP CI_IEXP
Print File ARQIMP Spaces(01)
For I From 1 to K              
  Print File ARQIMP "ORDEM: "+Format("W15",PRECO_UNITA[I])+Spaces(03)
EndFor
Print File ARQIMP CI_FEXP
Print File ARQIMP "\n\n"


EndProc

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

View "Answer"

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

Array DESCRI_ITEM[2]
Array DESCRI_COMPL_ITEM[2]
Array DESCRI_COMPL_ITEM2[2]
Array LARG_ITEM[2]
Array REF_ITEM[2]
Array PRECO_UNITA[2]

K=0
CONTADOR = 0
QUEBRA_PAGINA = 0                                         

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

While [Quantidade] > CONTADOR      
      CONTADOR = CONTADOR + 1  
      QUEBRA_PAGINA = QUEBRA_PAGINA + 1
      K=K+1                                                       
      DESCRI_ITEM[K]       = [Descricao do Item     ]
      DESCRI_COMPL_ITEM[K] = Substr([Descricao Complementar],1,22)
      DESCRI_COMPL_ITEM2[K]= Substr([Descricao Complementar],23,22)
      LARG_ITEM[K]         = [Codigo Concentrador   ]
      REF_ITEM[K]          = [Referencia            ]
      PRECO_UNITA[K] = "00"+Tira_CharNum([Preco Unitario])
      
      If K=2                    
         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)