Ayuda con TPRINTER

Ayuda con TPRINTER

Postby mag071 » Mon Oct 10, 2011 6:30 am

Saludos ;

Si ejecuto el ejemplo de \FWH\SAMPLES\TESTPRN5.PRG el me muestra como imprimir un archivo de texto con tprinter
pero solo se ejecuta la primera pagina del reporte .
como hago para mostrar igualmente un archivo de texto mas grande que pase de una pagina
Code: Select all  Expand view

#include "FiveWin.ch"

function Main()
//Aqui cambie en el Memoread Testprn5.prg por testxbr3.prg que es mas grande.
   local oPrn, cText := MemoRead( "testxbr3.prg" ), n := 0
   local nRowStep, oFont

   PRINTER oPrn PREVIEW

      DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
      nRowStep = oPrn:nVertRes() / 40

      PAGE
         while n < 40
            oPrn:Say( n * nRowStep, 1, MemoLine( cText,, n + 1 ), oFont )
            n++
         end
      ENDPAGE

   ENDPRINTER

   oFont:End()

return nil
 

Agradecido de antemano por las ayudas conseguidas siempre en este Foro.-
Mario Antonio González Osal
Venezuela
m a g 0 7 1 @ g m a i l. c o m
User avatar
mag071
 
Posts: 140
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela

Re: Ayuda con TPRINTER

Postby Ramon Paredes » Mon Oct 10, 2011 3:51 pm

mag071 :

#include "FiveWin.ch"

function Main()
//Aqui cambie en el Memoread Testprn5.prg por testxbr3.prg que es mas grande.
local oPrn, cText := MemoRead( "testxbr3.prg" ), n := 0
local nRowStep, oFont

PRINTER oPrn PREVIEW

DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
nRowStep = oPrn:nVertRes() / 40

PAGE
while n < 40
oPrn:Say( n * nRowStep, 1, MemoLine( cText,, n + 1 ), oFont )
n++
if n > 40
ENDPAGE
PAGE
n = 1
endif
end
ENDPAGE

ENDPRINTER

oFont:End()

return nil
... Desde la Tierra de lagos y Volcanes......
User avatar
Ramon Paredes
 
Posts: 215
Joined: Fri Feb 02, 2007 3:38 pm
Location: Managua, Nicaragua

Re: Ayuda con TPRINTER

Postby mag071 » Mon Oct 10, 2011 5:23 pm

Gracias Ramon por tu repuesta,

pero igual agrego el codigo que me envias al ejemplo testprn5.prg con el cambio del testxbrw3.prg y me sigue mostrando solo la primera pagina.
Mario Antonio González Osal
Venezuela
m a g 0 7 1 @ g m a i l. c o m
User avatar
mag071
 
Posts: 140
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela

Re: Ayuda con TPRINTER

Postby Bayron » Mon Oct 10, 2011 5:56 pm

Según veo yo, este programa esta diseñado para imprimir las primeras 40 lineas del archivo dado...

Lo que tienes que hacer es contar las lineas del archivo... y crear otro LOOP (Do While) encerrando PAGE/ENDPAGE, hasta que el numero de lineas del documento/numero de lineas por página se cumpla...
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Ayuda con TPRINTER

Postby Ramon Paredes » Mon Oct 10, 2011 6:10 pm

Mag071,

Prueba este codigo y me comentas,

#include "FiveWin.ch"

function Main()
//Aqui cambie en el Memoread Testprn5.prg por testxbr3.prg que es mas grande.
local oPrn, cText := MemoRead( "testxbr3.prg" ), n := 0,nlines,nRow:= 0
local nRowStep, oFont

PRINTER oPrn PREVIEW

DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
nRowStep = oPrn:nVertRes() / 40

PAGE
IF !Empty(cText)
nLines := MLCOUNT(cText,120) // ssco cuantas lineas tiene el campo memo con unalongitud de 39, (esa tu la puedes cambiar)
FOR x := 1 TO nLines
nRow += 0.4
oPrn:CmSay( nRow,2, MEMOLINE(cText,120,x),oFont)
if nRow > 30
ENDPAGE
PAGE
nRow := 0
endif
NEXT
ENDIF

ENDPAGE

ENDPRINTER

oFont:End()

return nil

Saludos desde Managua, Nicaragua
... Desde la Tierra de lagos y Volcanes......
User avatar
Ramon Paredes
 
Posts: 215
Joined: Fri Feb 02, 2007 3:38 pm
Location: Managua, Nicaragua

Re: Ayuda con TPRINTER

Postby mag071 » Mon Oct 10, 2011 6:15 pm

Gracias Bayron;

Asi quedo y me funciona como quiero.

Code: Select all  Expand view

#include "FiveWin.ch"

