          SUBROUTINE (OID,GEN,NUM.PGS,STATUS,PSTYLE.OVRD,PRT.ON,DRPT)
** Version# 15.0006 - 02/17/2010 - 12:36pm - JONW - UPGRADE
*** V15.0006 Change - Custom Coding CZV696 - 02/17/2010 - JONW - UPGRADE
*** V15.0005 Change - Custom Coding FORMS.MOD - 11/13/2008 - ROYO - eclipse
** Copied from UBP SOE.PRINT.BID Version# 15.0004 - 08/08/2008 - 04:03pm - CSTOLT - eclipse
*** V15.0004 Change - Custom Coding HIV121 - 08/08/2008 - CSTOLT - eclipse
*** V15.0003 Change - Custom Coding HDB282 - 10/16/2007 - HEATHERY - UPGRADE
*** V15.0002 Change - Custom Coding CRX856 - 08/16/2004 - JONW - UPGRADE
*** V15.0001 Change - Custom Coding BCL412 - 08/08/2002 - JONW - UPGRADE
*** V15.00 - 03/24/1999 - 11:17pm - NELSONC - UPGRADE

*** Subroutine - SOE.PRINT.BID
*-------------------------------------------------------------------------*
*** This subroutine prints/faxes bids/quotations.  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]
***       NUM.PGS     - Number of Pages Printed                      [Out]
***       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, CUS, CUSS, PRD, DRPT, PHANTOM.PROC, JAVA.PROC$
***         OID.LGTH$
*-------------------------------------------------------------------------*

          DIM PSTYL(10)

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

          PG.LGTH = 66

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

          MATREAD LED FROM LEDFILE,OID ELSE GOTO FINISH
*LOT
          IF LED(98)<1,GEN> THEN LOT.FLAG = YES ELSE LOT.FLAG = NO

          OE.GET.QSIGN QSIGN,OID,GEN
          BR = LED(2)<1,GEN,1>
          SHIP.BR = LED(2)<1,GEN,2>
          BT.CN = LED(1)<1,GEN>
          ST.CN = LED(5)<1,GEN>
          GET.CUS BR,BT.CN,ST.CN,QSIGN

          IF LED(8)<1,GEN>='' THEN
             LDIDS = LED(49)
             CONVERT VM TO SVM IN LDIDS
          END ELSE
             LDIDS = LED(48)<1,GEN>
          END

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

          GOSUB INIT
          GOSUB HEADER

          LDID.CT = DCOUNT(LDIDS,SVM)
          FOR LD.NO = 1 TO LDID.CT
             LDID   = LDIDS<1,1,LD.NO>
             GOSUB PRT.LINE
          NEXT LD.NO

          IF NOT(NO.TOLS) THEN
             * Check if the tax should be displayed.
             SHOW.TAX = NO
             READV SHIP.VIAS FROM CTRLFILE,'TAX.SHIP.VIAS',1 ELSE SHIP.VIAS = ''
             SHIP.VIAS = RAISE(SHIP.VIAS)
             LOCATE SHIP.VIA IN SHIP.VIAS SETTING POS THEN SHOW.TAX = YES
             IF SHOW.TAX THEN
                TAX.DESC =  '  TAX         '
                PRT.STR1 = SPACE(COL.START)
                PRT.STR2 = SPACE(COL.START-LEN(TAX.DESC)):TAX.DESC
                PRT.STR2 = PRT.STR2:TAX.AMT 'R#20'
                PRINT PRT.STR1
                PRINT PRT.STR2
             END

             SUBT.DESC = '  BID TOTAL   '
             GOSUB SUBTOTALS
             LINE.CT -= 2
          END

          RUNNING.TOTAL = COL.TOTAL<1,COL.CT>

          GOSUB FOOTER

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

          GOTO FINISH
