/*
This is a sample framework ... you will need to declare your variables, and otherwise access the data
*/
// Declare include files
#include "tdata.ch"
#include "fivewin.ch"
FUNCTION pro1110( oWrk, aConst )
// Declare LOCAL variables
LOCAL ...
nPageCount := 1
cPRNTYP := " "
// Open databases here, and get basic configuration data from memory, such as
// your printer settings, etc.
// Declare a header array and load the variables: aHead[x]
// Present the print selection option window and find the type
nPrnOpt := PRNSEL()
IF nPrnOpt = 0 // If Exit is specified, leave the print report function
RETURN NIL
ENDIF
// Set the number of copies
IF oDcf:InvPr4 = .T. .AND. cPRNTYP $ "EIC"
nPrnCopies := 2
ELSE
nPrnCopies := 1
ENDIF
// Now tell the print engine the type of format to use
IF nPrnOpt = 1
PRINT oPrn NAME "Invoice Printing" PREVIEW FROM USER MODAL // Preview with alternate printer selection
ELSEIF nPrnOpt = 2
PRINT oPrn NAME "Invoice Printing" PREVIEW MODAL // Preview with default printer
ELSEIF nPrnOpt = 3
PRINT oPrn NAME "Invoice Printing" FROM USER // Send to user selected printer
ELSEIF nPrnOpt = 4
PRINT oPrn NAME "Invoice Printing" // Send to default printer
ENDIF
// Define the fonts to be used
DEFINE FONT oFnorm NAME "Courier New" SIZE 0, - 12 OF oPrn
DEFINE FONT oFbold NAME "Courier New" SIZE 0, - 12 BOLD OF oPrn
DEFINE FONT oFundl NAME "Courier New" SIZE 0, - 12 UNDERLINE OF oPrn
DEFINE FONT oFwide NAME "Courier New" SIZE 0, - 18 BOLD ITALIC OF oPrn
DEFINE FONT oFboun NAME "Courier New" SIZE 0, - 12 BOLD UNDERLINE OF oPrn
DEFINE FONT oFcond NAME "Courier New" SIZE 0, - 8 OF oPrn
// Background brush
DEFINE BRUSH oPrnBrush COLOR CLR_LIGHTGRAY
// Define the pen
DEFINE PEN oPen STYLE PS_SOLID WIDTH 5 OF oPrn
DEFINE PEN oPben STYLE PS_SOLID WIDTH 10 OF oPrn
// Set the resolution divided by the standard 8.5x11 inch paper rows/columns
nRsp := oPrn:nVertRes() / 66 // Number of rows
nCsp := oPrn:nHorzRes() / 85 // Number of columns
// Now send the number of copies to the printer
oPrn:SetCopies( nPrnCopies )
// Turn on the first page - print the header data
PAGE
HEADINV( oPrn, aHead )
// PRINT INVOICE HEADING
// Lets create a watermark if the file exists in the main file directory
IF lPrnWtrmrk
oPrn:SayBitMap(21*nRsp,nCsp,cPath+"wtrmk.bmp", nCsp*84, 24*nRsp )
ENDIF
// Print the title for an Invoice
oPrn:Say( nRow, 30 * nCsp, "INVOICE FOR SERVICES", oFboun )
// After the title, we skip 2 lines
nRow += 2 * nRsp
// Greyscale the customer information if flagged
IF oDcf:InvPr3 = .T.
oPrn:FillRect( { nRow - ( 1 * nRsp ), 5, nRow + ( 8.0 * nRsp ), 84.8 * nCsp }, oPrnBrush )
ENDIF
// Box the customer information
oPrn:Box( nRow, nCsp, nRow + ( 7 * nRsp ), 39 * nCsp, oPben )
oPrn:Box( nRow, nCsp * 40, nRow + ( 7 * nRsp ), 83 * nCsp, oPben )
nRow += .4 * nRsp
// Now print the customer and service item information
oPrn:Say( nRow, 2 * nCsp, "CUSTOMER:", oFbold )
oPrn:Say( nRow, 13 * nCsp, m_cliwho, oFnorm )
oPrn:Say( nRow, 41 * nCsp, UPPER( sLbl[4]), oFbold )
oPrn:Say( nRow, 54 * nCsp, m_vehlif, oFnorm )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "ADDRESS:", oFbold )
oPrn:Say( nRow, 13 * nCsp, m_cliadd, oFnorm )
oPrn:Say( nRow, 41 * nCsp, UPPER( sLbl[1]), oFbold )
oPrn:Say( nRow, 54 * nCsp, m_vehstr, oFnorm )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "CITY:", oFbold )
oPrn:Say( nRow, 13 * nCsp, m_clicty, oFnorm )
oPrn:Say( nRow, 41 * nCsp, UPPER(TRIM(sLbl[2])) + ":", oFbold )
oPrn:Say( nRow, 54 * nCsp, m_vehidn, oFnorm )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "HOME:", oFbold )
oPrn:Say( nRow, 13 * nCsp, m_clipho, oFnorm )
oPrn:Say( nRow, 41 * nCsp, UPPER(TRIM(sLbl[3])) + ":", oFbold )
oPrn:Say( nRow, 54 * nCsp, "In:" + TRIM(oWrk:SrvMil) + " Out:" + TRIM(oWrk:SrvMio), oFnorm )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "BUSINESS:", oFbold )
oPrn:Say( nRow, 13 * nCsp, m_clibus, oFnorm )
oPrn:Say( nRow, 41 * nCsp, "TAG/COLOR", oFbold )
oPrn:Say( nRow, 54 * nCsp, TRIM( oWrk:SrvHat ) + " " + TRIM( m_vehcol ), oFnorm )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "CELL:", oFbold )
oPrn:Say( nRow, 13 * nCsp, m_clicel, oFnorm )
oPrn:Say( nRow, 41 * nCsp, "EMAIL:", oFbold )
oPrn:Say( nRow, 54 * nCsp, m_clieml, oFnorm )
nRow += nRsp * 3
IF ! EMPTY( oWrk:AltBil ) // Provide for alternate billing if appropriate
oPrn:Say( nRow, 2 * nCsp, m_altcom, oFnorm )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, m_altadd, oFnorm )
nRow += nRsp * 2
ENDIF
IF ! EMPTY( oWrk:PurOrd ) // Provide for purchase order if appropriate
oPrn:Say( nRow, 2 * nCsp, "REFERENCE PURCHASE ORDER NO. " + oWrk:PurOrd, oFnorm )
nRow += nRsp
ENDIF
// PRINT PARTS
// Locate the first part for the workorder, and if found put a flag on retention
oTdpa:seek( oWrk:wrkord )
IF oTdpa:FOUND() // If parts are found
// Print the retain option
oPrn:Say( nRow, 2 * nCsp, "The following parts were used on this service:", sFont )
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "Quan. Part # Description Charge Extended", oFundl )
nRow += 1.4 * nRsp
ENDIF
// Now print the actual parts
DO WHILE oTdpa:wrkord = oWrk:wrkord .AND. !oTdpa:eof()
// Check the page header first
PAGEHEAD( oPrn, aHead )
// If the quantity is not zero
IF oTdpa:parqun <> 0.00
oPrn:Say( nRow, 2 * nCsp, STR( oTdpa:parqun, 6, 2 ) + " " + oTdpa:parnum + " " + oTdpa:pardes + " " + STR( oTdpa:parchg, 8, 2 ) + " " + STR( oTdpa:partot, 8, 2 ), oFnorm )
nRow += nRsp
ENDIF
// Nextg part
oTdpa:skip()
ENDDO
// PRINT LABOR
IF cPRNTYP $ 'EIWC'
// Position the labor file to the first workorder entry
oTdla:seek( oWrk:wrkord )
IF oTdla:found()
// Print labor heading
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "The labor performed, and the charges, are:", sFont )
nRow += 2 * nRsp
ENDIF
// Now obtrain the information on the labor record
DO WHILE oTdla:wrkord = oWrk:wrkord .AND. !oTdla:eof()
oPrn:Say( nRow, 3 * nCsp, MEMOLINE( m_labtxt, 60, 1,, .t. ) + IIF( m_platot = 0, SPACE( 15 ), STR( m_platot, 15, 2 ) ), oFnorm )
nRow += nRsp
PAGEHEAD( oPrn, aHead )
// Move to the next record
oTdla:skip()
ENDDO
ENDIF
// PRINT RECOMMENDATIONS
// If there are recommendations
oTrec:seek( oWrk:wrkord )
IF oTrec:FOUND() // Print the header
nRow += nRsp
oPrn:Say( nRow, 2 * nCsp, "The following recommendations are offered based on work performed:", sFont )
nRow += 1.4 * nRsp
lPrntRecs := .t.
ENDIF
// Now print the actual recommendations
DO WHILE oTrec:wrkord = oWrk:wrkord .AND. !oTrec:eof()
IF ! oTrec:deleted( )
FOR lx := 1 TO MLCount( oTrec:rectxt, 60,, .t. )
PAGEHEAD( oPrn, aHead )
oPrn:Say( nRow, 2 * nCsp, MEMOLINE( oTrec:rectxt, 60, lx,, .t. ), oFnorm )
nRow += nRsp
NEXT
IF oTrec:labtot <> 0.00
oPrn:Say( nRow, 9 * nCsp, "The approximate cost will be $" + STR( oTrec:labtot, 10, 2 ) + ' plus taxes and supplies', oFnorm )
nRow += nRsp
ENDIF
ENDIF
oTrec:skip()
ENDDO
// PRINT TOTALS
/* Use the same principles to format and print totals. Remember you can do running calculations
in the steps above, and use those variables to hold the totals which depend on the info in the
printout.
Also, you can do credit card transaction receipts in this area with signature lines ... all done
with the same methods
*/
// PRINT DISCLAIMERS - Use Memo text fields, then print them in condensed print
// End of print
ENDPAGE
oPrn:SetCopies( 1 )
ENDPRINT
// Close databases
// Close fonts
oFnorm:end()
oFbold:end()
oFwide:end()
oFcond:end()
oFundl:end()
RETURN NIL
STATIC FUNCTION HEADINV( oPrn, aHead )
// Starting Row
nRow := 2 * nRsp
// Outer frame box
nRow += 2 * nRsp
oPrn:Box( nRow, 0, nRow + ( 63 * nRsp ), 85 * nCsp, oPen )
// Background for header
oPrn:FillRect( { nRow + 5, 5, nRow + ( 9 * nRsp ), 84.8 * nCsp }, oPrnBrush )
nRow += 2 * nRsp
// Box Both Sides
oPrn:Box( nRow, nCsp * 1, nRow + ( 6 * nRsp ), 38 * nCsp, oPben )
oPrn:Box( nRow, nCsp * 40, nRow + ( 6 * nRsp ), 83 * nCsp, oPben )
nRow += nRsp * .4
// Now print the invoice detail
oPrn:Say( nRow, 0, aHead[ 1 ], oFbold )
nRow += nRsp
oPrn:Say( nRow, 41 * nCsp, "INVOICE: ", oFbold )
oPrn:Say( nRow, 54 * nCsp, aHead[ 8 ], oFbold )
oPrn:Say( nRow, 62 * nCsp, "Page:", oFnorm )
oPrn:Say( nRow, 68 * nCsp, STR( nPageCount, 3), oFnorm )
nRow += nRsp
RETURN NIL
STATIC FUNCTION pagehead( oPrn, aHead )
IF nRow >= 60 * nRsp
ENDPAGE
PAGE
nPageCount ++
HEADINV( oPrn, aHead )
ENDIF
RETURN NIL