function Main()
   local oPrn, cText := MemoRead( "testxbr3.prg" ), n := 0
   local nRowStep, oFont,nLineas:=0,nVeces:=0
   nLineas:=MlCount(cText)
   PRINTER oPrn PREVIEW

      DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
      nRowStep = oPrn:nVertRes() / 40
      PAGE
      nVeces:=0
         for n := 0 to nLineas
            oPrn:Say( nVeces * nRowStep, 1, MemoLine( cText,, n + 1 ), oFont )
            nVeces++
            if nVeces >= 40
               nVeces:=0
               ENDPAGE
               PAGE
            endif
         NEXT
      ENDPAGE
   ENDPRINTER
   oFont:End()
return nil
 
Mario Antonio González Osal
Venezuela
m a g 0 7 1 @ g m a i l. c o m
User avatar
mag071
 
Posts: 140
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela

Re: Ayuda con TPRINTER

Postby mag071 » Mon Oct 10, 2011 6:16 pm

Gracias Ramón ;
Mario Antonio González Osal
Venezuela
m a g 0 7 1 @ g m a i l. c o m
User avatar
mag071
 
Posts: 140
Joined: Thu Feb 02, 2006 12:09 pm
Location: Venezuela

Re: Ayuda con TPRINTER

Postby Bayron » Mon Oct 10, 2011 6:29 pm

Que bueno Mario, yo te había preparado también este ejemplo:

Code: Select all  Expand view
// Printing an ascii file

#include "FiveWin.ch"

function Main()

   local oPrn, cText := MemoRead( "testxbr3.prg" ), n := 0, l := 0, linea := 0
   local nRowStep, oFont, nLines, nTimes
     
   If !Empty(cText)
      nLines := MLCOUNT(cText,120)
      nTimes := nLines / 40
      nTimes := If( ( nTimes - Int(nTimes) ) > 0, nTimes + 1, nTimes )
   
      PRINTER oPrn PREVIEW
   
         DEFINE FONT oFont NAME "Courier New" SIZE 0, -10 OF oPrn
         nRowStep = oPrn:nVertRes() / 40
     
         While l < nTimes
            PAGE
               while n < 40
                  oPrn:Say( n * nRowStep, 1, MemoLine( cText,, linea + 1 ), oFont )
                  n++
                  linea++
               end  
            ENDPAGE
            l++
            n := 0
         End
     
      ENDPRINTER
   
      oFont:End()
     
   EndIf

return nil
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Ayuda con TPRINTER

Postby jll-fwh » Tue Oct 11, 2011 12:35 am

Hola mag071:

Aqui tienes un ejemplo funcional completo del uso de TPrint con BD:

Code: Select all  Expand view
/*---------------------------------------------------------------------------------------*/
/*      Archivo: Proc3054.PRG                                                            */
/*  Descripcion: Listado de Apuntes de Gastos y Ingresos                                 */
/*        Fecha: 15-09-2010                                                              */
/*      Release: 19-09-2011                                                              */
/*        Autor: Jose Javier LLoris Roig                                                 */
/*                                                                                       */
/*      Funcion: ListaApuntesGI( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor )        */
/*                                                                                       */
/*      Parametros recibidos:                                                            */
/*                                                                                       */
/*                 cModoImp => Modo de impresion P = pantalla I = impresora              */
/*                 cDesde   => Desde fecha                                               */
/*                 cHasta   => Hasta fecha                                               */
/*                 cPDF     => Nombre del fichero PDF a generar                          */
/*                 nTypeL   => Tipo de listado                                           */
/*                             1.- Todos los apuntes con importe neto                    */
/*                             2.- Todos los apuntes con importe total                   */
/*                 lCeros   => Si imprimimos valores nulos ( ceros ).                    */
/*                             Recibe .T. = Si .F. = No                                  */
/*                                                                                       */
/*      Notas: Este informe se imprime en apaisado.                                      */
/*---------------------------------------------------------------------------------------*/

   #Include "FiveWin.CH"

   #Define CLR_GASTOS   RGB( 255,64,64 )
   #Define CLR_INGRESOS RGB( 76,127,185 )

   STATIC nTypeList