*-------------------------------------------------------------------------*
INIT:     *
          SSPC       = 9
          PAGE       = 0
          IN.FOOTER  = NO
          PRINT.PICK = NO
          CASH.SALE  = NO
          DOC.ID     = '** Quotation **'
          ORD.ID     = OID
          DOC.TYPE   = 'B'
          SUBT.SW    = NO
          SHOW.TAX   = NO

          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

          SOE.CREDIT.CHECK ST.CN,,COD,PRT.MSG,NO.SHIP,,,OID,GEN

          CUS.PSTYLE = CUSS(42)

    * Force last column to be Net for Cash Sales and Invoices
          BEGIN CASE
          CASE PSTYLE.OVRD#''
             STYLE.ID = PSTYLE.OVRD
          CASE LED(77)<1,GEN> # CUS.PSTYLE
             STYLE.ID = LED(77)<1,GEN>
          CASE OTHERWISE
             STYLE.ID = 'BID'
          END CASE

          GOSUB GET.PSTYLE

          COLUMN.HEADING = '    Qty  Description'

          CONVERT ' ' TO '-' IN COLUMN.HEADING

    * 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

          NO.TOLS  = (COL.BASIS<1,COL.CT>=2 AND NOT(COL.EXTDS<1,COL.CT>))
          NET.TOLS = (COL.BASIS<1,COL.CT>=1 OR COL.BASIS<1,COL.CT>=2)

          GOSUB GET.TOTALS

          ITEM.TAG.INFO  = '' ;* Item tag info
          OE.ITEM.TAG.READ OID,,,,ITEM.TAG.INFO

          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)
          COL.CT    = DCOUNT(COL.BASIS,VM)
          COL.TOTAL = ''
          SUB.TOTAL = ''

          RETURN
*-------------------------------------------------------------------------*
HEADER:   *
          PAGE = PAGE + 1
          LINE.CT = PG.LGTH
          CUS.PO = LED(65)<1,GEN>

          IF LED(69)<1,GEN,1> THEN
             FRGT.ALLWD = 'YES'
          END ELSE
             FRGT.ALLWD = 'NO'
          END

          READV BR.EN FROM TERRFILE,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> = TRIM(CUS.BR<3>):', ':CUS.BR<4>:' ':CUS.BR<5>
          BR.ADDR<-1> = 'Phone # : ':CUS.BR<17,1>

          PRINT SPACE(40-INT(LEN(DOC.ID)/2)):DOC.ID

          PRINT

          PRINT SPACE(30):BR.ADDR<1>'L#35':SPACE(4):'Page #: ':PAGE"R#3"
          PRINT SPACE(30):BR.ADDR<2>'L#35'
          PRINT SPACE(30):BR.ADDR<3>'L#35'
          PRINT SPACE(30):BR.ADDR<4>'L#35'
          PRINT SPACE(30):BR.ADDR<5>'L#40'
          PRINT 'Bid #: ':ORD.ID'L#20'

          IF COD THEN
             PRINT SPACE(40):'** C.O.D. ** C.O.D. ** C.O.D. **'
          END ELSE
             PRINT
          END

          PRINT

          WRITER   = LED(73)<1,GEN>
          SALESMAN = LED(72)<1,GEN>
          SHIP.VIA = LED(70)<1,GEN>
          ORD.DATE = LED(4)<1,GEN>
          SHP.DATE = LED(9)<1,GEN>
          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=''
*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):' ':CUS(5)

     * Header Bill To / Ship To
          PRINT SPACE(14):'Bid To:':SPACE(32):'Ship To:'

          FOR B = 1 TO 4
             PRINT BILL.ADDR<B>"L#35":SPACE(5):SHIP.ADDR<B>"L#35"
          NEXT B

          PRINT 'Phone # : ':PHONE.NO'L#30':
          PRINT 'JOB: ':CUS.PO'L#35'

          PRINT

     * Header additional data Line #1
          PRINT 'Bid-Date---Expr-Date':
          PRINT '--Writer--Terms-------------------Ship Via--------Frght Allw'

          PRINT OCONV(SHP.DATE,'D2/')      "L#10":' ':
          PRINT OCONV(EXP.DATE,'D2/')      "L#10":' ':
          PRINT WRITER                     "L#7":' ':
          PRINT TERMS.DESC                 "L#23":' ':
          PRINT SHIP.VIA                   "L#15":' ':
          PRINT FRGT.ALLWD                 "R#5"

          PRINT STR('-',80)

          PRINT

     * Column Headings
          PRINT COLUMN.HEADING

          LINE.CT -= 21

     * Shipping Instructions
          SHP.INST = LED(74)<1,GEN>
          IF SHP.INST#'' AND PAGE=1 THEN
             GOSUB SUBT.ONE
             PRINT SPACE(SSPC):'********* Shipping Instructions **********'
             CT = DCOUNT(SHP.INST,SVM)
             FOR JJ=1 TO CT
                GOSUB SUBT.ONE
                PRINT SPACE(SSPC):'* ':SHP.INST<1,1,JJ>"L#38":' *'
             NEXT JJ
             GOSUB SUBT.ONE
             PRINT SPACE(SSPC):STR('*',42)
          END

          BO.HEADING = NO

          RETURN
