PUES, NUEVAMENTE DANDO MOLESTIAS.
DISCULPEN TANTAS PREGUNTAS PERO ES QUE SOY NUEVO EN XAILER Y QUIERO
APRENDERLO BIEN ANTES DE COMPRAR LA LICENCIA. (ES JUSTO ADQUIRIR ESTA
EXCELENTE HERRAMIENTA)
MI PREGUNTA ES COMO PUEDO HACER QUE SE IMPRIMA UNA VENTA EN UNA IMPRESORA DE
TICKETS.
EN OTRO LENGUAJE QUE USO LO HAGO ASI:
DE ECHO PARTE PROCEDE DESDE CLIPPER
PRIMERO ENVIO TODA LA IMPRESION A UN ARCHIVO DE TEXTO
Y DESPUES LO IMPRIMO CON PRINT.EXE
Set Console Off
Set Device To print
Set Print On
SET PRINTER TO DIRECTORIO_TEMPORAL+"texto.txt" && SE ENVIA EL RESULTADO A
UN ARCHIVO DE TEXTO
@ 0,0 SAY ALLTRIM(NOMBRE_DE_LA_EMPRESA)
@ 1,0 SAY ALLTRIM(CALLE_EMPRESA)
@ 2,0 SAY ALLTRIM(COLONIA_EMPRESA)+", "+MUNICIPIO_EMPRESA
@ 3,0 SAY ALLTRIM(CIUDAD_EMPRESA)+", "+ESTADO_EMPRESA
@ 4,0 SAY RFC_EMPRESA
@ 5,0 SAY "DOCUMENTO: "+ALLTRIM(STR(documentof))+" FECHA:
"+DTOC(fecha_final)
@ 6,0 SAY "HORA: "+SUBSTR(TTOC(DATETIME(),2),1,5)+"
"+SUBSTR(TTOC(DATETIME(),2),10,2)+" ** LO ATENDIO: ** "
@ 7,0 SAY VAR_NOMBRE_USUARIO
@ 8,0 say SUBSTR(nombre_cliente,1,30)
@ 9,0 SAY "CANTIDAD"
@ 9,14 SAY "PRECIO"
@ 9,30 SAY "IMPORTE"
@ 10,0 SAY "----------------------------------------"
L=11
SELECT TEMPO
GO TOP
DO WHILE .NOT. EOF()
@ L,0 say substr(descripcion,1,40)
L=L+1
@ L,0 say CANTIDAD PICTURE "#,###.###"
@ L,12 say PRECIO PICT "##,###.##"
@ L,28 say IMPORTE PICT "##,###.##"
L=L+1
skip
enddo
@ L,0 SAY "----------------------------------------"
L=L+1
@ L,11 SAY "VENTA TOTAL:"
@ L,25 SAY var_importe_total PICT "##,###.##"
L=L+1
@ L,11 SAY "PAGADO====>:"
@ L,25 SAY VAR_PAGADO PICT "##,###.##"
L=L+1
@ L,11 SAY "CAMBIO====>:"
@ L,25 SAY VAR_CAMBIO PICT "##,###.##"
L=L+1
@ L,0 SAY IMPORTE_CON_LETRA
L=L+2
@ L,0 SAY "***** GRACIAS POR SU COMPRA *****"
L=L+3
Set Print Off
Set Device To Screen
Set Printer TO ""
Set Console On
**** FUNCION PARA IMPRIMIR EL ARCHIVO DE TEXTO
Declare Long WinExec In kernel32 STRING lpCmdLine , Long nCmdShow
cCmd ="print.exe "+ DIRECTORIO_TEMPORAL+"texto.txt"
=WinExec(cCmd, 0)
*********
POR FAVOR AYUDENME.
GRACIAS POR TODA LA AYUDA PROPORCIONADA
In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.
IMPRIMIR TICKETS
-
- Mensajes: 19
- Registrado: Vie Abr 06, 2007 3:46 am
- Carlos Ortiz
- Mensajes: 873
- Registrado: Mié Jul 01, 2009 5:44 pm
- Ubicación: Argentina - Córdoba
- Contactar:
IMPRIMIR TICKETS
Estimado Pedro, lo immprimis asi por algo en particular?, por que no directamente a la impresora? sera USB talvez.
Mas alla de muchas dudas que me dejas planteadas por esa metodologia te digo que no creo que tengas problemas con generar impresiones de ticket partiendo de que si no usas el REPORT nativo de Xailer tambien tenes otras alternativas, hay un ejemplo echo por Ignacio donde imprime comprobantes dibujando todo a medida, también existe la clase tImprime de Rafa (pido disculas si me equivoco u omito algun propietario) que te prmite emitir ticket / facturas y demas con el formato que quieras incluyendo graficos y codigos de barras ( de hecho estoy terminando algo de eso )
Pues para mi no creo que tengas problemas en función de alguna duda que se te puede estar planteando, quizas te falte mas testeo. Sumado a esto te comento que los colegas del foro son una masa en todo sentido.
Vuelvo a aclarar que soy novato con Xailer hara un mes que estoy haciendo algo en el poco tiempo que me queda y estoy muy conforme.
Atte. Carlos Ortiz.
Argentina
--
Mas alla de muchas dudas que me dejas planteadas por esa metodologia te digo que no creo que tengas problemas con generar impresiones de ticket partiendo de que si no usas el REPORT nativo de Xailer tambien tenes otras alternativas, hay un ejemplo echo por Ignacio donde imprime comprobantes dibujando todo a medida, también existe la clase tImprime de Rafa (pido disculas si me equivoco u omito algun propietario) que te prmite emitir ticket / facturas y demas con el formato que quieras incluyendo graficos y codigos de barras ( de hecho estoy terminando algo de eso )
Pues para mi no creo que tengas problemas en función de alguna duda que se te puede estar planteando, quizas te falte mas testeo. Sumado a esto te comento que los colegas del foro son una masa en todo sentido.
Vuelvo a aclarar que soy novato con Xailer hara un mes que estoy haciendo algo en el poco tiempo que me queda y estoy muy conforme.
Atte. Carlos Ortiz.
Argentina
--
@dbfarma
www.dbfarma.com.ar
www.dbfarma.com.ar
-
- Mensajes: 1310
- Registrado: Mié Sep 26, 2007 7:12 pm
IMPRIMIR TICKETS
**************************************
* *
* IMPRESION DE TICKETS *
* IMPRESION DE VALES *
* IMPRESION DE RESERVAS *
* APERTURA DE CAJÓN MONEDAS *
* *
* WFACTU PC WINDOWS * TICKET.PRG
* *
* MUNGIA INFORMÁTICA BINGEN 2.003-05 *
* *
**************************************
#Include "fivewin.ch"
#Include "report.ch"
*****************************************
* IMPRIMIR TICKETS ENTRE VARIOS TIPOS *
*****************************************
Function PrinTicket(nTicket,lTest,lAbreCajon,lPantalla)
Local oDataStruc:=tDbfStruc():New()
Local oVargen,oAgentes, oCabecera, oLineas, oEmpresa
Local nTipoTicket:=0, nAncho:=0
Default lTest:=.F., lAbreCajon:=.T. , lPantalla:=.F.
//APERTURA DE FICHEROS
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
oAgentes :=oDataStruc:Use("Agentes")
oCabecera :=oDataStruc:Use("TPVCAB")
oLineas :=oDataStruc:Use("TPVLIN")
oEmpresa :=oDataStruc:Use("Empresa")
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
//Ver si se ha de imprimir
If !oVargen:TicketImp
oDataStruc:Close()
Return Nil
Endif
//Si es una prueba
If lTest
oCabecera:GoBottom()
nTicket:=oCabecera:Numero
Endif
//Buscar cabecera de ticket
If !oCabecera:Seek(StrZero(nTicket,6))
MsgInfo("Nº de Ticket "+StrZero(nTicket,6)+" no encontrado para impresión de ticket","ERROR")
oDataStruc:Close()
Return Nil
Endif
//Buscar lineas de Ticket
Select(oLineas:cAlias)
oLineas:Scope( STRZERO(oCabecera:NUMERO,6) , STRZERO(oCabecera:NUMERO,6) )
nTipoTicket:=If(oVargen:TipoTicket=0,1,oVargen:TipoTicket)
nAncho:=If(oVargen:TickAncho>0,oVargen:TickAncho,40)
//Imprimir ticket del tipo 1
If nTipoTicket = 1
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Cantidad Articulo Precio" ); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Transform(oLineas:Cantidad,"@E 999.99")+" "+;
Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,24))+ " "+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 9,999.99") )
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ); oTicket:LineSkip()
Endif
oTicket:LineSkip()
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Imprimir ticket del tipo 2
If nTipoTicket = 2
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Ud x PVP Ud Articulo"); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,100))) ; oTicket:LineSkip()
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ) ; oTicket:LineSkip()
Endif
oTicket:Say( Transform(oLineas:Cantidad,"@E 9,999.9")+" Ud. X "+;
Transform(oLineas:Precio+(oLineas:Precio*(oLineas:TXC_IVA/10 0)), "@E 9,999.99")+" = "+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 99,999.99"))
oTicket:LineSkip()
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Imprimir ticket del tipo 3
If nTipoTicket = 3
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Ud x B.I. Ud. + % IVA Articulo"); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,24))+ " "+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 9,999.99")) ; oTicket:LineSkip()
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ); oTicket:LineSkip()
Endif
oTicket:Say( Transform(oLineas:Cantidad,"@E 999.9")+" X "+;
Transform(oLineas:Precio,"@E 999.99")+"Ud.="+;
Transform(oLineas:Cantidad*oLineas:Precio,"@E 999.99")+" + "+;
Transform(oLineas:TXC_IVA,"@E 99")+"%IVA "+Transform(oLineas:Importe*(oLineas:TXC_IVA/100),"@E 999.99"))
oTicket:LineSkip(2)
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Imprimir ticket del tipo 4
If nTipoTicket = 4
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Cant. Prec. Concepto Suma"); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Transform(oLineas:Cantidad,"@E 999.9")+" X "+;
Transform(oLineas:Precio+(oLineas:Precio*(oLineas:TXC_IVA/10 0)), "@E 999.99")+" "+;
Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,21))+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 999.99") )
oTicket:LineSkip()
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ); oTicket:LineSkip(2)
Endif
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Controlar tipo de ticket erroneo
If nTipoTicket > 4
MsgInfo("El tipo de ticket "+Alltrim(Str(nTipoTicket))+" No es válido (1-4)","ERROR")
Endif
oDataStruc:Close()
Return Nil
***************************************
* IMPRIMIR VALES ENTRE VARIOS TIPOS *
***************************************
Function PRINTVALE(nVale,lTest,lAbreCajon,lPantalla)
Local oDataStruc:=tDbfStruc():New()
Local oVargen, oCabecera, oEmpresa, oAgentes
Local nTipoVale:=0, nAncho:=0
Default lTest:=.F., lAbreCajon:=.T. , lPantalla:=.F.
//APERTURA DE FICHEROS
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
oAgentes :=oDataStruc:Use("Agentes")
oCabecera :=oDataStruc:Use("VALES")
oEmpresa :=oDataStruc:Use("Empresa")
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
//Ver si se ha de imprimir
If !oVargen:ValeImp
oDataStruc:Close()
Return Nil
Endif
//Si es una prueba
If lTest
oCabecera:GoBottom()
nVale:=oCabecera:Numero
Endif
//Buscar cabecera de Vale
If !oCabecera:Seek(StrZero(nVale,6))
MsgInfo("Nº de Vale "+StrZero(nVale,6)+" no encontrado para impresión de Vale","ERROR")
oDataStruc:Close()
Return Nil
Endif
nTipoVale:=1
nAncho:=If(oVargen:TickAncho>0,oVargen:TickAncho,40)
//Imprimir Vale del tipo 1
If nTipoVale = 1
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del Vale
oTicket:Say( "Vale No: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))); oTicket:LineSkip()
oTicket:Say( "Fecha : "+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) ); oTicket:LineSkip(2)
//Impresión de totales
oTicket:Say( "TOTAL VALE:",2,1 ); oTicket:LineSkip()
oTicket:Say( Transform(oCabecera:Importe,"@E 999,999.99")+oTicket:Euro(),2,1 ); oTicket:LineSkip()
//Lineas de información extra
If(!EMPTY(oVargen:Vale_L1),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L1,,1 )),)
If(!EMPTY(oVargen:Vale_L2),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L2,,1 )),)
If(!EMPTY(oVargen:Vale_L3),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L3,,1 )),)
If(!EMPTY(oVargen:Vale_L4),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Controlar tipo de Vale erroneo
If nTipoVale > 1
MsgInfo("El tipo de Vale "+Alltrim(Str(nTipoVale))+" No es válido","ERROR")
Endif
oDataStruc:Close()
Return Nil
******************************************
* IMPRIMIR RESERVAS ENTRE VARIOS TIPOS *
******************************************
Function PRINTRESERVA(nReserva,lTest,lAbreCajon,lPantalla)
Local oDataStruc:=tDbfStruc():New()
Local oVargen, oCabecera, oEmpresa
Local nTipoReserva:=0, nAncho:=0
Default lTest:=.F., lAbreCajon:=.T. , lPantalla:=.F.
//APERTURA DE FICHEROS
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
oCabecera :=oDataStruc:Use("Reservas")
oEmpresa :=oDataStruc:Use("Empresa")
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
//Ver si se ha de imprimir
If !oVargen:ReservaImp
oDataStruc:Close()
Return Nil
Endif
//Si es una prueba
If lTest
oCabecera:GoBottom()
nReserva:=oCabecera:Codigo
Endif
//Buscar cabecera de Reserva
If !oCabecera:Seek(StrZero(nReserva,6))
MsgInfo("Nº de Reserva "+StrZero(nReserva,6)+" no encontrado para impresión de Reserva","ERROR")
oDataStruc:Close()
Return Nil
Endif
nTipoReserva:=1
nAncho:=If(oVargen:TickAncho>0,oVargen:TickAncho,40)
//Imprimir Reserva del tipo 1
If nTipoReserva = 1
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del vale
oTicket:Say( "RESERVA No: "+ALLTRIM(cVALTOCHAR(oCabecera:Codigo))+" "+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) ); oTicket:LineSkip(2)
oTicket:Say( "Articulo : "+oCabecera:Cod_Art); oTicket:LineSkip()
oTicket:Say( STr(oCabecera:Cantidad)+" "+oCabecera:Articulo); oTicket:LineSkip(2)
//Impresión de totales
oTicket:Say( "PVP IVA Incluido: "+Transform(oCabecera:PVP,"@E 99,999.99")+oTicket:Euro() ); oTicket:LineSkip()
oTicket:Say( "Anticipo Reserva: "+Transform(oCabecera:Importe,"@E 99,999.99")+oTicket:Euro(),,,.T. ); oTicket:LineSkip()
oTicket:Say( "Resto a pagar: "+Transform(oCabecera:PVP-oCabecera:Importe,"@E 99,999.99")+oTicket:Euro() ); oTicket:LineSkip()
//Lineas de información extra
If(!EMPTY(oVargen:Reserv_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L1,,1 )),)
If(!EMPTY(oVargen:Reserv_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L2,,1 )),)
If(!EMPTY(oVargen:Reserv_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L3,,1 )),)
If(!EMPTY(oVargen:Reserv_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L4,,1 )),)
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Controlar tipo de Reserva erroneo
If nTipoReserva > 1
MsgInfo("El tipo de Reserva "+Alltrim(Str(nTipoReserva))+" No es válido","ERROR")
Endif
oDataStruc:Close()
Return Nil
Function AbreCajon()
Local oTicket, oVargen
Local oDataStruc:=tDbfStruc():New()
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
oTicket:=tEpson():New()
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
oTicket:OpenCash()
oTicket:End()
oDataStruc:Close()
Return Nil
Static Function AbreCom(cPuerto,cCodigo)
Local cDcb, nBytes
Local nComm := OpenComm(cPuerto, 1024, 128 )
Local nError
If ! BuildCommDcb(cPuerto+":9600,n,8,1", @cDcb )
nError = GetCommError( nComm )
MsgInfo("Error al configurar el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
If ! SetCommState( cDcb )
nError = GetCommError( nComm )
MsgInfo("Error al comunicar con el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
If nBytes := (WriteComm(nComm,cCodigo))< 0
nError=GetCommError(nComm)
MsgInfo("Error al escribir en el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
If ! CloseComm( nComm )
nError = GetCommError( nComm )
MsgInfo("Error al cerrar el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
Return .T.
Static Function AbreLpt(cPuerto,cCodigo)
nFp := fcreate( cPuerto,0 )
fWrite( nFp, cCodigo)
fClose( nFp )
Return Nil
/*********************************************************** ********************
CLASS tEpson
Manage POS Epson printer such as TM series directly via ESC codes
Mungia Informática S.L. 2004 Bingen bingen@muninser.com
************************************************************ *******************/
CLASS TEpson
DATA nFontBase AS NUMERIC //0=10cpp 1=12cpp
DATA cTextPrn AS CHARACTER
DATA cTextScr AS CHARACTER
DATA lToScreen AS LOGICAL
DATA cFileTxt AS CHARACTER
DATA cCashCode AS CHARACTER
DATA cPrnPort AS CHARACTER
METHOD New( ) CONSTRUCTOR
METHOD LineSkip( )
METHOD Say( cSay,nFont,nPos,lClrRed )
METHOD Euro()
METHOD Cut( lPartial )
METHOD OpenCash( )
METHOD End( )
ENDCLASS
//---------------------------------------------------------- ------------------//
METHOD New( ) CLASS TEpson
LOCAL cNotValid:=" / : * ? ¿ < > { } | · . ÑNñnÁAÉEÍIÓOÚUáaéeíióoúu", nItem:=0
::cTextPrn :=""
* ::cTextPrn+=Chr(27)+Chr(64) //Initialize printer
::cTextScr :=""
::lToScreen :=.F.
::nFontBase :=0
::cCashCode :="27,112,0,25,250"
::cPrnPort :="COM2:"
//Name of temporal text file
::cFileTxt :=Alltrim(WNetGetUser())
//Keep out not valid characters
For nItem:=1 To Len(cNotValid) STEP 2
::cFileTxt:=StrTran(::cFileTxt,SUBSTR(cNotValid,nItem,1),SUB STR(cNotValid,nItem+1,1))
Next
//Keep out rare characters
For nItem:=123 To 255
::cFileTxt:=StrTran(::cFileTxt,Chr(nItem),"")
Next
::cFileTxt:=Left(Alltrim(StrTran(::cFileTxt," ","")),8)
::cFileTxt:=PADL(::cFileTxt,8,"_")+".Txt"
Return Self
//---------------------------------------------------------- ------------------//
METHOD LineSkip( nSkip ) CLASS TEpson
Local nItem:=0
Default nSkip:=1
If nSkip>0
::cTextPrn+=Chr(27)+Chr(100)+Chr(nSkip)
For nItem:=1 To nSKip
::cTextScr+=Chr(13)+Chr(10)
Next
Else
::cTextPrn+=Chr(27)+Chr(101)+Chr(nSkip)
Endif
Return Nil
//---------------------------------------------------------- ------------------//
/* cSay Text to say
nFont 0=Normal 1=Compressed 2=Doble
nPos 0=Left 1=Center 2=Right
lBold Bold Text
lUnder Underlined Text
lClrRed Print text with red color (only if printer is capable)
*/
METHOD Say( cSay,nFont,nPos,lBold,lUnder,lClrRed ) CLASS TEpson
Local nFontType:=0
Default nPos:=0, nFont:=0, lBold:=.F., lUnder:=.F., lClrRed:=.F.
//Font Type, Bold, Underlined
Do Case
Case nFont=0
nFontType:=::nFontBase
Case nFont=1
nFontType:=4
Case nFont=2
nFontType:=16+32
EndCase
nFontType+=If(lBold,8,0)
nFontType+=If(lUnder,128,0)
::cTextPrn+=Chr(27)+Chr(33)+Chr(nFontType)
//Activate Red Color
If lClrRed
::cTextPrn+=Chr(27)+Chr(114)+Chr(1)
Else
::cTextPrn+=Chr(27)+Chr(114)+Chr(0)
Endif
//Alignement
::cTextPrn+=Chr(27)+Chr(97)+Chr(nPos)
//Say Text
::cTextPrn+=Alltrim(cSay)
::cTextScr+=Alltrim(cSay)
Return Nil
//---------------------------------------------------------- ------------------//
METHOD Euro( ) CLASS TEpson
Return If(::lToScreen,Chr(128),Chr(27)+Chr(116)+Chr(19)+Chr(213))
//---------------------------------------------------------- ------------------//
METHOD Cut( lPartial ) CLASS TEpson
Default lPartial:=.T.
::LineSkip( 2 )
::cTextPrn+=Chr(27)+If(lPartial,Chr(109),Chr(105))
Return Nil
//---------------------------------------------------------- ------------------//
/*
Apertura del cajón portamonedas
Secuencias de códigos para apertura de cajón portamonedas
27,112,0,25,250 (EPSON TM Standar)
27,112,0,100,250
27,112,0,100,255
27,112,0,50,100
27,112,0,50,150
27,112,0,100,250
27,112,0,10,100
*/
METHOD OpenCash( ) CLASS TEpson
Local cOpenCode, aCodigo:={}
If Len(Alltrim(::cCashCode))=0
::cTextPrn+=Chr(27)+Chr(112)+Chr(0)+Chr(25)+Chr(250)
Else
//Calculate the open code
cOpenCode:=::cCashCode
cOpenCode:=IF(RIGHT(cOpenCode,1)=",",cOpenCode,cOpenCode+", ")
Do While AT(",",cOpenCode)>0
AADD(aCodigo,ALLTRIM(LEFT(cOpenCode,AT(",",cOpenCode)-1)))
cOpenCode:=SUBSTR(cOpenCode,AT(",",cOpenCode)+1)
EndDo
cOpenCode:=""
For nItem:=1 to Len(aCodigo)
cOpenCode:=cOpenCode+Chr(Val(aCodigo[nItem]))
Next
::cTextPrn+=cOpenCode
Endif
Return Nil
//---------------------------------------------------------- ------------------//
METHOD End() CLASS TEpson
If !File("PrTicket.Bat")
MEMOWRIT("PrTicket.Bat","Mode "+::cPrnPort+"9600,n,8,1"+CRLF+"TYPE %1 >%2"+CRLF+"DEL %1")
Endif
If ::lToScreen
MEMOWRIT(::cFileTxt,::cTextScr)
WaitRun("notepad "+::cFileTxt)
FErase(::cFileTxt)
Else
MEMOWRIT(::cFileTxt,::cTextPrn)
ShellExecute( ,,"PrTicket.Bat",::cFileTxt+" "+::cPrnPort,,0)
Endif
Return Self
--
* *
* IMPRESION DE TICKETS *
* IMPRESION DE VALES *
* IMPRESION DE RESERVAS *
* APERTURA DE CAJÓN MONEDAS *
* *
* WFACTU PC WINDOWS * TICKET.PRG
* *
* MUNGIA INFORMÁTICA BINGEN 2.003-05 *
* *
**************************************
#Include "fivewin.ch"
#Include "report.ch"
*****************************************
* IMPRIMIR TICKETS ENTRE VARIOS TIPOS *
*****************************************
Function PrinTicket(nTicket,lTest,lAbreCajon,lPantalla)
Local oDataStruc:=tDbfStruc():New()
Local oVargen,oAgentes, oCabecera, oLineas, oEmpresa
Local nTipoTicket:=0, nAncho:=0
Default lTest:=.F., lAbreCajon:=.T. , lPantalla:=.F.
//APERTURA DE FICHEROS
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
oAgentes :=oDataStruc:Use("Agentes")
oCabecera :=oDataStruc:Use("TPVCAB")
oLineas :=oDataStruc:Use("TPVLIN")
oEmpresa :=oDataStruc:Use("Empresa")
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
//Ver si se ha de imprimir
If !oVargen:TicketImp
oDataStruc:Close()
Return Nil
Endif
//Si es una prueba
If lTest
oCabecera:GoBottom()
nTicket:=oCabecera:Numero
Endif
//Buscar cabecera de ticket
If !oCabecera:Seek(StrZero(nTicket,6))
MsgInfo("Nº de Ticket "+StrZero(nTicket,6)+" no encontrado para impresión de ticket","ERROR")
oDataStruc:Close()
Return Nil
Endif
//Buscar lineas de Ticket
Select(oLineas:cAlias)
oLineas:Scope( STRZERO(oCabecera:NUMERO,6) , STRZERO(oCabecera:NUMERO,6) )
nTipoTicket:=If(oVargen:TipoTicket=0,1,oVargen:TipoTicket)
nAncho:=If(oVargen:TickAncho>0,oVargen:TickAncho,40)
//Imprimir ticket del tipo 1
If nTipoTicket = 1
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Cantidad Articulo Precio" ); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Transform(oLineas:Cantidad,"@E 999.99")+" "+;
Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,24))+ " "+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 9,999.99") )
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ); oTicket:LineSkip()
Endif
oTicket:LineSkip()
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Imprimir ticket del tipo 2
If nTipoTicket = 2
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Ud x PVP Ud Articulo"); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,100))) ; oTicket:LineSkip()
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ) ; oTicket:LineSkip()
Endif
oTicket:Say( Transform(oLineas:Cantidad,"@E 9,999.9")+" Ud. X "+;
Transform(oLineas:Precio+(oLineas:Precio*(oLineas:TXC_IVA/10 0)), "@E 9,999.99")+" = "+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 99,999.99"))
oTicket:LineSkip()
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Imprimir ticket del tipo 3
If nTipoTicket = 3
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Ud x B.I. Ud. + % IVA Articulo"); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,24))+ " "+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 9,999.99")) ; oTicket:LineSkip()
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ); oTicket:LineSkip()
Endif
oTicket:Say( Transform(oLineas:Cantidad,"@E 999.9")+" X "+;
Transform(oLineas:Precio,"@E 999.99")+"Ud.="+;
Transform(oLineas:Cantidad*oLineas:Precio,"@E 999.99")+" + "+;
Transform(oLineas:TXC_IVA,"@E 99")+"%IVA "+Transform(oLineas:Importe*(oLineas:TXC_IVA/100),"@E 999.99"))
oTicket:LineSkip(2)
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Imprimir ticket del tipo 4
If nTipoTicket = 4
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del ticket
oTicket:Say( "Ticket: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))+" Fecha:"+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) )
oTicket:LineSkip()
//Impresión de líneas
oTicket:Say( "Cant. Prec. Concepto Suma"); oTicket:LineSkip()
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
Do While !oLineas:Eof()
oTicket:Say( Transform(oLineas:Cantidad,"@E 999.9")+" X "+;
Transform(oLineas:Precio+(oLineas:Precio*(oLineas:TXC_IVA/10 0)), "@E 999.99")+" "+;
Left(oLineas:Detalle,If(oVargen:TicketDetL>0,oVargen:TicketDetL,21))+;
Transform(oLineas:Importe+(oLineas:Importe*(oLineas:TXC_IVA/ 100)), "@E 999.99") )
oTicket:LineSkip()
If oLineas:TXC_Dto>0
oTicket:Say( Transform(oLineas:TXC_Dto,"@E 99.99")+"% Dto. "+;
Transform(oLineas:Importe*(oLineas:TXC_Dto/100),"@E 9,999.99") ); oTicket:LineSkip(2)
Endif
oLineas:Skip()
EndDo
//Impresión de totales
oTicket:Say( Replicate("-",nAncho) ); oTicket:LineSkip()
oTicket:Say( "TOTAL VENTA: "+Transform(oCabecera:TotalPagar,"@E 99,999.99")+oTicket:Euro(),,,.T. ) ;oTicket:LineSkip(2)
//Desglose de IVAs
oTicket:Say( "Desglose de IVA Incluido:") ;oTicket:LineSkip()
If oCabecera:TotIva1<>0
oTicket:Say( Transform(oCabecera:IVA_Sup,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp1,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva1,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva2<>0
oTicket:Say( Transform(oCabecera:IVA_Red,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp2,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva2,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva3<>0
oTicket:Say( Transform(oCabecera:IVA_Gen,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp3,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva3,"@E 999.99") )
oTicket:LineSkip()
Endif
If oCabecera:TotIva4<>0
oTicket:Say( Transform(oCabecera:IVA_Agr,"@E 99.99")+"% B.I. "+Transform(oCabecera:BaseImp4,"@E 999.99")+" Iva "+Transform(oCabecera:TotIva4,"@E 999.99") )
oTicket:LineSkip()
Endif
//Lineas de información extra
If(!EMPTY(oVargen:TICKET_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L1,,1 )),)
If(!EMPTY(oVargen:TICKET_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L2,,1 )),)
If(!EMPTY(oVargen:TICKET_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L3,,1 )),)
If(!EMPTY(oVargen:TICKET_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:TICKET_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Controlar tipo de ticket erroneo
If nTipoTicket > 4
MsgInfo("El tipo de ticket "+Alltrim(Str(nTipoTicket))+" No es válido (1-4)","ERROR")
Endif
oDataStruc:Close()
Return Nil
***************************************
* IMPRIMIR VALES ENTRE VARIOS TIPOS *
***************************************
Function PRINTVALE(nVale,lTest,lAbreCajon,lPantalla)
Local oDataStruc:=tDbfStruc():New()
Local oVargen, oCabecera, oEmpresa, oAgentes
Local nTipoVale:=0, nAncho:=0
Default lTest:=.F., lAbreCajon:=.T. , lPantalla:=.F.
//APERTURA DE FICHEROS
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
oAgentes :=oDataStruc:Use("Agentes")
oCabecera :=oDataStruc:Use("VALES")
oEmpresa :=oDataStruc:Use("Empresa")
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
//Ver si se ha de imprimir
If !oVargen:ValeImp
oDataStruc:Close()
Return Nil
Endif
//Si es una prueba
If lTest
oCabecera:GoBottom()
nVale:=oCabecera:Numero
Endif
//Buscar cabecera de Vale
If !oCabecera:Seek(StrZero(nVale,6))
MsgInfo("Nº de Vale "+StrZero(nVale,6)+" no encontrado para impresión de Vale","ERROR")
oDataStruc:Close()
Return Nil
Endif
nTipoVale:=1
nAncho:=If(oVargen:TickAncho>0,oVargen:TickAncho,40)
//Imprimir Vale del tipo 1
If nTipoVale = 1
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del Vale
oTicket:Say( "Vale No: "+ALLTRIM(cVALTOCHAR(oCabecera:Numero))); oTicket:LineSkip()
oTicket:Say( "Fecha : "+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) ); oTicket:LineSkip(2)
//Impresión de totales
oTicket:Say( "TOTAL VALE:",2,1 ); oTicket:LineSkip()
oTicket:Say( Transform(oCabecera:Importe,"@E 999,999.99")+oTicket:Euro(),2,1 ); oTicket:LineSkip()
//Lineas de información extra
If(!EMPTY(oVargen:Vale_L1),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L1,,1 )),)
If(!EMPTY(oVargen:Vale_L2),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L2,,1 )),)
If(!EMPTY(oVargen:Vale_L3),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L3,,1 )),)
If(!EMPTY(oVargen:Vale_L4),(oTicket:LineSkip(),oTicket:Say( oVargen:Vale_L4,,1 )),)
//Linea de vendedor
If !EMPTY(oVargen:TickNomVen) .And. oAgentes:SEEK(STRZERO(oCabecera:Agente,8))
oTicket:LineSkip(2)
oTicket:Say( "Le atendio: "+Alltrim(oAgentes:Nombre) )
ENDIF
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Controlar tipo de Vale erroneo
If nTipoVale > 1
MsgInfo("El tipo de Vale "+Alltrim(Str(nTipoVale))+" No es válido","ERROR")
Endif
oDataStruc:Close()
Return Nil
******************************************
* IMPRIMIR RESERVAS ENTRE VARIOS TIPOS *
******************************************
Function PRINTRESERVA(nReserva,lTest,lAbreCajon,lPantalla)
Local oDataStruc:=tDbfStruc():New()
Local oVargen, oCabecera, oEmpresa
Local nTipoReserva:=0, nAncho:=0
Default lTest:=.F., lAbreCajon:=.T. , lPantalla:=.F.
//APERTURA DE FICHEROS
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
oCabecera :=oDataStruc:Use("Reservas")
oEmpresa :=oDataStruc:Use("Empresa")
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
//Ver si se ha de imprimir
If !oVargen:ReservaImp
oDataStruc:Close()
Return Nil
Endif
//Si es una prueba
If lTest
oCabecera:GoBottom()
nReserva:=oCabecera:Codigo
Endif
//Buscar cabecera de Reserva
If !oCabecera:Seek(StrZero(nReserva,6))
MsgInfo("Nº de Reserva "+StrZero(nReserva,6)+" no encontrado para impresión de Reserva","ERROR")
oDataStruc:Close()
Return Nil
Endif
nTipoReserva:=1
nAncho:=If(oVargen:TickAncho>0,oVargen:TickAncho,40)
//Imprimir Reserva del tipo 1
If nTipoReserva = 1
oTicket:=tEpson():New()
oTicket:nFontBase:=oVargen:TicketFont
oTicket:lToScreen:=lPantalla
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
//Apertura del cajón
If(lAbreCajon,oTicket:OpenCash( ),)
//Relleno inicial en lineas
oTicket:LineSkip(oVargen:TicketBeg)
//Cabecera datos de la empresa
oTicket:Say( oEmpresa:NombreCom,2,1,.T. ); oTicket:LineSkip()
If(oEmpresa:NombreCom<>oEmpresa:Nombre,(oTicket:Say( oEmpresa:Nombre,,1,.T. ),oTicket:LineSkip()), )
oTicket:Say( "NIF: "+oEmpresa:CIFDNI,0,1,.T. ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Domicilio,,1 ); oTicket:LineSkip()
oTicket:Say( oEmpresa:Poblacion,,1 ); oTicket:LineSkip()
oTicket:Say( "Tlf:"+oEmpresa:Telefono,,1 ); oTicket:LineSkip(2)
//Cabecera del vale
oTicket:Say( "RESERVA No: "+ALLTRIM(cVALTOCHAR(oCabecera:Codigo))+" "+FECHACORTA(oCabecera:Fecha)+" "+Left(Time(),5) ); oTicket:LineSkip(2)
oTicket:Say( "Articulo : "+oCabecera:Cod_Art); oTicket:LineSkip()
oTicket:Say( STr(oCabecera:Cantidad)+" "+oCabecera:Articulo); oTicket:LineSkip(2)
//Impresión de totales
oTicket:Say( "PVP IVA Incluido: "+Transform(oCabecera:PVP,"@E 99,999.99")+oTicket:Euro() ); oTicket:LineSkip()
oTicket:Say( "Anticipo Reserva: "+Transform(oCabecera:Importe,"@E 99,999.99")+oTicket:Euro(),,,.T. ); oTicket:LineSkip()
oTicket:Say( "Resto a pagar: "+Transform(oCabecera:PVP-oCabecera:Importe,"@E 99,999.99")+oTicket:Euro() ); oTicket:LineSkip()
//Lineas de información extra
If(!EMPTY(oVargen:Reserv_L1),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L1,,1 )),)
If(!EMPTY(oVargen:Reserv_L2),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L2,,1 )),)
If(!EMPTY(oVargen:Reserv_L3),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L3,,1 )),)
If(!EMPTY(oVargen:Reserv_L4),(oTicket:LineSkip(),oTicket:Say ( oVargen:Reserv_L4,,1 )),)
//Relleno final en lineas
oTicket:LineSkip(oVargen:TicketEnd)
//Corte parcial del papel
oTicket:Cut()
//Finalización e impresión del Ticket
oTicket:End()
EndIf
//Controlar tipo de Reserva erroneo
If nTipoReserva > 1
MsgInfo("El tipo de Reserva "+Alltrim(Str(nTipoReserva))+" No es válido","ERROR")
Endif
oDataStruc:Close()
Return Nil
Function AbreCajon()
Local oTicket, oVargen
Local oDataStruc:=tDbfStruc():New()
oVargen :=oDataStruc:Use("Vargen",,,,,,.T.)
If oDataStruc:lError
oDataStruc:Close()
Return Nil
ENDIF
oTicket:=tEpson():New()
oTicket:cCashCode:=Alltrim(oVargen:SecApertur)
oTicket:cPrnPort :=Alltrim(oVargen:ImpTicket)
oTicket:OpenCash()
oTicket:End()
oDataStruc:Close()
Return Nil
Static Function AbreCom(cPuerto,cCodigo)
Local cDcb, nBytes
Local nComm := OpenComm(cPuerto, 1024, 128 )
Local nError
If ! BuildCommDcb(cPuerto+":9600,n,8,1", @cDcb )
nError = GetCommError( nComm )
MsgInfo("Error al configurar el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
If ! SetCommState( cDcb )
nError = GetCommError( nComm )
MsgInfo("Error al comunicar con el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
If nBytes := (WriteComm(nComm,cCodigo))< 0
nError=GetCommError(nComm)
MsgInfo("Error al escribir en el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
If ! CloseComm( nComm )
nError = GetCommError( nComm )
MsgInfo("Error al cerrar el puerto: "+cPuerto+Str(nError))
Return .F.
Endif
Return .T.
Static Function AbreLpt(cPuerto,cCodigo)
nFp := fcreate( cPuerto,0 )
fWrite( nFp, cCodigo)
fClose( nFp )
Return Nil
/*********************************************************** ********************
CLASS tEpson
Manage POS Epson printer such as TM series directly via ESC codes
Mungia Informática S.L. 2004 Bingen bingen@muninser.com
************************************************************ *******************/
CLASS TEpson
DATA nFontBase AS NUMERIC //0=10cpp 1=12cpp
DATA cTextPrn AS CHARACTER
DATA cTextScr AS CHARACTER
DATA lToScreen AS LOGICAL
DATA cFileTxt AS CHARACTER
DATA cCashCode AS CHARACTER
DATA cPrnPort AS CHARACTER
METHOD New( ) CONSTRUCTOR
METHOD LineSkip( )
METHOD Say( cSay,nFont,nPos,lClrRed )
METHOD Euro()
METHOD Cut( lPartial )
METHOD OpenCash( )
METHOD End( )
ENDCLASS
//---------------------------------------------------------- ------------------//
METHOD New( ) CLASS TEpson
LOCAL cNotValid:=" / : * ? ¿ < > { } | · . ÑNñnÁAÉEÍIÓOÚUáaéeíióoúu", nItem:=0
::cTextPrn :=""
* ::cTextPrn+=Chr(27)+Chr(64) //Initialize printer
::cTextScr :=""
::lToScreen :=.F.
::nFontBase :=0
::cCashCode :="27,112,0,25,250"
::cPrnPort :="COM2:"
//Name of temporal text file
::cFileTxt :=Alltrim(WNetGetUser())
//Keep out not valid characters
For nItem:=1 To Len(cNotValid) STEP 2
::cFileTxt:=StrTran(::cFileTxt,SUBSTR(cNotValid,nItem,1),SUB STR(cNotValid,nItem+1,1))
Next
//Keep out rare characters
For nItem:=123 To 255
::cFileTxt:=StrTran(::cFileTxt,Chr(nItem),"")
Next
::cFileTxt:=Left(Alltrim(StrTran(::cFileTxt," ","")),8)
::cFileTxt:=PADL(::cFileTxt,8,"_")+".Txt"
Return Self
//---------------------------------------------------------- ------------------//
METHOD LineSkip( nSkip ) CLASS TEpson
Local nItem:=0
Default nSkip:=1
If nSkip>0
::cTextPrn+=Chr(27)+Chr(100)+Chr(nSkip)
For nItem:=1 To nSKip
::cTextScr+=Chr(13)+Chr(10)
Next
Else
::cTextPrn+=Chr(27)+Chr(101)+Chr(nSkip)
Endif
Return Nil
//---------------------------------------------------------- ------------------//
/* cSay Text to say
nFont 0=Normal 1=Compressed 2=Doble
nPos 0=Left 1=Center 2=Right
lBold Bold Text
lUnder Underlined Text
lClrRed Print text with red color (only if printer is capable)
*/
METHOD Say( cSay,nFont,nPos,lBold,lUnder,lClrRed ) CLASS TEpson
Local nFontType:=0
Default nPos:=0, nFont:=0, lBold:=.F., lUnder:=.F., lClrRed:=.F.
//Font Type, Bold, Underlined
Do Case
Case nFont=0
nFontType:=::nFontBase
Case nFont=1
nFontType:=4
Case nFont=2
nFontType:=16+32
EndCase
nFontType+=If(lBold,8,0)
nFontType+=If(lUnder,128,0)
::cTextPrn+=Chr(27)+Chr(33)+Chr(nFontType)
//Activate Red Color
If lClrRed
::cTextPrn+=Chr(27)+Chr(114)+Chr(1)
Else
::cTextPrn+=Chr(27)+Chr(114)+Chr(0)
Endif
//Alignement
::cTextPrn+=Chr(27)+Chr(97)+Chr(nPos)
//Say Text
::cTextPrn+=Alltrim(cSay)
::cTextScr+=Alltrim(cSay)
Return Nil
//---------------------------------------------------------- ------------------//
METHOD Euro( ) CLASS TEpson
Return If(::lToScreen,Chr(128),Chr(27)+Chr(116)+Chr(19)+Chr(213))
//---------------------------------------------------------- ------------------//
METHOD Cut( lPartial ) CLASS TEpson
Default lPartial:=.T.
::LineSkip( 2 )
::cTextPrn+=Chr(27)+If(lPartial,Chr(109),Chr(105))
Return Nil
//---------------------------------------------------------- ------------------//
/*
Apertura del cajón portamonedas
Secuencias de códigos para apertura de cajón portamonedas
27,112,0,25,250 (EPSON TM Standar)
27,112,0,100,250
27,112,0,100,255
27,112,0,50,100
27,112,0,50,150
27,112,0,100,250
27,112,0,10,100
*/
METHOD OpenCash( ) CLASS TEpson
Local cOpenCode, aCodigo:={}
If Len(Alltrim(::cCashCode))=0
::cTextPrn+=Chr(27)+Chr(112)+Chr(0)+Chr(25)+Chr(250)
Else
//Calculate the open code
cOpenCode:=::cCashCode
cOpenCode:=IF(RIGHT(cOpenCode,1)=",",cOpenCode,cOpenCode+", ")
Do While AT(",",cOpenCode)>0
AADD(aCodigo,ALLTRIM(LEFT(cOpenCode,AT(",",cOpenCode)-1)))
cOpenCode:=SUBSTR(cOpenCode,AT(",",cOpenCode)+1)
EndDo
cOpenCode:=""
For nItem:=1 to Len(aCodigo)
cOpenCode:=cOpenCode+Chr(Val(aCodigo[nItem]))
Next
::cTextPrn+=cOpenCode
Endif
Return Nil
//---------------------------------------------------------- ------------------//
METHOD End() CLASS TEpson
If !File("PrTicket.Bat")
MEMOWRIT("PrTicket.Bat","Mode "+::cPrnPort+"9600,n,8,1"+CRLF+"TYPE %1 >%2"+CRLF+"DEL %1")
Endif
If ::lToScreen
MEMOWRIT(::cFileTxt,::cTextScr)
WaitRun("notepad "+::cFileTxt)
FErase(::cFileTxt)
Else
MEMOWRIT(::cFileTxt,::cTextPrn)
ShellExecute( ,,"PrTicket.Bat",::cFileTxt+" "+::cPrnPort,,0)
Endif
Return Self
--