/*------------------------------------------------------------------------------*/
Function ListaApuntesGI( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor )
/*------------------------------------------------------------------------------*/

   MsgRun( "Imprimiendo apuntes de gastos y ingresos.",;
           "Espere por Favor...",;
           { || Lista( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor ) } )

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Lista( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor )
/*------------------------------------------------------------------------------*/

   LOCAL oPrn, oFontC, oFontD, oFontT, oPen, oFontB
   LOCAL nRow  := 0, nLen := 0, nConta := 0

   LOCAL lOk    := .F.
   LOCAL aTotal := ARRAY( 3 )

   DEFAULT cPDF   := "" ,;
           lColor := .F.
   /*-----------------------------------------*/
   /* nTypeList = Tipo de listado de apuntes  */
   /*-----------------------------------------*/
   /* 1.- Todos los apuntes con importe neto  */
   /* 2.- Todos los apuntes con importe total */
   /*-----------------------------------------*/
   nTypeList := nTypeL

   aTotal[1] := 0 // Total apuntes
   aTotal[2] := 0 // Total importe gastos
   aTotal[3] := 0 // Total importe ingresos

   /* Controlamos si es por pantalla o impresora */
   If cModoImp == "P"
      PRINT oPrn NAME "Impresión de Apuntes G/I" PREVIEW MODAL
   Else
      PRINT oPrn NAME "Impresión de Apuntes G/I"
   End

   /* Controlamos si se ha creado el objeto PRINT */
   If Empty( oPrn:hDC )
      Return NIL
   End

   /* Asignamos el nombre del fichero PDF a generar*/
   /* En la nueva version esto sobra               */
   *If !Empty( cPDF )
     * oPrn:cDocument := AllTrim( cPDF )
   *End

   /* Impresion en horizontal */
   oPrn:SetLandscape()

   /* Definimos los FONT */
   DEFINE FONT oFontC NAME "Tahoma" SIZE 0, -8 BOLD     OF oPrn
   DEFINE FONT oFontD NAME "Tahoma" SIZE 0, -7          OF oPrn
   DEFINE FONT oFontT NAME "Tahoma" SIZE 0, -7 BOLD     OF oPrn
   DEFINE FONT oFontB NAME "3 of 9 barcode" SIZE 0, -30 OF oPrn
   DEFINE PEN oPen WIDTH 5 OF oPrn

   PAGE

      nRow := 1

      /* Imprimimos la cabecera del listado */
      Cabeceras( oPrn, @nRow, oFontD, oFontC, oPen, cDesde, cHasta, oFontB )

      /* NOTA: El indice que usamos para generar este informe es ApuCon01.NTX que esta */
      /* ordenado por Numero de Apunte                                                 */

      /* Leemos hasta final de fichero */
      WHILE ! ApuConta->( Eof() )

          /* Controlamos la impresion por rangos de fecha */
          IF ApuConta->ApuFec >= cDesde .AND. ApuConta->ApuFec <= cHasta

             /* Controlamos que tipo de apunte es Gasto o Ingresos para acumular el */
             /* importe neto o importe total                                        */
             IF ApuConta->ApuTip == "G"

                /* 1.- Todos los apuntes con importe neto  */
                IF nTypeList == 1
                   aTotal[2] := aTotal[2] + ApuConta->ApuImp  // Totalizamos gastos neto
                ELSE
                   /* 2.- Todos los apuntes con importe total */
                   aTotal[2] := aTotal[2] + ApuConta->ApuTot  // Totalizamos gastos total
                END

             ELSE

                /* 1.- Todos los apuntes con importe neto  */
                IF nTypeList == 1
                   aTotal[3] := aTotal[3] + ApuConta->ApuImp   // Totalizamos ingresos neto
                ELSE
                   /* 2.- Todos los apuntes con importe total */
                   aTotal[3] := aTotal[3] + ApuConta->ApuTot   // Totalizamos ingresos total
                END

             END

             /* Imprimimos los detalles */
             Detalle( oPrn, @nRow, oFontD, oPen, lColor )

             /* Controlamos los numeros de linea a imprimir */

             IF nConta >= 30 .AND. ! ApuConta->( Eof() )
                oPrn:CmSay( nRow+=0.5,3, "Sigue en página siguiente...",oFontC,,CLR_BLACK )
                oPrn:EndPage()
                oPrn:StartPage()
                nRow   := 1
                nConta := 0
                Cabeceras( oPrn, @nRow, oFontD, oFontC, oPen, cDesde, cHasta, oFontB )
             END

             /* Aumentamos el valor del numero de lineas impresas y si hemos leido al */
             /* menos un registro para poder imprimir los totales                     */
             nConta++
             aTotal[1]++
             lok := .T.

          END

          ApuConta->( DbSkip() )
          SysRefresh()

      END

      /* Impirmimos los totales generales */
      Totales( oPrn, nRow, oFontT, oPen, aTotal, lOk, lColor )

   ENDPAGE


   ENDPRINT

   /* Finalizamos los objetos utilizados */
   oFontC:End()
   oFontD:End()
   oFontT:End()
   oFontB:End()
   oPen:End()

   /* Borramos los objetos utilizados */
   DeleteObject( oPrn )
   DeleteObject( oFontC )
   DeleteObject( oFontD )
   DeleteObject( oFontT )
   DeleteObject( oFontB )
   DeleteObject( oPen )

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Cabeceras( oPrn, nRow, oFontD, oFontC, oPen, cDesde, cHasta, oFontB )
/*------------------------------------------------------------------------------*/

   LOCAL cTitValor

   /* Impresion de la Cabecera del listado */
   oPrn:CmSay( nRow+=1,   3, "Procedimiento: PROC3054.PRG"            ,oFontD )
   oPrn:CmSay( nRow,   11.6, "LISTADO DE APUNTES DE GASTOS/INGRESOS"  ,oFontC )
   oPrn:CmSay( nRow,     23, "Pagina: " + AllTrim( Str( oPrn:nPage ) ),oFontD )
   oPrn:CmSay( nRow,   24.8, "Fecha:  " + dToc( Date() )              ,oFontD )
   oPrn:CmSay( nRow+=0.3, 3, Replicate( "-", 270 )                    ,oFontD )

   /* Imprimimos configuracion del listado */
   oPrn:CmSay( nRow+=0.5, 3, "Desde Periodo:"              ,oFontC )
   /* Codigo de Barra 3of9 Barcode */
   oPrn:CmSay( nRow, 24.5, "3058"                          ,oFontB )
   oPrn:CmSay( nRow, 5.3, TransForm( cDesde, "99-99-9999" ),oFontD )
   oPrn:CmSay( nRow+=0.5, 3, "Hasta Periodo:"              ,oFontC )
   oPrn:CmSay( nRow, 5.3, TransForm( cHasta, "99-99-9999" ),oFontD )
   oPrn:CmSay( nRow+=0.5, 3, "Actividad:"                  ,oFontC )
   oPrn:CmSay( nRow, 5.3, "Todas las actividades"          ,oFontD )

   nRow+=0.3
   LinePrint( oPrn, nRow+=0.5, 3, nRow, 27, oPen )
   nRow+=0.2

   /* Controlamos el titulo a imprimir si es por importe neto o por importe total */
   DO CASE
      CASE nTypeList == 1
           cTitValor := "Neto"
      CASE nTypeList == 2
           cTitValor := "Total"
   ENDCASE

   oPrn:CmSay( nRow,25.8, "Importe"           ,oFontC )
   nRow+=0.3
   oPrn:CmSay( nRow,   3, "Apunte"            ,oFontC )
   oPrn:CmSay( nRow, 4.2, "G/I"               ,oFontC )
   oPrn:CmSay( nRow,   5, "Fecha"             ,oFontC )
   oPrn:CmSay( nRow, 6.4, "Doc"               ,oFontC )
   oPrn:CmSay( nRow,   8, "Actividad"         ,oFontC )
   oPrn:CmSay( nRow,  12, "Concepto"          ,oFontC )
   oPrn:CmSay( nRow,16.8, "Tipo Ingreso/Gasto",oFontC )
   oPrn:CmSay( nRow,20.8, "Forma Cobro/Pago"  ,oFontC )
   oPrn:CmSay( nRow,25.8, cTitValor           ,oFontC )
   nRow+=0.5
   LinePrint( oPrn, nRow, 3, nRow, 27, oPen )

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Detalle( oPrn, nRow, oFontC, oPen, lColor )
/*------------------------------------------------------------------------------*/

   LOCAL nCLR := CLR_INGRESOS

   /* Controlamos en que tipo de color imprimimos */
   IF ApuConta->ApuTip == "G"
      nCLR := CLR_GASTOS
   END

   /* Controlamos si imprimimos en color o en escala de grisis */
   IF !lColor
      nCLR := CLR_BLACK
   END

   nRow+=0.2
   oPrn:CmSay( nRow,   3, ApuConta->ApuNum                           ,oFontC,,CLR_BLACK )
   oPrn:CmSay( nRow, 4.4, ApuConta->ApuTip                           ,oFontC,,CLR_BLACK )
   oPrn:CmSay( nRow,   5, TransForm( ApuConta->ApuFec, "99-99-9999" ),oFontC,,CLR_BLACK )
   oPrn:CmSay( nRow, 6.4, ApuConta->ApuFac                           ,oFontC,,CLR_BLACK )

   /* Actividad */
   IF MiDosBuscar( "Activida", 1, ApuConta->ApuCac )
      oPrn:CmSay( nRow, 8, StrCapFirst( SubStr( Activida->DesAct, 1, 30 ) ) ,oFontC,,CLR_BLACK )
   END

   /* Concepto */
   oPrn:CmSay( nRow, 12, StrCapFirst( SubStr( ApuConta->ApuCon, 1, 40 ) ) ,oFontC,,CLR_BLACK )

   /* Si es un tipo de apunte de Gastos */
   IF ApuConta->ApuTip == "G"

      IF MiDosBuscar( "TGasto", 1, ApuConta->ApuTga )
         oPrn:CmSay( nRow, 16.8, StrCapFirst( SubStr( TGasto->TgDes, 1, 30 ) ) ,oFontC,,CLR_BLACK )
      END

   ELSE

      /* Si es un tipo de apunte de Ingreso */
      IF MiDosBuscar( "TIngreso", 1, ApuConta->ApuTin )
         oPrn:CmSay( nRow, 16.8, StrCapFirst( SubStr( TIngreso->TiDes, 1, 30 )) ,oFontC,,CLR_BLACK )
      END

   END

   /* Formas de pago/cobro */
   IF MiDosBuscar( "FormaPC", 1, ApuConta->ApuFpa )
      oPrn:CmSay( nRow, 20.8, StrCapFirst( SubStr( FormaPC->DesFpc, 1, 35 ) ) ,oFontC,,CLR_BLACK )
   END

   /* Imprimimos importe neto o importe total segun sea un Gasto o un Ingreso */
   DO CASE
      /* Importe neto */
      CASE nTypeList == 1
           oPrn:CmSay( nRow, 27, TransForm( ApuConta->ApuImp, "99,999,999.99" ) ,oFontC,,nCLR,,1 )
      /* Importe total */
      CASE nTypeList == 2
           oPrn:CmSay( nRow, 27, TransForm( ApuConta->ApuTot, "99,999,999.99" ) ,oFontC,,nCLR,,1 )
   ENDCASE

   nRow+=0.2

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Totales( oPrn, nRow, oFont, oPen, aTotal, lOk, lColor )
/*------------------------------------------------------------------------------*/

   LOCAL nCLR
   LOCAL nTotal := 0

   /* Si no hay registros a imprimir se muestra un mesaje y no imprimimos totales */
   IF !lOk
      nRow+=0.2
      oPrn:CmSay( nRow,12, "*** No existen apuntes a imprimir ***",oFont,,CLR_BLACK )
      Return NIL
   END

   /* Calculamos el saldo de gastos y ingresos */
   nTotal := aTotal[3] - aTotal[2]

   nRow+=0.2
   LinePrint( oPrn, nRow, 3, nRow, 27, oPen )
   nRow+=0.2

   /* Impirmimos total de apuntes */
   oPrn:CmSay( nRow, 3, "Total apuntes: " + LTrim( TransForm( aTotal[1], "999,999" ) ),oFont,, CLR_BLACK )

   If aTotal[2] > aTotal[3]
      nCLR := CLR_GASTOS
   Else
     If aTotal[2] < aTotal[3]
        nCLR := CLR_INGRESOS
     Else
        nCLR := CLR_BLACK
     End
   End

   /* Controlamos si imprimimos en color o en escala de grisis */
   IF !lColor
      nCLR := CLR_BLACK
   END

   oPrn:CmSay( nRow,20.8, "Saldo:",oFont,,CLR_BLACK )
   oPrn:CmSay( nRow,  27, TransForm( nTotal, "99,999,999.99" ),oFont,, nCLR,,1 )