*-------------------------------------------------------------------------*
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)
             IF COL.EXTDS<1,COL> THEN
                PRT.STR1 = PRT.STR1:STR('-',LGTH)

                * Check if the tax should be displayed.
                IF SHOW.TAX THEN
                   SUB.TOL = SUB.TOTAL<1,COL> + TAX.AMT
                   COL.TOL = COL.TOTAL<1,COL> + TAX.AMT
                END ELSE
                   SUB.TOL = SUB.TOTAL<1,COL>
                   COL.TOL = COL.TOTAL<1,COL>
                END
                IF SUBT.SW THEN
                   PRT.STR2 = PRT.STR2:SUB.TOL COL.FRMTS<1,COL>
                END ELSE
                   PRT.STR2 = PRT.STR2:COL.TOL COL.FRMTS<1,COL>
                END
             END ELSE
                PRT.STR1 = PRT.STR1:SPACE(LGTH)
                PRT.STR2 = PRT.STR2:SPACE(LGTH)
             END
          NEXT COL

          PRINT PRT.STR1
          PRINT PRT.STR2

          RETURN
*-------------------------------------------------------------------------*
GET.TOTALS: *
          SOE.CALC.CASH OID,GEN,AMT.DUE,AMT.PAID,CASH.DISC
          OE.ORDER.TOTAL OID,GEN,QSIGN,,,FREIGHT,HANDLING,TAX.AMT
          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: *
          TOTAL.COMMENT = ''
          IF TAX.AMT THEN
*            TOTAL.COMMENT = 'Sales tax'
             TOTAL.AMT     = TAX.AMT
*            GOSUB PRINT.TOTAL
             RUNNING.TOTAL += TOTAL.AMT
          END

          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

 *        TOTAL.COMMENT = 'Bid Amount'
          TOTAL.AMT     = RUNNING.TOTAL
 *        GOSUB PRINT.TOTAL

          PRINT.AMT.DUE = NO
          CASH.DISC2    = CASH.DISC

          IF CASH.DISC AND NET.TOLS AND RUNNING.TOTAL+CASH.DISC=0 THEN
 *           TOTAL.COMMENT = 'Less cash disc'
             TOTAL.AMT     = CASH.DISC
 *           CASH.DISC     = 0
 *           GOSUB PRINT.TOTAL
             RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
             PRINT.AMT.DUE = YES
          END

          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 - Payment # ':PAY.ID"L#12"
                   END ELSE
                      TOTAL.COMMENT = 'Prior Deposit on ':OCONV(PAY.DT,'D2/')"L#8" :' - Payment # ':PAY.ID"L#12"
                   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: *
          GOSUB SUBT.ONE
          PRT.STR = SPACE(TOTAL.SPACES-LEN(TOTAL.COMMENT)-13)
          PRT.STR = PRT.STR:TOTAL.COMMENT:''"L#13"
          PRT.STR = PRT.STR:TOTAL.AMT TOTAL.FRMT
          PRINT PRT.STR

          RETURN
*-------------------------------------------------------------------------*
PRINT.TOTAL.LINE: *
          GOSUB SUBT.ONE
          LGTH = FIELD(TOTAL.FRMT,"#",2)
          PRT.STR = SPACE(TOTAL.SPACES):STR('-',LGTH)
          PRINT PRT.STR

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

          BEGIN CASE
          CASE NUM(PN)
             QS = (SUM(LD(5)<1,GEN>) + SUM(LD(6)<1,GEN>)) * QSIGN
             IF QS#0 THEN GOSUB PRT.PN
          CASE PN='C'
             OE.DESC.GET DESC,ALT.DESC,"SOE Printing"
             GOSUB PRT.XDESC
          CASE PN='S' AND COL.BASIS<1,COL.CT>=19
             COL.EXTDS<1,COL.CT> = 1
             SUBT.SW=YES
             GOSUB PRT.SUBT
             SUBT.SW=NO
             SUB.TOTAL=''
             COL.EXTDS<1,COL.CT> = 0
          CASE PN='S'
             SUBT.SW=YES
             GOSUB PRT.SUBT
             SUBT.SW=NO
             SUB.TOTAL=''
          END CASE

          RETURN
