          SUBROUTINE (OID,GEN,NO.PT,STATUS,PSTYLE.OVRD,PRT.ON,DRPT)
** Version# 38.0001[19] - 08/22/2013 - 04:19pm - TSMITH - eclipse
*** V38.0001 Change - Custom Coding 1-3 - 08/22/2013 - TSMITH - eclipse

*** Subroutine: SOE.PRINT.ACK
*-------------------------------------------------------------------------*
*** This subroutine prints/faxes acknowledgements. Includes page 1 of n
*** logic as well as new OE.DESC.GET and new Lot Billing. This is a laser
*** form with laser printer commands.
*-------------------------------------------------------------------------*
*** Variables:
***       OID         - Order ID                                      [In]
***       GEN         - Order generation                              [In]
***       STATUS      - Print status determines which form will print (In)
***       PSTYLE.OVRD - Print style override                          (In)
***       PRT.ON      - Printer on flag                               (In)
***       DRPT        - Report Defaults                               [In]
*-------------------------------------------------------------------------*
*** Common: LED, LD, PRD, PRD.BR, CUS, and CUSS are read but not written.
***         JAVA.PROC$, INVOICE.COPY.CT$, and PHANTOM.PROC are used but
***         not written.
*-------------------------------------------------------------------------*
          SV.GEN = GEN

          DIM PSTYL(10)

          UT.OPEN.FILE "PRINT.STYLES",PSTYLFILE,ERR.MSG
          IF ERR.MSG THEN RETURN

          PG.LGTH = 60
          FT.LGTH  = 0
          BOD.LINES = 31
          IF DRPT<29> THEN FAX.FLAG = YES ELSE FAX.FLAG = NO
          *IF FAX.FLAG THEN
*            PG.LGTH    = 30
             FTR.MSG    = "Subtotal"
             FTR.MSG<2> = "S&H CHGS"
             FTR.MSG<3> = "Sales Tax"
             FTR.MSG<4> = "Amount Due"
*         END ELSE
*            FTR.MSG    = ''
*         ENDIF FAX.FLAG THEN

          IF NOT(PHANTOM.PROC) AND NOT(PRT.ON) AND NOT(JAVA.PROC$) THEN
             WINDOW 15,8,50,5
             IF FAX.FLAG THEN
                PRINT @(0,1):'Faxing .... ':OID
             END ELSE
                PRINT @(0,1):'Printing .... ':OID
             END
          END

          MATREAD LED FROM LEDFILE,OID ELSE GOTO FINISH