Return NIL
 


Un saludo
JLL
Libreria: FWH/FWH1109 + Harbour 5.8.2 + Borland C++ 5.8.2
Editor de Recursos: PellecC
ADA, OURXDBU
S.O: XP / Win 7 /Win10
Blog: http://javierlloris.blogspot.com.es/
e-mail: javierllorisprogramador@gmail.com
User avatar
jll-fwh
 
Posts: 408
Joined: Fri Jan 29, 2010 8:14 pm
Location: Meliana - Valencia

Re: Ayuda con TPRINTER

Postby Yessica » Tue Apr 24, 2012 4:13 pm

Una pregunta mi querido amigo, como seria el comando para preguntar si la impresora esta Lista es decir, ya que si por alguna razon no estuviera lista me manda un error, la impresora esta en Red y es laser, como puedo saber si esta lista o no para que ya no me mande este error antes de imprimir??

ojala y me pudieras echar la mano con este detalle.

Gracias de antemano

Yessi.


jll-fwh wrote:Hola mag071:

Aqui tienes un ejemplo funcional completo del uso de TPrint con BD:

Code: Select all  Expand view
/*---------------------------------------------------------------------------------------*/
/*      Archivo: Proc3054.PRG                                                            */
/*  Descripcion: Listado de Apuntes de Gastos y Ingresos                                 */
/*        Fecha: 15-09-2010                                                              */
/*      Release: 19-09-2011                                                              */
/*        Autor: Jose Javier LLoris Roig                                                 */
/*                                                                                       */
/*      Funcion: ListaApuntesGI( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor )        */
/*                                                                                       */
/*      Parametros recibidos:                                                            */
/*                                                                                       */
/*                 cModoImp => Modo de impresion P = pantalla I = impresora              */
/*                 cDesde   => Desde fecha                                               */
/*                 cHasta   => Hasta fecha                                               */
/*                 cPDF     => Nombre del fichero PDF a generar                          */
/*                 nTypeL   => Tipo de listado                                           */
/*                             1.- Todos los apuntes con importe neto                    */
/*                             2.- Todos los apuntes con importe total                   */
/*                 lCeros   => Si imprimimos valores nulos ( ceros ).                    */
/*                             Recibe .T. = Si .F. = No                                  */
/*                                                                                       */
/*      Notas: Este informe se imprime en apaisado.                                      */
/*---------------------------------------------------------------------------------------*/

   #Include "FiveWin.CH"

   #Define CLR_GASTOS   RGB( 255,64,64 )
   #Define CLR_INGRESOS RGB( 76,127,185 )

   STATIC nTypeList