*-------------------------------------------------------------------------*
PRT.PN:   *
          GET.ALL.PRD BR,PN,QSIGN,GROUP
          DFLT.PER.GET OID[1,1],PER,UM

          SHP.TYP.LOCS = LD(7)<1,GEN>
          LOC.CT  = DCOUNT(SHP.TYP.LOCS,SVM)

          IF PRD(3) = 9 THEN LOT.FLAG = YES ELSE LOT.FLAG = NO

          *** 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
             QS = (LD(5)<1,GEN,LOC> + LD(6)<1,GEN,LOC>) * QSIGN
             IF QS=0 THEN GOTO NO.PTR

             OE.DESC.GET DESC,ALT.DESC,"SOE Printing"

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

             IF NOT(LED(8)<1,GEN>) THEN
                QOPEN = 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)
                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)
             TYPE    = FIELD(SHP.TYP.LOC,'~',1)
             IF LOCA = 'WHSE' THEN PRINT.PICK = YES

             IF TYPE = 'T' THEN
                TAG = FIELD(SHP.TYP.LOC,'^',2)
                TAG = FIELD(TAG,'.',1)
                DESC<1,-1> = '<<** ':QS:' Tagged to ':TAG[1,OID.LGTH$]:' **>>'
             END

             BEGIN CASE
             CASE QS<0 AND TYPE='F';  LOCA = '**DEF '
             CASE QS>0 AND TYPE='D';  LOCA = '**DIR '
             CASE QS<0;               LOCA = '**RTN '
             CASE OTHERWISE;          LOCA = LOCA"L#3"
             END CASE

             IF PER THEN QOPEN = QOPEN/PER
             IF LOC > 1 THEN QOPEN = '"'

             PRT.STR = QOPEN               "R#7":'  '
             PRT.STR = PRT.STR:DESC<1,1>   "L#35"

             IF ITEM.TAG.INFO THEN
                * Let user know how many labels go with this line
                OE.ITEM.TAG.GET.FORM.CMT OID,GEN,LDID,LBL.DATA
                LBL.CT = DCOUNT(LBL.DATA,AM)
                FOR LBL.NO = 2 TO LBL.CT
                   DESC<1,-1> = LBL.DATA<LBL.NO>
                NEXT LBL.NO
             END

             GOSUB SUBT.ONE
   *LOT
             IF LOT.FLAG THEN
                PRT.STR             := OCONV(LD(67)<1,1>,'MR9') "R3#12"
                PRT.STR             := OCONV(LD(67)<1,1>,'MR9') "R2#11"
                COL.TOTAL<1,COL.CT> += OCONV(LD(67)<1,1>,'MR9')
             END ELSE
                OE.GET.PSTYLE OID,GEN,COL.START,COL.FRMTS,COL.BASIS,COL.EXTDS,COL.CT,QS,PRT.STR,COL.TOTAL,SUB.TOTAL
             END

             PRINT PRT.STR
             DESC = DELETE(DESC,1,1)
             GOSUB PRT.XDESC

NO.PTR:   NEXT LOC
*LOT
          IF LOT.FLAG THEN
             GOSUB LOT.SUB
          END

          RETURN
*-------------------------------------------------------------------------*
PRT.XDESC: *
          DESC.CT = DCOUNT(DESC,VM)
          FOR DLN = 1 TO DESC.CT
             GOSUB SUBT.ONE
             PRINT SPACE(SSPC):DESC<1,DLN>"L#35"
          NEXT DLN

          RETURN
*-------------------------------------------------------------------------*
PRT.SUBT: *
          OE.DESC.GET DESC,ALT.DESC,"SOE Printing"
          SUBT.DESC = DESC<1,1>
          LINE.CT -= 2
          GOSUB SUBTOTALS
          DESC = DELETE(DESC,1,1)
          GOSUB PRT.XDESC

          RETURN
*-------------------------------------------------------------------------*
SUBT.ONE: *
          IF LINE.CT<14 THEN
             PRINT
             PRINT SPACE(50):'*** Continued on Next Page ***'
             LINE.CT -= 2
             GOSUB FFEED
             GOSUB HEADER
          END

          LINE.CT -= 1

          RETURN