*LOT
          IF LED(98)<1,GEN> THEN LOT.FLAG = YES ELSE LOT.FLAG = NO
          CHANGE.FLAG = (LED(129)<1,2> # "")
          IF (CHANGE.FLAG) THEN
             FTR.MSG<4> = "Change Amt"
          END
          LD.GEN = GEN

          OE.GET.QSIGN QSIGN,OID,GEN
          BR      = LED(2)<1,GEN,1>
          SHIP.BR = LED(2)<1,GEN,2>

          READV BR.EN FROM TERRFILE,BR,4 ELSE BR.EN = ''
          READ CUS.BR FROM CUSFILE,BR.EN ELSE CUS.BR=''
          PRC.PHONES = CUS.BR<17>
          PRC.BR.PHONES = PRC.PHONES<1,1>
          IF PRC.PHONES<1,2> THEN
             PRC.BR.PHONES := ' Fax ':PRC.PHONES<1,2>
          END

          READV BR.EN FROM TERRFILE,SHIP.BR,4 ELSE BR.EN = ''
          READ CUS.BR FROM CUSFILE,BR.EN ELSE CUS.BR=''

          BR.ADDR = CUS.BR<1>
          IF CUS.BR<2,1> THEN BR.ADDR<-1> = CUS.BR<2,1>
          IF CUS.BR<2,2> THEN BR.ADDR<-1> = CUS.BR<2,2>
          BR.ADDR<-1> = CUS.BR<3>:' ':CUS.BR<4>:' ':CUS.BR<5>
          CONTACTS = RAISE(OCONV(CUS.BR<16>,"MCU"))
          FINDSTR "FAX" IN CONTACTS SETTING PPOS ELSE PPOS = 0
          FINDSTR "FAX" IN CONTACTS SETTING PPOS ELSE PPOS = 0
          IF PPOS THEN
             IF CUS.BR<17,PPOS> # '' THEN
                FAX.PHONE = '  Fax ':CUS.BR<17,PPOS>
             END ELSE FAX.PHONE = ''
          END ELSE FAX.PHONE = ''
          BR.ADDR<-1> = CUS.BR<17,1>:FAX.PHONE
          BT.CN  = LED(1)<1,GEN>
          ST.CN  = LED(5)<1,GEN>
          GET.CUS BR,BT.CN,ST.CN,QSIGN
          INVN    = LED(8)<1,GEN> + 0

          IF INVN=0 THEN
             PRT.LDIDS = LED(49)
             CONVERT VM TO AM IN PRT.LDIDS
          END ELSE
             PRT.LDIDS = LED(48)<1,GEN>
             CONVERT SVM TO AM IN PRT.LDIDS
          END

          IF NOT(PRT.ON) THEN
             PRINTER.ON "BID",RPT.DFLT=DRPT
          END


          *** Check if user has the control record set to enable printing
          *** all gens on the acknowledgement
          READ ALL.FRST.PRT FROM CTRLFILE,'FRST.PRT.ALL.GENS' ELSE ALL.FRST.PRT = ''
          *** If control record is set to 'Y' then set the FRST.PRT.FL to
          *** yes.  If flag is set, then all gens will be displayed on the
          *** first print.

          IF ALL.FRST.PRT THEN FRST.PRT.FL = YES ELSE FRST.PRT.FL = NO

          *** Check if this is the First Print, if this is the first print
          *** in the acknowledgement, display all gens. If not the
          *** first print, display the gen specific one.
          IF FRST.PRT.FL THEN
             READV PRT.HIST FROM LEDLFILE,OID,1 ELSE PRT.HIST = ''
             PRT.HIST = RAISE(PRT.HIST)
             LOCATE 'S' IN PRT.HIST SETTING ACK.POS ELSE ACK.POS = ''
             IF ACK.POS THEN FRST.PRT.FL = NO
          END

          PRINT.GENS = TRANS('LEDGER.GPS',OID,6,'X')
          IF PRINT.GENS = 'Yes' THEN
          FRST.PRT.FL = YES
          END


          IF FRST.PRT.FL = YES THEN
             ALL.GENS = YES
             PRINT.LDIDS = ''
          END ELSE
             ALL.GENS = ''
          END




          GOSUB INIT
DI = 1
          LDID.CT = DCOUNT(PRT.LDIDS,AM)

          FOR LD.NO = 1 TO LDID.CT
             LDID   = PRT.LDIDS<LD.NO>

             IF ALL.GENS THEN
                NUM.GENS = DCOUNT(LED(1)<1>,VM)
                FOR GX = 1 TO NUM.GENS
                   GEN.LDIDS = RAISE(RAISE(LED(48)<1,GX>))
                   GSTAT     = LED(6)<1,GX>
                   *** Add ldid unless it is a direct or cancelled
                   IF GSTAT # 'X' AND GSTAT # 'Y' AND GSTAT#'B' THEN
                      LOCATE LDID IN PRINT.LDIDS SETTING LPOS ELSE
                         *** Add LDID if another gen hasn't already
                         LD.GEN = GX
                         PRINT.LDIDS<-1> = LDID
                         GOSUB PRT.LINE
                      END
                   END
SKIPGN:         NEXT GX
             END ELSE
                GOSUB PRT.LINE
             END
          NEXT LD.NO

          GEN = SV.GEN

*---------
*LOT
          IF LOT.FLAG THEN
             RUNNING.TOTAL = COL.TOTAL<1,COL.CT>
       *     OE.LOT.GET.XCURR ,S.XRATE
       *     RUNNING.TOTAL = OCONV(LD(67)<1,1>/S.XRATE,'MR9')
          END ELSE
             RUNNING.TOTAL = COL.TOTAL<1,COL.CT,1>
          END

          IF NOT(NO.TOLS) THEN
             GOSUB PRINT.TOTALS
             IF STATUS = 'B' THEN
                BLINE += 1
                TOTAL.COMMENT = 'TAXES NOT INCLUDED'
                PRT.STR = SPACE(TOTAL.SPACES-LEN(TOTAL.COMMENT)-12)
                PRT.STR = PRT.STR:TOTAL.COMMENT
                BOD<BLINE> = PRT.STR
             END
          END
          GOSUB ADD.FTR
          PGS = INT((BLINE + BOD.LINES-1)/BOD.LINES)

          PRINT CHAR(27):"&l1e6D":NORM:
          GOSUB HEADER
          GOSUB PRTBOD

          IF NOT(PRT.ON) THEN
             PRINTER.OFF
          END

          GOTO FINISH
*-------------------------------------------------------------------------*
INIT:     *
          PAGE    = 0
          BO.CT   = 0
          LINE.CT = 0
* Prepass for subtotal pricing detail Y/N
          NO.PRICING  = ''

          SLPI       = CHAR(27):"&l6D"
          ELPI       = CHAR(27):"&l8D"

          SMALL      = CHAR(27):'(8U'
          SMALL     := CHAR(27):'(s0p16.67h8.5v0s0b0T'
          MED        = CHAR(27):"(8U":CHAR(27):'(s0p12h0s3b3T'
          SUP.SMALL  = CHAR(27):"(8U":CHAR(27):'(s0p20h0s0b0T'
          NORM       = CHAR(27):'(8U'
          NORM      := CHAR(27):'(s0p10h12v0s0b3T'
          NORM.BOLD  = CHAR(27):'(8U'
          NORM.BOLD := CHAR(27):'(s0p10h12v0s1b3T'
          LARGE      = CHAR(27):'(8U'
          LARGE     := CHAR(27):'(s1p10h14v0s3b3T'
          XLARGE     = CHAR(27):'(8U'
          XLARGE    := CHAR(27):'(s0p8h8v0s3b3T'

          FRST.DET   = 1
          LD.CT = DCOUNT(PRT.LDIDS,AM)
          FOR LD.NO = 1 TO LD.CT
          LDID  = PRT.LDIDS<LD.NO>
          LD.GET LDID
          IF LD(1)='S' THEN
             IF LD(21) = '' THEN
* NO PRICING
                FOR DL = FRST.DET TO LD.NO
                NO.PRICING<DL> = YES
                NEXT DL
             END
             FRST.DET = LD.NO + 1
          END
          NEXT LD.NO
          INV.AMT    = LED(15)<1,GEN>
          BOD        = ''
          BLINE      = 0
          PRINT.PICK = NO
          CASH.SALE  = NO
          SSPC       = 21
          BEGIN CASE
          CASE CHANGE.FLAG
             DOC.ID   = "Change Order Acknowledgement"
             ORD.ID   = OID
             DOC.TYPE = "B"
          CASE STATUS = 'B'
             DOC.ID   = 'Quotation'
             ORD.ID   = OID
             DOC.TYPE = 'B'
          CASE OTHERWISE
             IF INV.AMT <= 0 THEN
                DOC.ID   = 'Acknowledgement'
             END ELSE
                DOC.ID   = ' Return Goods'
             END
             ORD.ID   = OID
             DOC.TYPE = 'S'
          END CASE
          SOE.CREDIT.CHECK ST.CN,,COD,PRT.MSG,NO.SHIP,,,OID,GEN
          IF COD THEN
             COD.MSG = '** C.O.D. ** C.O.D. ** C.O.D. **'
          END ELSE
             COD.MSG = ''
          END

          IF DRPT<27>='HOLD' THEN
             USE.DOC.TYPE = DOC.TYPE:VM:1
          END ELSE
             USE.DOC.TYPE = DOC.TYPE
          END

          OE.LOG.PRINT OID,GEN,USE.DOC.TYPE,DOC.ID,REPRINT

   * Get Print style record
          BEGIN CASE
          CASE CHANGE.FLAG
             * Change order Acknowledgements only respect BLIND, BLIND.TOT,
             * and BID print styles
             BEGIN CASE
             CASE PSTYLE.OVRD = 'CO.BLIND'
                STYLE.ID = 'CO.BLIND'
             CASE PSTYLE.OVRD = 'CO.BTOT'
                STYLE.ID = 'CO.BTOT'
             CASE OTHERWISE
                STYLE.ID = 'BID'
             END CASE
          CASE PSTYLE.OVRD#''
             STYLE.ID = PSTYLE.OVRD
          CASE LED(77)<1,GEN>
             STYLE.ID = LED(77)<1,GEN>
          CASE OTHERWISE
             STYLE.ID = 'BID'
          END CASE

          IF STYLE.ID= 'B' OR STYLE.ID= 'BLIND' THEN
             STYLE.ID = 'BID'
          END

          GOSUB GET.PSTYLE

          DOC.FORM.SPEC = ''
          IF CHANGE.FLAG THEN
             CONTROL.FILE = 'ACK.CO.FORM'
          END ELSE
             CONTROL.FILE = 'ACK.FORM'
          END
          READ DOC.FORM.REC FROM CTRLFILE,CONTROL.FILE ELSE DOC.FORM.REC = ''

          NO.TOLS  = NOT(COL.EXTDS<1,COL.CT>)

          IF DOC.FORM.REC THEN
             GOSUB CNVRT.FORM
          END

          BEGIN CASE
          CASE STATUS = 'B'
             COLUMN.HEADING = 'Quote Qty     Product Description '
          CASE OTHERWISE
             COLUMN.HEADING = " Ordered              Product Description"
          END CASE
    * Compile column heading line from print style record
          TOTAL.SPACES = COL.START
          FMT = 'L#':COL.START
          COLUMN.HEADING = COLUMN.HEADING FMT
          FOR COL = 1 TO COL.CT
          LGTH = FIELD(COL.FRMTS<1,COL>,'#',2)+0
          FRMT = 'L#':LGTH
          IF COL=COL.CT THEN
             TOTAL.FRMT = COL.FRMTS<1,COL>
          END ELSE
             TOTAL.SPACES = TOTAL.SPACES + LGTH
          END
          COLUMN.HEADING = COLUMN.HEADING:COL.HEADS<1,COL> FRMT
          NEXT COL
          TOTAL.FMT = 'L#':TOTAL.SPACES

          NET.TOLS = (COL.BASIS<1,COL.CT>=1 OR COL.BASIS<1,COL.CT>=2)

          GOSUB GET.TOTALS
          PRINT.CREDIT.MSG = NO
          IF PRINT.CREDIT.MSG THEN
             FT.LGTH  += 3
          END

          CUS.PO   = LED(13)<1,GEN>
          REL.NO   = LED(65)<1,GEN>

          FRGHT.ALLW=LED(69)<1,GEN,1>
          IF FRGHT.ALLW THEN
             FRGT = 'Yes'
          END ELSE
             FRGT = 'No'
          END

          SALESMAN = LED(72)<1,GEN>
          READV SALESMAN FROM INIFILE,SALESMAN,3 ELSE NULL
          WRITER   = LED(73)<1,GEN>
          READV WRITER FROM INIFILE,WRITER,3 ELSE NULL
          ORD.BY =  LED(68)<1,GEN>
*         READV ORD.BY FROM INIFILE,ORD.BY,3 ELSE NULL
          SHIP.VIA = LED(70)<1,GEN>
          ORD.DATE = LED(4)<1,GEN>
          SHP.DATE = LED(9)<1,GEN>
          REQ.DATE = OCONV(LED(10)<1,GEN> ,'D2/')
          EXP.DATE = LED(31)<1,GEN>
          PHONE.NO = CUS(17)<1,1>
          TERMS.ID = LED(29)<1,GEN>
          READV TERMS.DESC FROM TERMSFILE,TERMS.ID,1 ELSE TERMS.DESC=TERMS.ID
*B2B
          SHIP.ADDR = LED(78)<1,GEN,6>
          IF NOT(SHIP.ADDR) THEN SHIP.ADDR = CUSS(1)
          IF LED(78)<1,GEN,1> THEN SHIP.ADDR<-1>  = LED(78)<1,GEN,1>
          IF LED(78)<1,GEN,2> THEN SHIP.ADDR<-1>  = LED(78)<1,GEN,2>
          SHIP.ADDR<-1>  = TRIM(LED(78)<1,GEN,3>):" ":LED(75)<1,GEN>"L#10"

          BILL.ADDR = CUS(1)
          IF CUS(2)<1,1> THEN BILL.ADDR<-1> = CUS(2)<1,1>
          IF CUS(2)<1,2> THEN BILL.ADDR<-1> = CUS(2)<1,2>
          BILL.ADDR<-1> = TRIM(CUS(3)):", ":CUS(4)"L#4":CUS(5)

          SHP.INST = ''
*         SHP.INST = LED(74)<1,GEN>
          BO.FLAG   = YES

          IF SHP.INST<1,1,1> = "!NOBO" THEN
             BO.FLAG = NO
             SHP.INST    = DELETE(SHP.INST,1,1,1)
          END

          IF SHP.INST # '' THEN
             BLINE += 1
             BOD<BLINE> = SPACE(SSPC):'********* Shipping Instructions **********'
             CT = DCOUNT(SHP.INST,SVM)
             FOR JJ = 1 TO CT
                BLINE += 1
                BOD<BLINE> = SPACE(SSPC):'* ':SHP.INST<1,1,JJ>"L#38":' *'
             NEXT JJ
             BLINE += 1
             BOD<BLINE> = SPACE(SSPC):STR('*',42)
          END

          WHSE.MSG = 'Shp ':SHIP.BR "L#4": 'Prc ':BR "L#3"

          IF STATUS # 'B' THEN ORD.MSG = 'ORDER' ELSE ORD.MSG = 'QUOTE'

          IF LED(61)<1,GEN> THEN
             TAX.MSG = 'N'
          END ELSE
             TAX.MSG = 'Y'
          END

          PRT.TIME =  TIMEDATE()
          BO.PNS   = ''

          RETURN
*-------------------------------------------------------------------------*
GET.PSTYLE: *
    * Get Print style record
          MATREAD PSTYL FROM PSTYLFILE,STYLE.ID ELSE
             MATREAD PSTYL FROM PSTYLFILE,'DEFAULT' ELSE
                MAT PSTYL = ''
                PSTYL(3) = 69
                PSTYL(4) = 'R2#10'
                PSTYL(5) = 1
                PSTYL(6) = 1
                PSTYL(7) = 'Net Price'
             END
          END
          COL.START = PSTYL(3)
          COL.FRMTS = PSTYL(4)
          COL.BASIS = PSTYL(5)
          COL.EXTDS = PSTYL(6)
          COL.HEADS = PSTYL(7)
          ALT.DESC  = PSTYL(8)
          *ALL.GENS  = PSTYL(9)
          COL.CT    = DCOUNT(COL.BASIS,VM)
          COL.TOTAL = ''
          SUB.TOTAL = ''
          SUBT.SW   = NO

          RETURN
*-------------------------------------------------------------------------*
CNVRT.FORM: * Convert the values we picked up from our Form overlay
            * Control Record AND from the Print Style Id we're using,
            * that was set up in Print Style Maintenance...

*** Get data out from the Form Overlay Control Record we're using...

          *** We should find this string in the Row where our Invoice's
          *** data columns were set up...
          FINDSTR '@PRINT.STYLE' IN DOC.FORM.REC SETTING AMC THEN
             *** Get the Print Style Width....
             FORM.STYLE.WIDTH = FIELD(DOC.FORM.REC<AMC>,',',2)
             *** Initialize our Total Width to be the Print Style Width...
             TOTAL.WIDTH      = FORM.STYLE.WIDTH

             TAMC = AMC - 1
             *** Go through each data column that's been set up in the
             *** current row...
             LOOP
             UNTIL DOC.FORM.REC<TAMC>[1,1] # '"' DO
             *** Add the width from each column to our Total Width...
             TOTAL.WIDTH += FIELD(DOC.FORM.REC<TAMC>,',',2)
             TAMC -= 1
             REPEAT

             *** Set our Start Column, where we'll be printing the values
             *** determined by our print style Id...
             COL.START    = TOTAL.WIDTH - FORM.STYLE.WIDTH
             DEL DOC.FORM.REC<AMC>

*** Now we'll go through the columns that were set up for the Print
*** Style Id we're using (set up in Print Style Maintenance)...

             STYLE.WIDTH  = 0
             WIDTH.INSERT = ''

             FOR CC = 1 TO COL.CT
             TWIDTH           = FIELD(COL.FRMTS<1,CC>,'#',2)
             WIDTH.INSERT<CC> = TWIDTH
             STYLE.WIDTH     += TWIDTH
             NEXT CC

             BEGIN CASE
             *** If the actual width of our Print Style Id columns is less
             *** than the width that our Form Overlay Control Record
             *** stated that it needed to be...
             CASE STYLE.WIDTH < FORM.STYLE.WIDTH
                CC = COL.CT
                LOOP
                UNTIL STYLE.WIDTH >= FORM.STYLE.WIDTH DO
                *** Increase a columns width...
                WIDTH.INSERT<CC> += 1
                NEW.FRMT  = FIELD(COL.FRMTS<1,CC>,'#',1):'#'
                NEW.FRMT := WIDTH.INSERT<CC>
                COL.FRMTS<1,CC> = NEW.FRMT

                CC -= 1
                *** If we've already increased each columns width
                *** once, start with the first one again...
                IF CC < 1 THEN CC = COL.CT
                STYLE.WIDTH += 1
                REPEAT
             *** If the actual width of our Print Style Id columns is
             *** greater than the width that our Form Overlay Control
             *** Record stated that it needed to be...
             CASE STYLE.WIDTH > FORM.STYLE.WIDTH
                CC = 1
                LOOP
                UNTIL STYLE.WIDTH <= FORM.STYLE.WIDTH DO
                *** Decrease a columns width...
                WIDTH.INSERT<CC> -= 1
                NEW.FRMT  = FIELD(COL.FRMTS<1,CC>,'#',1):'#'
                NEW.FRMT := WIDTH.INSERT<CC>
                COL.FRMTS<1,CC> = NEW.FRMT

                CC += 1
                *** If we've already decreased each columns width
                *** once, start with the first one again...
                IF CC > COL.CT THEN CC = 1
                STYLE.WIDTH -= 1
                REPEAT
             END CASE

             FOR CC = 1 TO COL.CT
                IF COL.HEADS<1,CC> = '' THEN COL.HEADS<1,CC> = ' '
                TINSERT  = '"':COL.HEADS<1,CC>:'",'
                TINSERT := WIDTH.INSERT<CC>

                INS TINSERT BEFORE DOC.FORM.REC<AMC+CC-1>
             NEXT CC

             FTR.TEXT.LGTH = 79-WIDTH.INSERT<COL.CT>
             FTR.FMT       = 'R2#':WIDTH.INSERT<COL.CT>
          END

          RETURN
*-------------------------------------------------------------------------*
HEADER:   *
          PAGE    = PAGE + 1
          LINE.CT = PG.LGTH
          IF FAX.FLAG THEN
*            PRINT '@+INCLUDE[/usr/vsifax/eclipse/docs/INV,ul-down]'
*            PRINT CHAR(27):"*p0Y":
          END

          *** Print the macro
          MACRO.ID = 'ACK~':STYLE.ID
          GOSUB SET.MACRO

            IF BR = '5' THEN
          PRINT CHAR(27):"*p25y*p50X":
          PTR.MACRO.PRINT ERR.MSG, 'KIV_PICK', DRPT
          PRINT CHAR(27):"*p0Y":
          PRINT NORM:SLPI:
          PRINT ; PRINT
          END ELSE
          PRINT CHAR(27):"*p25y*p50X":
          PTR.MACRO.PRINT ERR.MSG, 'PICK', DRPT
          PRINT CHAR(27):"*p0Y":
          PRINT NORM:SLPI:
          PRINT ; PRINT
          END

          PRINT CHAR(27):"*p0Y":
          PRINT NORM:SLPI:
          PRINT
          PRINT
          PRINT SPACE(72-LEN(DOC.ID)):XLARGE:DOC.ID:NORM

          PRINT CHAR(27):"*p50Y":SLPI

            IF BR = '5' THEN
          PRINT ''
          PRINT ''
          PRINT ''
          PRINT ''
          PRINT ''
          FOR KK = 2 TO 5
             PRINT '' "L#1":LARGE:  BR.ADDR<KK>:NORM
          NEXT KK
          END ELSE
          PRINT ''
          PRINT ''
          PRINT ''
          FOR KK = 1 TO 5
             PRINT '' "L#1":LARGE:  BR.ADDR<KK>:NORM
          NEXT KK
          END





          PRINT CHAR(27):"*p165Y":SLPI
          PRINT
          PRINT
          PRINT '' "L#57" :OCONV(ORD.DATE,'D2/')   "L#10":
          PRINT ORD.ID                             "L#16"

          PRINT CHAR(27):"*p315Y"
          PRINT '' "L#57":SMALL:"ORDER TO:":NORM:ELPI
          PRINT '' "L#57":SUP.SMALL:BR.ADDR<1> "L#30":NORM
          PRINT '' "L#57":SUP.SMALL:BR.ADDR<2> "L#30":NORM
          PRINT '' "L#57":SUP.SMALL:BR.ADDR<3> "L#30":NORM:PAGE  "R#5"
          PRINT '' "L#57":SUP.SMALL:BR.ADDR<4> "L#30":NORM
          PRINT CHAR(27):"*p490Y":SLPI

*         PRINT '' "L#48":SUP.SMALL:"Past due invoices may be subject to 1.5% late charge":NORM

          PRINT CHAR(27):"*p565Y":SLPI
          IF STATUS='B' THEN
             PRINT SPACE(9):SMALL:"QUOTE TO:":NORM:
          END ELSE
             PRINT SPACE(9):SMALL:"SOLD TO:":NORM:
          END
          PRINT CHAR(27):"*p565Y":SLPI
          PRINT SPACE(47):SMALL:"SHIP TO:":NORM

          FOR KK=1 TO 4
          PRINT SPACE(9):BILL.ADDR<KK>'L#38': SHIP.ADDR<KK>  "L#30"'L#30'
          NEXT KK

*------Header Info------*
          PRINT CHAR(27):"*p890Y"
          PRINT
          PRINT
          PRINT '    ':ST.CN          'L#9 ':
          PRINT CUS.PO                'L#22 ':
          PRINT REL.NO                'L#21 ':

*         PRINT ORD.WITH              'L#19 ':
*         PRINT BR                    'R#2'

          PRINT
          PRINT
          PRINT
          PRINT ' ':WRITER            'L#22 ':
          PRINT SHIP.VIA              'L#17 ':
          PRINT TERMS.DESC            'L#16 ':
          PRINT OCONV(SHP.DATE,'D2/') 'L#10 ':
          PRINT FRGT
          PRINT
          BO.HEADING = NO

          RETURN
*-------------------------------------------------------------------------*
PRTBOD:   *
          PLINE = 1
          LINEX = 0
          LOOP
          LINEX += 1
          IF LINEX > BLINE THEN EXIT
          IF PLINE > BOD.LINES THEN GOSUB TOP; PLINE=1
          PRINT BOD<LINEX>
          PLINE += 1
          REPEAT

          FOR X = PLINE TO BOD.LINES
          PRINT
          NEXT X
          GOSUB FOOTER

          RETURN
*-------------------------------------------------------------------------*
TOP:    *
          PRINT "     *** Continued on Next Page ***"
          GOSUB FFEED
          GOSUB HEADER

          RETURN
*-------------------------------------------------------------------------*
* NEW SUBTOTALS LOGIC 02/10/00 - FROM SG PLUMBING
*-------------------------------------------------------------------------*
SUBTOTALS:*
          PRT.STR1 = SPACE(COL.START)
          PRT.STR2 = SPACE(COL.START-LEN(SUBT.DESC)):SUBT.DESC
          FOR COL = 1 TO COL.CT
          LGTH = FIELD(COL.FRMTS<1,COL>,'#',2)

          *** Now find the exchange rate for the GN passed in.
          IF LED(92)<1,GEN,2> THEN
             XRATE = OCONV(LED(92)<1,GEN,2>,'MR4')
          END ELSE
             XRATE = 1
          END

          IF COL.EXTDS<1,COL> THEN
             PRT.STR1 = PRT.STR1:STR('-',LGTH)
             IF SUBT.SW THEN
                PRT.STR2 = PRT.STR2:(OCONV(LD(8)<1,GEN>/XRATE,'MR2')*QSIGN) COL.FRMTS<1,COL>
             END
          END ELSE
             IF COL = 2 THEN
                PRT.STR1 = PRT.STR1:STR('-',LGTH)
                PRT.STR2 = PRT.STR2:(OCONV(LD(8)<1,GEN>/XRATE,'MR2')*QSIGN) COL.FRMTS<1,COL>
             END ELSE
                PRT.STR1 = PRT.STR1:SPACE(LGTH)
                PRT.STR2 = PRT.STR2:SPACE(LGTH)
             END
          END
          NEXT COL

          BLINE += 1
          BOD<BLINE> = PRT.STR1
          BLINE += 1
          BOD<BLINE> = PRT.STR2

          RETURN
*-------------------------------------------------------------------------*
GET.TOTALS: *

             PRINT.GENS = TRANS('LEDGER.GPS',OID,6,'X')
             IF PRINT.GENS = 'Yes' THEN
             FRST.PRT.FL = YES
             END



          IF FRST.PRT.FL THEN
             AMT.PAID  = 0
             CASH.DISC = 0

             GEN.CT = DCOUNT(LED(1)<1>,VM)
             FOR GX = 1 TO GEN.CT
                GSTAT  = LED(6)<1,GX>
                IF GSTAT # 'X' AND GSTAT # 'Y' AND GSTAT # 'B' THEN
                   SOE.CALC.CASH OID,GX,,AMT.PAIDX,CASH.DISCX
                   AMT.PAID  += AMT.PAIDX
                   CASH.DISC += CASH.DISCX
                END
             NEXT GX
          END ELSE
             SOE.CALC.CASH OID,GEN,AMT.DUE,AMT.PAID,CASH.DISC
          END
          * Get WOE.DISC for Web orders
          SOE.CALC.DISC OID,GEN,,,WOE.DISC



          ** If first print flag is set, get totals for all gens
          IF FRST.PRT.FL THEN
             FREIGHT  = 0
             HANDLING = 0
             TAX.AMT  = 0
             FET.AMT  = 0


             FOR GX = 1 TO GEN.CT
                *** Don't add if gen is invoiced, PO, or cancelled

                IF LED(8)<1,GX>+0 # 0 OR LED(6)<1,GX> = 'Y' OR LED(6)<1,GX> = 'X' OR LED(6)<1,GX> = 'B' THEN CONTINUE
                OE.ORDER.TOTAL OID,GX,QSIGN,TOTALX,SUB.TOLX,FREIGHTX,HANDLINGX,TAX.AMTX,FET.AMTX
                FREIGHT  += FREIGHTX
                HANDLING += HANDLINGX
                TAX.AMT  += TAX.AMTX
                FET.AMT  += FET.AMTX
             NEXT GX
          END ELSE
             OE.ORDER.TOTAL OID,GEN,QSIGN,,,FREIGHT,HANDLING,TAX.AMT,FET.AMT
          END
          IF STATUS='B' THEN CASH.DISC = 0
          AMT.PAID  = OCONV(AMT.PAID,'MR2')
          FREIGHT   = OCONV(FREIGHT,'MR2')
          HANDLING  = OCONV(HANDLING,'MR2')
          TAX.AMT   = OCONV(TAX.AMT,'MR2')
          CASH.DISC = OCONV(CASH.DISC,'MR2')

  * Find service Charges , put in OE.ORDER.TOTAL when possible
          LOCATE 'SC' IN LED(24)<1,GEN> SETTING POS THEN
             SERV.CHRG = -OCONV(LED(26)<1,GEN,POS>,'MR2')
          END ELSE
             SERV.CHRG = 0
          END

          RETURN
*-------------------------------------------------------------------------*
PRINT.TOTALS: *
*         IF FREIGHT THEN
*            TOTAL.COMMENT = 'Freight'
*            TOTAL.AMT     = FREIGHT
*            GOSUB PRINT.TOTAL
*            RUNNING.TOTAL += TOTAL.AMT
*         END
*         IF HANDLING THEN
*            TOTAL.COMMENT = 'Handling'
*            TOTAL.AMT     = HANDLING
*            GOSUB PRINT.TOTAL
*            RUNNING.TOTAL += TOTAL.AMT
*         END
          IF SERV.CHRG THEN
             TOTAL.COMMENT = 'Service Charge'
             TOTAL.AMT     = SERV.CHRG
             GOSUB PRINT.TOTAL
             RUNNING.TOTAL += TOTAL.AMT
          END

*         GOSUB PRINT.TOTAL.LINE
*         IF STATUS='B' THEN
*            TOTAL.COMMENT = 'Quote Total'
*         END ELSE
*            TOTAL.COMMENT = 'Invoice Amount'
*         END
*         TOTAL.AMT     = RUNNING.TOTAL
*         GOSUB PRINT.TOTAL

          * If there is a web order discount then display the web
          * order discount and add  to Running Total.
          IF DOC.TYPE = 'S' THEN
             IF WOE.DISC THEN
                   TOTAL.COMMENT = 'Web Order Discount'
                   TOTAL.AMT = OCONV(WOE.DISC,'MR2')
                   GOSUB PRINT.TOTAL
                   RUNNING.TOTAL += TOTAL.AMT
                   WOE.DISC = 0
             END
          END

          PRINT.AMT.DUE = NO

          IF AMT.PAID THEN
             PRINT.AMT.DUE = YES
             IF LED(8)<1,GEN>='' THEN
                TOTAL.COMMENT = 'Less cash paid'
                TOTAL.AMT     = AMT.PAID
                GOSUB PRINT.TOTAL
                RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
             END ELSE
                AR.ID = OID:'.':LED(8)<1,GEN>"R%3"
                SOE.PAYMENTS.DISC AR.ID,PAY.IDS,PAY.DTS,PAY.AMTS,DISC.TAKEN
                IF DISC.TAKEN THEN
                   TOTAL.COMMENT = 'Less discount taken'
                   TOTAL.AMT     = OCONV(DISC.TAKEN,"MR2")
                   CASH.DISC     = 0
                   GOSUB PRINT.TOTAL
                   RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
                END
                PCT = DCOUNT(PAY.IDS,VM)
                FOR PYN = 1 TO PCT
                PAY.ID  = PAY.IDS<1,PYN>
                PAY.DT  = PAY.DTS<1,PYN>
                PAY.AMT = PAY.AMTS<1,PYN>
                IF PAY.DT=DATE() THEN
                   TOTAL.COMMENT = 'Amount paid today # ':PAY.ID
                END ELSE
                   TOTAL.COMMENT = 'Prior Deposit on ':OCONV(PAY.DT,'D2/')"L#8"
                END
                TOTAL.AMT = OCONV(PAY.AMT,"MR2")
                GOSUB PRINT.TOTAL
                RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
                NEXT PYN
             END
          END

*         IF PRINT.AMT.DUE THEN
*            GOSUB PRINT.TOTAL.LINE
*            TOTAL.COMMENT = '** AMOUNT DUE **'
*            TOTAL.AMT     = RUNNING.TOTAL
*            GOSUB PRINT.TOTAL
*         END

          RETURN
*-------------------------------------------------------------------------*
PRINT.TOTAL: *
          PRT.STR = TOTAL.COMMENT"R#56" TOTAL.FMT
          PRT.STR = PRT.STR:TOTAL.AMT TOTAL.FRMT
          BLINE += 1
          BOD<BLINE> = PRT.STR

          RETURN
*-------------------------------------------------------------------------*
PRINT.TOTAL.LINE: *
          LGTH = FIELD(TOTAL.FRMT,"#",2)
          PRT.STR = SPACE(TOTAL.SPACES):STR('-',LGTH)
          BLINE += 1
          BOD<BLINE> = PRT.STR

          RETURN
*-------------------------------------------------------------------------*
PRT.LINE: *
          LD.GET LDID
          PN = LD(1)

          * Include Job Management Items
          JM.ITEM = (PN[1,2] = "L#")

          IF (CHANGE.FLAG) THEN
             READV PSTAT FROM PRDFILE,PN,3 ELSE PSTAT = ""
             IF (PSTAT = 9) THEN
                LOT.FLAG = YES
             END ELSE
                LOT.FLAG = NO
             END
          END

          BEGIN CASE
          CASE NUM(PN) OR JM.ITEM
             IF FRST.PRT.FL THEN
                QS = 0
                GEN.CT = DCOUNT(LED(1)<1>,VM)
                *** Loop through each gen to get correct LDIDS
                FOR GX = 1 TO GEN.CT
                   GEN.LDIDS = RAISE(RAISE(LED(48)<1,GX>))
                   GSTAT     = LED(6)<1,GX>
                   IF GSTAT # 'X' AND GSTAT # 'Y' AND GSTAT # 'B' THEN
                      QS += (SUM(LD(5)<1,GX>) + SUM(LD(6)<1,GX>)) * QSIGN
                   END
                NEXT GX
             END ELSE
                QS = (SUM(LD(5)<1,GEN>) + SUM(LD(6)<1,GEN>)) * QSIGN
             END
             IF QS # 0 THEN GOSUB PRT.PN
          CASE PN = 'C'
             OE.DESC.GET DESC,ALT.DESC,"SOE Printing"
             GOSUB PRT.XDESC
*LOT
          CASE PN = 'S'
             IF NOT(LOT.FLAG) THEN
                SUBT.SW   = YES
                GOSUB PRT.SUBT
                SUBT.SW   = NO
                SUB.TOTAL = ''
             END
          END CASE

          RETURN
*-------------------------------------------------------------------------*
PRT.PN:   *
          TOT.QS = QS
          LINE.CT    += 1
          GET.ALL.PRD BR,PN,QSIGN,GROUP

          *** If this is the First Print, display all gens, if not, display
          *** the gen that was specified by user
          IF FRST.PRT.FL THEN
             *** Build location list for all gens without duplicates
             SHP.TYP.LOCS = ''
             GEN.CT = DCOUNT(LED(1)<1>,VM)
             FOR GX = 1 TO GEN.CT
                GSTAT = LED(6)<1,GX>
                IF GSTAT # 'X' AND GSTAT # 'Y' AND GSTAT # 'B' THEN
                   LCT = DCOUNT(LD(7)<1,GX>,SVM)
                   FOR LX = 1 TO LCT
                      TLOC = LD(7)<1,GX,LX>
                      LOCATE TLOC IN SHP.TYP.LOCS<1,1> SETTING FOUND ELSE
                         SHP.TYP.LOCS<1,1,-1> = TLOC
                      END
                   NEXT LX
                END
             NEXT GX
          END ELSE
             SHP.TYP.LOCS = LD(7)<1,GEN>
          END

          LOC.CT    = DCOUNT(SHP.TYP.LOCS,SVM)
          IF STATUS = 'B' THEN LOC.CT = 1

          *** Check whether the product is flagged for Serial Number
          *** Tracking at the Shipping Branch...
          PRD.BR.GET.VAL SHIP.BR,PN,25,SERIAL.TRACKING

          FOR LOC = 1 TO LOC.CT
             SHP.TYP.LOC = SHP.TYP.LOCS<1,1,LOC>


             IF STATUS # 'B' THEN
                *** If this is the First Print, get sum for all gens, if
                *** not, sum for the gen user specified
                IF FRST.PRT.FL THEN
                   QS = 0
                   *** Loop through gens finding any with this location
                   FOR GX = 1 TO GEN.CT
                      GSTAT = LED(6)<1,GX>
                      IF GSTAT # 'X' AND GSTAT # 'Y' AND GSTAT # 'B' THEN
                         *** Add the qty for this location on this gen
                         LOCATE SHP.TYP.LOC IN LD(7)<1,GX> SETTING LPOS THEN
                            QS += ((LD(5)<1,GX,LPOS>) + (LD(6)<1,GX,LPOS>))*QSIGN
                         END
                      END
                   NEXT GX
                END ELSE
                   QS = ((LD(5)<1,GEN,LOC> + LD(6)<1,GEN,LOC>)) * QSIGN
                END
             END

             IF QS=0 THEN GOTO NO.PTR

             OE.DESC.GET DESC,ALT.DESC,"SOE Printing"
             CUT.PRODUCT.CHK.DESC DESC,"SOE Printing",QS
             IF LD(36)<1,GEN,1>#'' THEN DESC<1,-1> = LD(36)<1,GEN,1>

             IF STATUS # 'B' AND SERIAL.TRACKING AND SERIAL.TRACKING # 'N' THEN
                FOR XX=1 TO QS
                   DESC<1,-1> = 'Serial#____________________________'
                NEXT XX
             END

*----Kits
             IF LD(31)#'' AND LD(38)<1,2> = '1' THEN
                KCMPS = LD(31)
                KQTYS = LD(30)
                KCMTS = LD(37)
                GET.KIT.COMPS.LOC.ALT KCMPS,KQTYS,KCMTS,45,DESC,SHIP.BR,ALT.DESC,GEN,QS
             END
              IF NOT(LED(8)<1,GEN>) THEN
                QOPEN = TOT.QS
                DQS    = ''
             END ELSE
                OE.CALC.QOPEN OID,QSIGN,QOPEN
                IF LED(8)<1,GEN> THEN
                   QOPEN += (SUM(LD(5)<1,GEN>) + SUM(LD(6)<1,GEN>)) * QSIGN
                END
                DQS = QS
             END
*LOT
             IF LOT.FLAG THEN
                DQS   = 1
                QS    = 1
                QOPEN = 1
             END

             SHP.TYP.LOC = SHP.TYP.LOCS<1,1,LOC>
             LOCA    = FIELD(FIELD(SHP.TYP.LOC,'~',2),'^',1)
             TAG     = FIELD(SHP.TYP.LOC,'^',2)
             TYPE    = FIELD(SHP.TYP.LOC,'~',1)
             IF LOCA = 'WHSE' THEN PRINT.PICK = YES
             IF TYPE = 'T' THEN
                 DESC<1,-1> = '<<** ':QS:' Tagged to ':TRIM(TAG):' **>>'
                 LOCA = ''
             END

             BEGIN CASE
             CASE QS<0 AND TYPE='F';  LOCA = '**DEF '
             CASE QS>0 AND TYPE='D';  LOCA = '**DIR '
             CASE QS<0;               LOCA = '**RTN '
             END CASE

             IQ.TO.ALPHA PLNE(3),PRD(7),LD(23),QS,Q1,U1,Q2,U2,QO.ALPHA
             *IF LOC > 1 THEN QO.ALPHA = '"'
             PRT.STR = TRIM(QO.ALPHA)      "R#10"
             PRT.STR := PN                 "R#10 "
             PRT.STR = PRT.STR:DESC<1,1>   "L#35"
             SAVE.LINE = PRT.STR
*LOT
              IF LOT.FLAG THEN
                 *** Use LD.GEN to get the correct pricing when the
                 *** Print All Gens flag is active
                FORMS.GET.LOT.PRC "ACK",LDID,LD.GEN,ALL.GENS,UNT.PRC
                IF STYLE.ID = 'BID' OR NOT(CHANGE.FLAG) THEN
                   PRT.STR := UNT.PRC "R3#12"
                   PRT.STR := UNT.PRC "R2#11"
                END ELSE
                   PRT.STR := '' 'R#12'
                   PRT.STR := '' 'R#11'
                END
                IF STYLE.ID = 'CO.BLIND' THEN
                   COL.TOTAL<1,COL.CT> += ''
                END ELSE
                   COL.TOTAL<1,COL.CT> += UNT.PRC
                END
             END ELSE
                *** Use LD.GEN to get the correct pricing when the
                *** Print All Gens flag is active
                OE.GET.PSTYLE OID,LD.GEN,COL.START,COL.FRMTS,COL.BASIS,COL.EXTDS,COL.CT,QS,PRT.STR,COL.TOTAL,SUB.TOTAL
             END

             IF NO.PRICING<LD.NO> THEN PRT.STR = SAVE.LINE
             BLINE += 1
             BOD<BLINE> = PRT.STR
             DESC    = DELETE(DESC,1,1)
             GOSUB PRT.XDESC

NO.PTR:   NEXT LOC
*LOT
          IF LOT.FLAG THEN
             *** Use LD.GEN instead of GEN because the lot description
             *** depends on the order status, which must be taken from the
             *** gen that the lot item is on (not the main gen if the Print
             *** All Gens option is in effect)
             OE.LOT.PRINT.SETUP OID,LD.GEN,'S','A',BLINE,SSPC,BOD,,ALL.GENS,LDID
          END

          RETURN
*-------------------------------------------------------------------------*
PRT.XDESC: *
          DESC.CT = DCOUNT(DESC,VM)
          FOR DLN = 1 TO DESC.CT
             PRT.STR = SPACE(SSPC):DESC<1,DLN>
             IF TRIM(PRT.STR) THEN
                BLINE += 1
                BOD<BLINE> = PRT.STR
             END
          NEXT DLN

          RETURN
*-------------------------------------------------------------------------*
PRT.SUBT: *
          IF NOT(NO.TOLS) THEN
             SUBT.SW   = YES
             OE.DESC.GET DESC,ALT.DESC,"SOE Printing"
             SUBT.DESC = DESC<1,1>
             GOSUB SUBTOTALS
             DESC      = DELETE(DESC,1,1)
             GOSUB PRT.XDESC
             SUBT.SW   = NO
             SUB.TOTAL = ''
          END

          RETURN
*-------------------------------------------------------------------------*
ADD.FTR:  *
          IF NOT(NO.TOLS) THEN GOSUB PRT.OS

          IF FT.LGTH = 0 THEN RETURN
          PGS = INT((BLINE+BOD.LINES-1)/BOD.LINES)
          LAST.PG = PGS*BOD.LINES - BLINE
          IF LAST.PG >= FT.LGTH THEN
             ADD.LINES = LAST.PG - FT.LGTH
          END ELSE
             ADD.LINES = BOD.LINES + LAST.PG - FT.LGTH
          END
          FOR X = 1 TO ADD.LINES
          BLINE += 1
          BOD<BLINE> = ''
          NEXT X
          IF PRINT.CREDIT.MSG THEN
             BLINE += 1
             BOD<BLINE> = STR('+ ',35)
             BLINE += 1
             BOD<BLINE> = '+   Thank You For Your Business __________'
             BLINE += 1
             BOD<BLINE> = STR('+ ',35)
          END

          RETURN
*-------------------------------------------------------------------------*
PRT.OS:   *
* ORDER SUMMARY
          GN.CT     = DCOUNT(LED(6),VM)
          OS.MSG    = ''
          PAYMENTS  = 0
          PAID.BY   = ''
          SALES     = 0
          SHIP.CT   = 0

          FOR GN = 1 TO GN.CT
             STAT   = LED(6)<1,GN>
             IF STAT # 'X' AND STAT # 'Y' THEN
                IF STAT = '$' THEN
                   PAYMENTS -= SUM(LED(45)<1,GN>)
                   GOSUB ADD.PAYMT
                END ELSE
                   SHIP.CT  += 1
                   OE.ORDER.TOTAL OID,GN,QSIGN,GEN.TOTAL
                   SALES    += GEN.TOTAL
                END
             END
          NEXT GN

          IF PAYMENTS # 0 THEN
             BAL.AMT     = SALES + PAYMENTS
             IF SHIP.CT > 1 OR ICONV(RUNNING.TOTAL,"MR2") # BAL.AMT THEN
                OS.MSG = STR("*",10):' ORDER SUMMARY ':STR("*",10)
                OS.MSG<1,-1> = 'Total Sales for Order'"R#21":OCONV(SALES,"MR2") "R#14"
                OS.MSG<1,-1> = 'Payments to Date'"R#21":OCONV(PAYMENTS,"MR2") "R#14"
                OS.MSG<1,-1> = SPACE(23):STR('-',12)
                OS.MSG<1,-1> = 'Balance' "R#21":OCONV(BAL.AMT,"MR2") "R#14"
                OS.MSG<1,-1> = STR("*",35)
             END

             IF OS.MSG THEN
                DESC = OS.MSG
                GOSUB PRT.XDESC
             END

             IF PAID.BY THEN
                DESC = PAID.BY
                GOSUB PRT.XDESC
             END
          END

          RETURN
*-------------------------------------------------------------------------*
ADD.PAYMT: *
          PINVN    = LED(8)<1,GN> + 0
          PAY.ID   = OID:'.':PINVN"R%3"
          READ TST FROM ARFILE,PAY.ID ELSE TST = ''
          PAY.DT   = OCONV(TST<3,1>,"D2/")

          IF LED(45)<1,GN,1> THEN
             PAID.BY<1,-1> = PAY.DT:OCONV(LED(45)<1,GN,1>,"MR2") "R#12" :' Cash'
          END

          IF LED(45)<1,GN,2> THEN
             PAID.BY<1,-1> = PAY.DT:OCONV(LED(45)<1,GN,2>,"MR2") "R#12" :' Check# ':LED(46)<1,GN,2>
          END

          IF LED(45)<1,GN,3> THEN
             GET.LEDCC.VAL CREDIT.CARD.NO,3,OID,GEN
             CREDIT.CARD.MASK1 CARD.RESULT,CREDIT.CARD.NO,4
             PAID.BY<1,-1> = PAY.DT:OCONV(LED(45)<1,GN,3>,"MR2") "R#12":' Credit Card ': CARD.RESULT
          END

          IF LED(45)<1,GN,4> THEN
             PAID.BY<1,-1> = PAY.DT:OCONV(LED(45)<1,GN,4>,"MR2") "R#12":' Gift Card# ':LED(46)<1,GN,20>
          END

          RETURN
*-------------------------------------------------------------------------*
FFEED:    *
          PRINT CHAR(12):

          RETURN
*-------------------------------------------------------------------------*
FOOTER:   *

          PRINT CHAR(27):"*p2790Y":NORM
          PRINT NORM.BOLD:

          TFTR = SPACE(79)
          TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<1>)+1,LEN(FTR.MSG<1>)] = FTR.MSG<1>
          IF NO.TOLS THEN
             TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = SPACE(WIDTH.INSERT<COL.CT>)
          END ELSE
             TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = RUNNING.TOTAL FTR.FMT
          END
          PRINT TFTR

          *TFTR = DISC.MSG 'L#79'
          TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<2>)+1,LEN(FTR.MSG<2>)] = FTR.MSG<2>
          IF (CHANGE.FLAG) THEN
             PRINT
          END ELSE
             TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = (FREIGHT + HANDLING) FTR.FMT

             PRINT TFTR
          END

          IF (STATUS = 'B' OR CHANGE.FLAG) THEN
             PRINT
          END ELSE
             RUNNING.TOTAL += (FREIGHT + HANDLING)
             *TFTR = DUE.MSG "L#79"
             TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<3>)+1,LEN(FTR.MSG<3>)] = FTR.MSG<3>
             TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = TAX.AMT FTR.FMT
             PRINT TFTR
             RUNNING.TOTAL += TAX.AMT
          END

          PRINT
          TFTR = SPACE(79)
          TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<4>)+1,LEN(FTR.MSG<4>)] = FTR.MSG<4>
          IF NO.TOLS THEN
             TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = SPACE(WIDTH.INSERT<COL.CT>)
          END ELSE
             TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = RUNNING.TOTAL FTR.FMT
          END
          PRINT TFTR

          PRINT CHAR(27):"*p2840Y":NORM
          IF STATUS = 'B' THEN
             PRINT  NORM.BOLD:'This is a Quotation.':NORM
             PRINT CHAR(27):"*p2920Y"
             PRINT  ELPI:SUP.SMALL:'Price are firm for 30 days, subject to change without notice after 30 days.'
             PRINT  'Applicable taxes extra.':NORM
          END
          PRINT SLPI:
          PRINT CHAR(12):

          RETURN