/*------------------------------------------------------------------------------*/
Function ListaApuntesGI( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor )
/*------------------------------------------------------------------------------*/

   MsgRun( "Imprimiendo apuntes de gastos y ingresos.",;
           "Espere por Favor...",;
           { || Lista( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor ) } )

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Lista( cModoImp, cDesde, cHasta, cPDF, nTypeL, lColor )
/*------------------------------------------------------------------------------*/

   LOCAL oPrn, oFontC, oFontD, oFontT, oPen, oFontB
   LOCAL nRow  := 0, nLen := 0, nConta := 0

   LOCAL lOk    := .F.
   LOCAL aTotal := ARRAY( 3 )

   DEFAULT cPDF   := "" ,;
           lColor := .F.
   /*-----------------------------------------*/
   /* nTypeList = Tipo de listado de apuntes  */
   /*-----------------------------------------*/
   /* 1.- Todos los apuntes con importe neto  */
   /* 2.- Todos los apuntes con importe total */
   /*-----------------------------------------*/
   nTypeList := nTypeL

   aTotal[1] := 0 // Total apuntes
   aTotal[2] := 0 // Total importe gastos
   aTotal[3] := 0 // Total importe ingresos

   /* Controlamos si es por pantalla o impresora */
   If cModoImp == "P"
      PRINT oPrn NAME "Impresión de Apuntes G/I" PREVIEW MODAL
   Else
      PRINT oPrn NAME "Impresión de Apuntes G/I"
   End

   /* Controlamos si se ha creado el objeto PRINT */
   If Empty( oPrn:hDC )
      Return NIL
   End

   /* Asignamos el nombre del fichero PDF a generar*/
   /* En la nueva version esto sobra               */
   *If !Empty( cPDF )
     * oPrn:cDocument := AllTrim( cPDF )
   *End

   /* Impresion en horizontal */
   oPrn:SetLandscape()

   /* Definimos los FONT */
   DEFINE FONT oFontC NAME "Tahoma" SIZE 0, -8 BOLD     OF oPrn
   DEFINE FONT oFontD NAME "Tahoma" SIZE 0, -7          OF oPrn
   DEFINE FONT oFontT NAME "Tahoma" SIZE 0, -7 BOLD     OF oPrn
   DEFINE FONT oFontB NAME "3 of 9 barcode" SIZE 0, -30 OF oPrn
   DEFINE PEN oPen WIDTH 5 OF oPrn

   PAGE

      nRow := 1

      /* Imprimimos la cabecera del listado */
      Cabeceras( oPrn, @nRow, oFontD, oFontC, oPen, cDesde, cHasta, oFontB )

      /* NOTA: El indice que usamos para generar este informe es ApuCon01.NTX que esta */
      /* ordenado por Numero de Apunte                                                 */

      /* Leemos hasta final de fichero */
      WHILE ! ApuConta->( Eof() )

          /* Controlamos la impresion por rangos de fecha */
          IF ApuConta->ApuFec >= cDesde .AND. ApuConta->ApuFec <= cHasta

             /* Controlamos que tipo de apunte es Gasto o Ingresos para acumular el */
             /* importe neto o importe total                                        */
             IF ApuConta->ApuTip == "G"

                /* 1.- Todos los apuntes con importe neto  */
                IF nTypeList == 1
                   aTotal[2] := aTotal[2] + ApuConta->ApuImp  // Totalizamos gastos neto
                ELSE
                   /* 2.- Todos los apuntes con importe total */
                   aTotal[2] := aTotal[2] + ApuConta->ApuTot  // Totalizamos gastos total
                END

             ELSE

                /* 1.- Todos los apuntes con importe neto  */
                IF nTypeList == 1
                   aTotal[3] := aTotal[3] + ApuConta->ApuImp   // Totalizamos ingresos neto
                ELSE
                   /* 2.- Todos los apuntes con importe total */
                   aTotal[3] := aTotal[3] + ApuConta->ApuTot   // Totalizamos ingresos total
                END

             END

             /* Imprimimos los detalles */
             Detalle( oPrn, @nRow, oFontD, oPen, lColor )

             /* Controlamos los numeros de linea a imprimir */

             IF nConta >= 30 .AND. ! ApuConta->( Eof() )
                oPrn:CmSay( nRow+=0.5,3, "Sigue en página siguiente...",oFontC,,CLR_BLACK )
                oPrn:EndPage()
                oPrn:StartPage()
                nRow   := 1
                nConta := 0
                Cabeceras( oPrn, @nRow, oFontD, oFontC, oPen, cDesde, cHasta, oFontB )
             END

             /* Aumentamos el valor del numero de lineas impresas y si hemos leido al */
             /* menos un registro para poder imprimir los totales                     */
             nConta++
             aTotal[1]++
             lok := .T.

          END

          ApuConta->( DbSkip() )
          SysRefresh()

      END

      /* Impirmimos los totales generales */
      Totales( oPrn, nRow, oFontT, oPen, aTotal, lOk, lColor )

   ENDPAGE


   ENDPRINT

   /* Finalizamos los objetos utilizados */
   oFontC:End()
   oFontD:End()
   oFontT:End()
   oFontB:End()
   oPen:End()

   /* Borramos los objetos utilizados */
   DeleteObject( oPrn )
   DeleteObject( oFontC )
   DeleteObject( oFontD )
   DeleteObject( oFontT )
   DeleteObject( oFontB )
   DeleteObject( oPen )

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Cabeceras( oPrn, nRow, oFontD, oFontC, oPen, cDesde, cHasta, oFontB )
/*------------------------------------------------------------------------------*/

   LOCAL cTitValor

   /* Impresion de la Cabecera del listado */
   oPrn:CmSay( nRow+=1,   3, "Procedimiento: PROC3054.PRG"            ,oFontD )
   oPrn:CmSay( nRow,   11.6, "LISTADO DE APUNTES DE GASTOS/INGRESOS"  ,oFontC )
   oPrn:CmSay( nRow,     23, "Pagina: " + AllTrim( Str( oPrn:nPage ) ),oFontD )
   oPrn:CmSay( nRow,   24.8, "Fecha:  " + dToc( Date() )              ,oFontD )
   oPrn:CmSay( nRow+=0.3, 3, Replicate( "-", 270 )                    ,oFontD )

   /* Imprimimos configuracion del listado */
   oPrn:CmSay( nRow+=0.5, 3, "Desde Periodo:"              ,oFontC )
   /* Codigo de Barra 3of9 Barcode */
   oPrn:CmSay( nRow, 24.5, "3058"                          ,oFontB )
   oPrn:CmSay( nRow, 5.3, TransForm( cDesde, "99-99-9999" ),oFontD )
   oPrn:CmSay( nRow+=0.5, 3, "Hasta Periodo:"              ,oFontC )
   oPrn:CmSay( nRow, 5.3, TransForm( cHasta, "99-99-9999" ),oFontD )
   oPrn:CmSay( nRow+=0.5, 3, "Actividad:"                  ,oFontC )
   oPrn:CmSay( nRow, 5.3, "Todas las actividades"          ,oFontD )

   nRow+=0.3
   LinePrint( oPrn, nRow+=0.5, 3, nRow, 27, oPen )
   nRow+=0.2

   /* Controlamos el titulo a imprimir si es por importe neto o por importe total */
   DO CASE
      CASE nTypeList == 1
           cTitValor := "Neto"
      CASE nTypeList == 2
           cTitValor := "Total"
   ENDCASE

   oPrn:CmSay( nRow,25.8, "Importe"           ,oFontC )
   nRow+=0.3
   oPrn:CmSay( nRow,   3, "Apunte"            ,oFontC )
   oPrn:CmSay( nRow, 4.2, "G/I"               ,oFontC )
   oPrn:CmSay( nRow,   5, "Fecha"             ,oFontC )
   oPrn:CmSay( nRow, 6.4, "Doc"               ,oFontC )
   oPrn:CmSay( nRow,   8, "Actividad"         ,oFontC )
   oPrn:CmSay( nRow,  12, "Concepto"          ,oFontC )
   oPrn:CmSay( nRow,16.8, "Tipo Ingreso/Gasto",oFontC )
   oPrn:CmSay( nRow,20.8, "Forma Cobro/Pago"  ,oFontC )
   oPrn:CmSay( nRow,25.8, cTitValor           ,oFontC )
   nRow+=0.5
   LinePrint( oPrn, nRow, 3, nRow, 27, oPen )

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Detalle( oPrn, nRow, oFontC, oPen, lColor )
/*------------------------------------------------------------------------------*/

   LOCAL nCLR := CLR_INGRESOS

   /* Controlamos en que tipo de color imprimimos */
   IF ApuConta->ApuTip == "G"
      nCLR := CLR_GASTOS
   END

   /* Controlamos si imprimimos en color o en escala de grisis */
   IF !lColor
      nCLR := CLR_BLACK
   END

   nRow+=0.2
   oPrn:CmSay( nRow,   3, ApuConta->ApuNum                           ,oFontC,,CLR_BLACK )
   oPrn:CmSay( nRow, 4.4, ApuConta->ApuTip                           ,oFontC,,CLR_BLACK )
   oPrn:CmSay( nRow,   5, TransForm( ApuConta->ApuFec, "99-99-9999" ),oFontC,,CLR_BLACK )
   oPrn:CmSay( nRow, 6.4, ApuConta->ApuFac                           ,oFontC,,CLR_BLACK )

   /* Actividad */
   IF MiDosBuscar( "Activida", 1, ApuConta->ApuCac )
      oPrn:CmSay( nRow, 8, StrCapFirst( SubStr( Activida->DesAct, 1, 30 ) ) ,oFontC,,CLR_BLACK )
   END

   /* Concepto */
   oPrn:CmSay( nRow, 12, StrCapFirst( SubStr( ApuConta->ApuCon, 1, 40 ) ) ,oFontC,,CLR_BLACK )

   /* Si es un tipo de apunte de Gastos */
   IF ApuConta->ApuTip == "G"

      IF MiDosBuscar( "TGasto", 1, ApuConta->ApuTga )
         oPrn:CmSay( nRow, 16.8, StrCapFirst( SubStr( TGasto->TgDes, 1, 30 ) ) ,oFontC,,CLR_BLACK )
      END

   ELSE

      /* Si es un tipo de apunte de Ingreso */
      IF MiDosBuscar( "TIngreso", 1, ApuConta->ApuTin )
         oPrn:CmSay( nRow, 16.8, StrCapFirst( SubStr( TIngreso->TiDes, 1, 30 )) ,oFontC,,CLR_BLACK )
      END

   END

   /* Formas de pago/cobro */
   IF MiDosBuscar( "FormaPC", 1, ApuConta->ApuFpa )
      oPrn:CmSay( nRow, 20.8, StrCapFirst( SubStr( FormaPC->DesFpc, 1, 35 ) ) ,oFontC,,CLR_BLACK )
   END

   /* Imprimimos importe neto o importe total segun sea un Gasto o un Ingreso */
   DO CASE
      /* Importe neto */
      CASE nTypeList == 1
           oPrn:CmSay( nRow, 27, TransForm( ApuConta->ApuImp, "99,999,999.99" ) ,oFontC,,nCLR,,1 )
      /* Importe total */
      CASE nTypeList == 2
           oPrn:CmSay( nRow, 27, TransForm( ApuConta->ApuTot, "99,999,999.99" ) ,oFontC,,nCLR,,1 )
   ENDCASE

   nRow+=0.2