*-------------------------------------------------------------------------*
FOOTER:   *
          IN.FOOTER = YES
          IF NOT(NO.TOLS) THEN GOSUB PRINT.TOTALS

          GOSUB FFEED

          RETURN
*-------------------------------------------------------------------------*
FFEED:    *
          LN.CT = LINE.CT - 15

          FOR Z = 1 TO LN.CT
             PRINT
             LINE.CT -= 1
          NEXT Z

          IF REPRINT THEN
             PRINT SPACE(35):'.. Reprint .. Reprint .. Reprint .. Reprint ..'
          END ELSE
             PRINT
          END

          LINE.CT -= 1
          LN.CT = LINE.CT - 10

          FOR X = 1 TO LN.CT
             PRINT
             LINE.CT -= 1
          NEXT X

          PRINT SPACE(9):'Quoted in accordance with our interpretation of specifications.'
          PRINT SPACE(9):'This material offered subject to approval of Architect and Engineers.'

          PRINT CHAR(12):

          LINE.CT = 0

          RETURN
*-------------------------------------------------------------------------*
LOT.SUB:  *LOT
          PARTS.CT = DCOUNT(LD(59),VM)

          ORD.STAT1 = LED(6)<1,GEN,1>
          IF ORD.STAT1 # "D" THEN
             TOTAL.PARTS.SHP = 0
             FOR CT = 1 TO PARTS.CT
                TOTAL.PARTS.SHP += LD(61)<1,CT,GEN>
             NEXT CT
          END ELSE
             TOTAL.PARTS.SHP = 1
          END

          IF TOTAL.PARTS.SHP = 0 THEN
             GOSUB SUBT.ONE
             PRINT
             PRT.STR = SPACE(SSPC):"This specific Lot Shipment has no"
             GOSUB SUBT.ONE
             PRINT PRT.STR
             PRT.STR = SPACE(SSPC):"related material detail defined."
             GOSUB SUBT.ONE
             PRINT PRT.STR
             RETURN
          END

          IF PARTS.CT THEN
             GOSUB SUBT.ONE
             PRINT
             PRT.STR = SPACE(SSPC):"This Lot Consists of the following:"
             GOSUB SUBT.ONE
             PRINT PRT.STR
             PRT.STR = SPACE(SSPC):"Ord Qty  Description"
             GOSUB SUBT.ONE
             PRINT PRT.STR
             PRT.STR = SPACE(SSPC):"------- ---------------------------"
             GOSUB SUBT.ONE
             PRINT PRT.STR
          END

          FOR CT = 1 TO PARTS.CT
             PARTS.NUM = LD(59)<1,CT>
             PARTS.ORD = LD(60)<1,CT>
             PARTS.SHP = LD(61)<1,CT,GEN>
             PARTS.CST = OCONV(LD(63)<1,CT>,'MR3')
             PARTS.EXT = PARTS.CST * PARTS.ORD

             IF PARTS.NUM[1,1] = "/" THEN
                PN = PARTS.NUM[2,LEN(PARTS.NUM)-1]
                MATREAD PRD FROM PRDFILE,PN ELSE RETURN
                DESC = PRD(1)
                FOLD.STRING DESC,27,NEWSTRING,VCT
                DESC = NEWSTRING
             END ELSE
                PARTS.NUM = RAISE(PARTS.NUM)
                FOLD.STRING PARTS.NUM,27,NEWSTRING,VCT
                DESC = NEWSTRING
             END

             PRT.STR  = SPACE(SSPC)
             PRT.STR := PARTS.ORD "R#7 "
             PRT.STR := DESC<1,1> "L#27"

             GOSUB SUBT.ONE
             PRINT PRT.STR
             DESC     = DELETE(DESC,1,1)
             SAV.SSPC = SSPC
             SSPC    += 8
             OE.CUS.PN.CMT.GET LED(1)<1,GEN>,LED(5)<1,GEN>,CUSS(66),PARTS.NUM,CMT
             IF CMT<1> THEN DESC<1,-1> = 'Your PN: ':CMT<1> "L#15"
             GOSUB PRT.XDESC
             SSPC = SAV.SSPC
          NEXT CT

          PRINT

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

          RETURN
*-------------------------------------------------------------------------*
!JONW~02/17/10~12:36