*-------------------------------------------------------------------------*
DRAWSHADING: *** Draw shaded boxes to fill in headers

          PERC = 11   ;* Shade at 11%
          REST = 100  ;* Restore to 100%
          HGHT = 1    ;* All boxes are 1 char height

          FORMS.PRINT.SHADE PERC,1680, 190,2.3,HGHT,REST  ;* Inv Dt/Number
          FORMS.PRINT.SHADE PERC,2160, 340,0.7,HGHT,REST  ;* Page Number
          FORMS.PRINT.SHADE PERC,   0, 910,7.9,HGHT,REST  ;* 1st full line
          FORMS.PRINT.SHADE PERC,   0,1060,7.9,HGHT,REST  ;* 2nd full line
          FORMS.PRINT.SHADE PERC,   0,1210,7.9,HGHT,REST  ;* 3rd full line

          RETURN
*-------------------------------------------------------------------------*
SET.MACRO: *** Print macro or create if necessary

          MACRO.OK = ''

          *** Check to see if this macro is already loaded
          PTR.MACRO.ACTIVE MACRO.ID,PRT.SEQ

          *** If a sequence is returned, use to print macro immediately
          IF PRT.SEQ THEN GOTO PRT.MACRO

          *** Begin saving macro (suspend physical printing)
          PTR.MACRO.SAVE.ON MACRO.ID,MACRO.OK

          *** 'Print' the overlay - this does NOT physically print,
          *** anything between SAVE statements is only saved to macro
          DOC.FORM.CONVERT DOC.FORM.REC,DOC.FORM.SPEC
          DOC.FORM.PRINT DOC.FORM.SPEC,"1"
          GOSUB DRAWSHADING

          *** Stop saving macro (resume physical printing)
          PTR.MACRO.SAVE.OFF MACRO.ID,MACRO.OK,PRT.SEQ

PRT.MACRO: *** Print the macro with saved or newly created sequence

          IF PRT.SEQ THEN
             *** For each !, print CHAR(27) and the following characters
             CONVERT '!' TO AM IN PRT.SEQ
             ESC.CT = DCOUNT(PRT.SEQ,AM)
             FOR XX = 2 TO ESC.CT
                PRINT CHAR(27):PRT.SEQ<XX>:
             NEXT XX
             PRINT
          END

          RETURN
*-------------------------------------------------------------------------*
FINISH:   *
          IF NOT(PHANTOM.PROC) AND NOT(PRT.ON) AND NOT(JAVA.PROC$) THEN
             WINDOW.CLOSE
          END

          RETURN
*-------------------------------------------------------------------------*
!STEELI~11/13/97~23:17
!TSMITH~08/22/13~16:19