Return NIL
/*------------------------------------------------------------------------------*/
STATIC Function Totales( oPrn, nRow, oFont, oPen, aTotal, lOk, lColor )
/*------------------------------------------------------------------------------*/

   LOCAL nCLR
   LOCAL nTotal := 0

   /* Si no hay registros a imprimir se muestra un mesaje y no imprimimos totales */
   IF !lOk
      nRow+=0.2
      oPrn:CmSay( nRow,12, "*** No existen apuntes a imprimir ***",oFont,,CLR_BLACK )
      Return NIL
   END

   /* Calculamos el saldo de gastos y ingresos */
   nTotal := aTotal[3] - aTotal[2]

   nRow+=0.2
   LinePrint( oPrn, nRow, 3, nRow, 27, oPen )
   nRow+=0.2

   /* Impirmimos total de apuntes */
   oPrn:CmSay( nRow, 3, "Total apuntes: " + LTrim( TransForm( aTotal[1], "999,999" ) ),oFont,, CLR_BLACK )

   If aTotal[2] > aTotal[3]
      nCLR := CLR_GASTOS
   Else
     If aTotal[2] < aTotal[3]
        nCLR := CLR_INGRESOS
     Else
        nCLR := CLR_BLACK
     End
   End

   /* Controlamos si imprimimos en color o en escala de grisis */
   IF !lColor
      nCLR := CLR_BLACK
   END

   oPrn:CmSay( nRow,20.8, "Saldo:",oFont,,CLR_BLACK )
   oPrn:CmSay( nRow,  27, TransForm( nTotal, "99,999,999.99" ),oFont,, nCLR,,1 )

Return NIL
 


Un saludo
JLL
Yessica
 
Posts: 78
Joined: Thu May 28, 2009 6:58 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 10 guests