          SUBROUTINE (OID,INIT.GEN,DOC.TYPE,PSTYLE.OVRD,DRPT,PRT.ON,MNFST.PRT)
** Version# 90.001[4] - 05/13/2014 - 03:52pm - TSMITH - eclipse
*** V90.001 Change - Custom Coding . - 05/13/2014 - TSMITH - eclipse
*** V90.0009 Change - Custom Coding . - 02/18/2014 - TSMITH - eclipse
*** V90.0008 Change - Custom Coding . - 10/29/2013 - TSMITH - eclipse
*** V90.0007 Change - Custom Coding CYS288 - 01/16/2009 - AMYC - UPGRADE
*** V90.0006 Change - Custom Coding AVK986 - 04/03/2006 - GARYD - eclipse
*** V90.0005 Change - Custom Coding DKF876 - 06/13/2005 - BARSPA - eclipse
** Copied from CBP POE.PRINT.ORDER Version# 90.0004 - 04/27/2005 - 01:31pm - BARSPA - eclipse
*** V90.0004 Change - Custom Coding HEK618 - 04/27/2005 - BARSPA - eclipse
*** V90.0003 Change - Add FULL Ver 96 - 03/30/2005 - BARSPA - eclipse
*** V90.0002 Change - Custom Coding DJO541 - 02/26/2005 - HAZELTON - eclipse
*** V90.0001 Change - Add FULL Ver 8 - 02/26/2005 - ELIZR - eclipse

*** Subroutine - POE.PRINT.ORDER
*-------------------------------------------------------------------------*
*** Prints Purchase Orders.
*** If it is printing a receiving ticket, the defaults for the particular
*** branch are gotten from the CTRBFILE under PO.RECVR.DFLTS.
*-------------------------------------------------------------------------*
*** OID         - Order ID                                            [IN]
*** INIT.GEN    - Order generation                                    [IN]
*** DOC.TYPE    - Determines which form will print                    (IN)
*** PSTYLE.OVRD - Print style override                                (IN)
*** DRPT        - Report Defaults                                     [IN]
*** PRT.ON      - Printer on flag                                     (IN)
*-------------------------------------------------------------------------*
*** COMMON VARIABLES: DRPT, LD, LED, CUS, JAVA.PROC$
*-------------------------------------------------------------------------*

*-------------------------------------------------------------------------*
 GEN = INIT.GEN
          PSTYLE.ID = ''
          IF USE.ECLIPSE.FORMS$ THEN
             PSTYLE.ID = ""
          END ELSE
             IF PSTYLE.ID='' THEN PSTYLE.ID = PSTYLE.OVRD
          END




          STATUS = LED(6)<1,GEN,1>
          BR       = LED(2)<1,GEN,1>
          SHIP.BR  = LED(2)<1,GEN,2>
          IF BR = '6' OR SHIP.BR = '6' THEN
          POE.PRINT.NUCLEAR OID,GEN,STATUS,PSTYLE.ID,DRPT,PRT.ON
          RETURN
          END

          STATUS = LED(6)<1,GEN,1>
          BR       = LED(2)<1,GEN,1>
          SHIP.BR  = LED(2)<1,GEN,2>

*-------------------------------------------------------------------------*
          GEN = INIT.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

          MATREAD LED FROM LEDFILE,OID ELSE GOTO FINISH
          ORD.STAT = LED(6)<1,GEN,1>

          ** CODE CHANGE FOR DKJ405 BEGIN
          **OE.GET.QSIGN QSIGN,OID
          OE.GET.QSIGN QSIGN,OID,GEN
          ** CODE CHANGE FOR DKJ405 END

          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>
          DRP.PT.BR = LED(119)<1,GEN>
          IF DRP.PT.BR = '' THEN DRP.PT.BR = SHIP.BR
          GET.CUS BR,BT.CN,ST.CN,QSIGN
          GOSUB INIT

          * Check to see if it's a Receiving Register, if so, check the
          * control record for current ship branch to see if a Receiving
          * Register should print off a PO Receiver.
          CONTROL.CHK = 'PRINT.PO.RECVR~':LED(2)<1,GEN,2>
          IF ORD.STAT = 'R' AND ORDER.TOTAL > 0 THEN
             READV NADA FROM CTRBFILE,CONTROL.CHK,0 THEN
                *** Check to see if there are printing defaults defined
                *** for this branch in the CONTROL.BR file. These are set
                *** via the P/O receiver F6-R-V.
                DFLTS.ID = 'PO.RECVR.DFLTS~':LED(2)<1,GEN,2>
                READ DFLTS FROM CTRBFILE,DFLTS.ID THEN
                   SHP.STATS = DFLTS<1>
                   PRT.OPTS  = DFLTS<2>
                   CMTD      = DFLTS<3>
                   TAGS      = DFLTS<4>
                   LTYPES    = DFLTS<5>
                END ELSE
                   SHP.STATS = ''
                   PRT.OPTS  = 'ALL'
                   CMTD      = 'ALL'
                   TAGS      = 'ALL'
                   LTYPES    = ''
                END

                POE.PRINT.RECVR OID,INIT.GEN,PRT.ON,SHP.STATS,PRT.OPTS,TAGS,CMTD,LTYPES
                RETURN
             END
          END

          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    = ''
*         END
          IF NOT(PHANTOM.PROC) AND NOT(PRT.ON) AND NOT(JAVA.PROC$) THEN
            WINDOW 15,8,50,5
            IF NOT(FAX.FLAG) THEN
               PRINT @(0,1):'Printing .... ':OID
            END ELSE
               PRINT @(0,1):'Faxing .... ':OID
            END
          END

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

          OE.LOG.PRINT OID,INIT.GEN,DOC.TYPE,DOC.ID,REPRINT
          IF REPRINT THEN
             REPRINT.MSG = '** Reprint ** Reprint ** Reprint **'
          END ELSE
             REPRINT.MSG = ''
          END

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

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

          RUNNING.TOTAL = COL.TOTAL<1,COL.CT,1>
          PGS = INT((BLINE + BOD.LINES-1)/BOD.LINES)

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

          IF PRINT.HAZ THEN
             SOE.PRINT.HAZMAT OID,GEN,DRPT
          END

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

          GOTO FINISH
*-------------------------------------------------------------------------*
INIT:     *
          PAGE       = 0
          SSPC       = 21
          SUBT.SW    = NO
          PRINT.HAZ  = NO
          HAZMAT.INFO = ''
          * Get price branch specific nonstock comment
          READV NCMT FROM CTRBFILE,"NONSTOCK.COMMENT~":BR,1 ELSE NCMT=""

          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'

          SLPI       = CHAR(27):"&l6D"
          ELPI       = CHAR(27):"&l8D"
          ST.NO      = LED(5)<1,GEN>
          CUS.PO     = ''
          ORD.WITH   = LED(68)<1,GEN>
          FRT.FLAG   = LED(69)<1,INIT.GEN,1>
          READ CTRL.DATA FROM CTRLFILE,'VENDOR.FREIGHT.TERMS' ELSE CTRL.DATA = ""
          IF CTRL.DATA = '' THEN
             FRT.MSG = "Allowed"
          END ELSE
             FRT.MSG = FRT.FLAG
          END
          ***IF FRT.FLAG THEN FRT.MSG = "Allowed" ELSE FRT.MSG = "Prepay&Chrg"
          WRITER     = LED(73)<1,GEN>
          READV WRITER FROM INIFILE,WRITER,3 ELSE NULL
          SHIP.VIA   = LED(70)<1,GEN>
          ORD.DATE   = LED(4)<1,GEN>
          SHP.INST   = LED(74)<1,GEN>
          SHP.DATE   = LED(9)<1,GEN>
          REQD.DATE  = LED(10)<1,GEN>
          PHONE.NO   = CUSS(17)<1,1>
          CONFIRM.PO = LED(67)<1,GEN>
          IF CONFIRM.PO THEN
             CONFIRM.MSG = '*** CONFIRMING P/O *** DO NOT DUPLICATE ***'
          END ELSE
             CONFIRM.MSG = ''
          END

          TERMS.ID = LED(29)<1,GEN>
          READV TERMS.DESC FROM TERMSFILE,TERMS.ID,1 ELSE TERMS.DESC=TERMS.ID
          CASH.SALE = (TERMS.ID[1,1] = 'C')
          BOD       = ''
          BLINE     = 0
          * Get Print style
          BEGIN CASE
          CASE PSTYLE.OVRD#''
             STYLE.ID = PSTYLE.OVRD
          CASE ORD.STAT='B' OR (ORD.STAT='Y' AND DOC.TYPE='B')
             STYLE.ID = 'BLIND'
          CASE ORD.STAT = 'Y'
             STYLE.ID = 'DIRECT'
          CASE OTHERWISE
             STYLE.ID = 'INV'
          END CASE
          IF STYLE.ID = '' THEN STYLE.ID = 'INV'
          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 = ''

          DOC.FORM.SPEC = ''

          *** For Johnstone Sites we will be displaying the store number
          *** along with the PO Number, and if there is a PSO number
          *** set in the Internal PO Notes, we will display that as well.
          *** We'll therefore need a bigger box for the PO Number, so
          *** use the PO Form Control Record specific to Johnstone...
          IF JOHNSTONE.SITE$ THEN
             PO.FORM = 'JOHNSTONE.PO.FORM'
          END ELSE
             PO.FORM = 'PO.FORM'
          END

          READ DOC.FORM.REC FROM CTRLFILE,PO.FORM THEN
             GOSUB CNVRT.FORM
          END ELSE
             DOC.FORM.REC = ''
          END

          PRINT.PICK = NO
          DIR.SHIP   = NO

          GOSUB GET.TOTALS

          BEGIN CASE
          CASE ORD.STAT = 'B' OR (ORD.STAT = 'Y' AND DOC.TYPE = 'B')
             *** Normal Bid or Bid for Direct Shipment...
             DOC.ID   = 'Request for Quotation'
             DOC.TYPE = 'B'
             ORD.ID   = ''
          CASE ORD.STAT = 'Y'
             *** Direct Shipment...
             INVN = LED(8)<1,GEN>
             IF INVN THEN
                ORD.ID = OID:'.':INVN"R%3"
             END ELSE
                ORD.ID = OID
                END
             DOC.ID   = 'Direct Shipment P/O'
             DOC.TYPE = 'D'
             DIR.SHIP = YES
          CASE ORD.STAT = 'R' AND ORDER.TOTAL > 0
             *** Normal Received PO...
*            FT.LGTH += 4
             INVN   = LED(8)<1,GEN>
             ORD.ID = OID:'.':INVN"R%3"
             DOC.ID   = 'Receiving Register'
             DOC.TYPE = 'R'
          CASE ORDER.TOTAL < 0 AND ORD.STAT = 'O'
             *** Open PO to be returned
             DOC.ID   = 'Return Goods Authorization'
             DOC.TYPE = 'O'
             ORD.ID = OID
          CASE ORDER.TOTAL < 0 AND ORD.STAT = 'R'
             *** Received PO to be returned
             DOC.ID = 'Purchase Order Return'
             DOC.TYPE = 'R'
             INVN   = LED(8)<1,GEN>
             ORD.ID = OID:'.':INVN"R%3"
          CASE OTHERWISE
             *** Regular open PO...
             DOC.ID   = 'Purchase Order'
             DOC.TYPE = 'O'
             INVN   = LED(8)<1,GEN>
             ORD.ID   = OID
          END CASE

    * Compile column heading line from print style record
          TOTAL.SPACES = COL.START
          COLUMN.HEADING = 'Product Description' "L#35"
          IF DOC.TYPE = 'R' THEN
             COLUMN.HEADING := 'Open Qty' "R#12"
          END ELSE
             COLUMN.HEADING := 'Order Qty' "R#12"
          END
          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  = NOT(COL.EXTDS<1,COL.CT>)

          TOTAL.FMT = 'L#':TOTAL.SPACES
          BLIND = (COL.BASIS<1,COL.CT>=2)

          *** Check to see if an alternate 'Remit To' entity has been
          *** assigned. If so use it...
          READV REMIT.EN FROM TERRFILE,BR,38 ELSE REMIT.EN = ""
          IF REMIT.EN = "" THEN
             READV REMIT.EN FROM TERRFILE,BR,5 ELSE REMIT.EN = ""
          END
          IF REMIT.EN = "" THEN
             READV REMIT.EN FROM TERRFILE,BR,4 ELSE REMIT.EN = ""
          END

          READ REMIT.ADD FROM CUSFILE,REMIT.EN ELSE REMIT.ADD = ''


           *** Code to print "Greensboro Plumbing Supply".
           SHP.DATE = LED(9)<1,GEN>
          IF SHP.DATE < 16938 THEN
          REMIT = 'GREENSBORO PLUMBING SUPPLY'
          END ELSE
          REMIT = REMIT.ADD<1>
          END


          REMIT<-1> = REMIT.ADD<2,1>
          REMIT<-1> = REMIT.ADD<2,2>
          REMIT<-1> = REMIT.ADD<3>:' ':REMIT.ADD<4>:' ':REMIT.ADD<5>

          READV BR.EN FROM TERRFILE,DRP.PT.BR,4 ELSE BR.EN = ''
          READ CUS.BR FROM CUSFILE,BR.EN ELSE CUS.BR = ''
          *** Code to print "Greensboro Plumbing Supply".
           SHP.DATE = LED(9)<1,GEN>
          IF SHP.DATE < 16938 THEN
          BR.ADDR = 'GREENSBORO PLUMBING SUPPLY'
          END ELSE
          BR.ADDR =  CUS.BR<1>
          END

          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
          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
          READV BR.CN FROM TERRFILE,BR,4 ELSE BR.CN = ''


          IF LED(33)<1,GEN> THEN
             LOCATE LED(33)<1,GEN> IN LED(12)<1> SETTING GEN THEN NULL
             CUS.PO   = LED(13)<1,GEN>
          END

*LOT
          IF LED(98)<1,GEN> THEN LOT.FLAG = YES ELSE LOT.FLAG = NO

          * Both GENs must be passed to OE.GET.PSTYLE for Direct POs
          GNS = GEN
          IF INIT.GEN # GEN THEN GNS<1,2> = INIT.GEN

          READV BR.PHONE FROM CUSFILE,"1",17 ELSE BR.PHONE=''
          READV SHP.TO FROM CUSFILE,LED(5)<1,GEN>,1  ELSE SHP.TO = ''
          READV SHP.PHN FROM CUSFILE,LED(5)<1,GEN>,17 ELSE SHP.PHN = ''
          READV CONTACTS FROM CUSFILE,LED(5)<1,GEN>,16 ELSE CONTACTS = ''

          IF LED(78)<1,GEN,1> THEN SHP.TO<-1> = LED(78)<1,GEN,1>
          IF LED(78)<1,GEN,2> THEN SHP.TO<-1> = LED(78)<1,GEN,2>
          SHP.TO<-1> = TRIM(LED(78)<1,GEN,3>):" ":LED(75)<1,GEN>"L#10"

          CONTACTS = RAISE(OCONV(CONTACTS,"MCU"))
          FINDSTR "FAX" IN CONTACTS SETTING PPOS ELSE PPOS = 0
          IF PPOS THEN
             IF SHP.PHN<1,PPOS> # '' THEN
                FAX.PHONE = '  Fax ':SHP.PHN<1,PPOS>
             END ELSE
                FAX.PHONE = ''
             END
          END ELSE
             FAX.PHONE = ''
          END
          IF DOC.TYPE # 'D' THEN
          SHP.TO<-1> = SHP.PHN<1,1>:FAX.PHONE
          END
**        SHP.TO<-1> = SHP.PHN<1,1>:"  Fax ":FAX.PHONE
*B2B
          VADDR = LED(78)<1,INIT.GEN,6>
          IF NOT(VADDR) THEN VADDR = CUSS(1)
          IF LED(78)<1,INIT.GEN,1> THEN VADDR<-1> = LED(78)<1,INIT.GEN,1>
          IF LED(78)<1,INIT.GEN,2> THEN VADDR<-1> = LED(78)<1,INIT.GEN,2>
          VADDR<-1> = TRIM(LED(78)<1,INIT.GEN,3>):" ":LED(75)<1,INIT.GEN>"L#10"

          IF NOT(DIR.SHIP) THEN
             VADDR = SHP.TO
             SHP.TO = BR.ADDR
          END

          IF LED(109)<1,INIT.GEN,1> # '' THEN
             SHP.TO     = LED(109)<1,INIT.GEN,1>
             SHP.TO<-1> = LED(109)<1,INIT.GEN,2>
             SHP.TO<-1> = LED(109)<1,INIT.GEN,3>
             SHP.TO<-1> = TRIM(LED(109)<1,INIT.GEN,4>):', ':LED(109)<1,INIT.GEN,5>:' ':LED(109)<1,INIT.GEN,6>
             SHP.TO<-1> = LED(109)<1,INIT.GEN,7>
          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#35"
             NEXT JJ
             BLINE += 1
             BOD<BLINE> = SPACE(SSPC):STR('*',34)
          END

          *** For Johnstone sites, we need to display the Store Number
          *** along with the PO Number, minus the 'P' in the PO Number...
          IF JOHNSTONE.SITE$ THEN
             *** Read in the Johnstone Store Numbers from the Control File
             READV STNO FROM CTRBFILE,'JOHNSTONE.STORE.NOS~':SHIP.BR,1 ELSE
                STNO = ''
             END
             *** We'll trim off any spaces we get when there's only a
             *** 2-digit store number...
             ORD.ID = TRIM(STNO"R#3":'-':ORD.ID[2,7])

             *** If there is a PSO number in the Internal PO Notes, we'll
             *** display that as well...
             IF LED(80)<1,GEN,1>[1,3] = 'PSO' THEN
                ORD.ID = FIELD(ORD.ID,'-',1):FIELD(LED(80)<1,GEN,1>,'-',2):FIELD(ORD.ID,'-',2)
             END
          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 = 'PO~':STYLE.ID
          GOSUB SET.MACRO

          PRINT CHAR(27):"*p0Y":
          PRINT NORM:SLPI:
          PRINT
          PRINT

          PRINT SPACE(70-LEN(DOC.ID)):XLARGE:DOC.ID:NORM

          KIV.ADDR = "GREENSBORO PLUMBING SUPPLY CO."
          KIV.ADDR<-1> = "501 East Washington Street"
          KIV.ADDR<-1> = "Greensboro, NC 27401"
          KIV.ADDR<-1> = "336-274-7615  Fax 336-370-4715"


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

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

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

          *** For Johnstone Sites we will be displaying the store number
          *** along with the PO Number, and if there is a PSO number
          *** set in the Internal PO Notes, we will display that as well.
          *** We'll therefore be printing the P/O Date, P/O NUmber, BillTo
          *** and Page No. in a different position on the form to
          *** accomodate the additional characters we'll have for the P/O
          *** Number...
          IF JOHNSTONE.SITE$ THEN
             PRINT '' "L#54" :OCONV(ORD.DATE,'D2/')   "L#10":
             PRINT ORD.ID                             "L#15"
             PRINT CHAR(27):"*p315Y"
             PRINT '' "L#54":SMALL:"BILL TO:":NORM:ELPI

             PRINT '' "L#54":SUP.SMALL:REMIT<1> "L#37":NORM
             PRINT '' "L#54":SUP.SMALL:REMIT<2> "L#37":NORM
             PRINT '' "L#54":SUP.SMALL:REMIT<3> "L#37":NORM:PAGE  "R#5"
             PRINT '' "L#54":SUP.SMALL:REMIT<4> "L#37":NORM
          END ELSE
             PRINT '' "L#55" :OCONV(ORD.DATE,'D2/')   "L#10":
             PRINT ORD.ID                             "L#14"
             PRINT CHAR(27):"*p315Y"
             PRINT '' "L#55":SMALL:"BILL TO:":NORM:ELPI

             PRINT '' "L#55":SUP.SMALL:REMIT<1> "L#30":NORM
             PRINT '' "L#55":SUP.SMALL:REMIT<2> "L#30":NORM
             PRINT '' "L#55":SUP.SMALL:REMIT<3> "L#30":NORM:PAGE  "R#5"
             PRINT '' "L#55":SUP.SMALL:REMIT<4> "L#30":NORM
          END

          PRINT CHAR(27):"*p490Y":SLPI
          PRINT CONFIRM.MSG

          PRINT CHAR(27):"*p565Y":SLPI
          PRINT SPACE(7):SMALL:"VENDOR:":NORM:
          PRINT CHAR(27):"*p565Y":SLPI
          PRINT SPACE(45):SMALL:"SHIP TO:":NORM

          FOR KK=1 TO 5
          PRINT SPACE(7):VADDR<KK>'L#38': SHP.TO<KK>
          NEXT KK

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

*         PRINT BR                     'R#2':'   ':

          PRINT WRITER                 'L#20'
          PRINT
          PRINT
          PRINT ' ':FRT.MSG            'L#12 ':
          PRINT SHIP.VIA               'L#22 ':
          PRINT TERMS.DESC             'L#21 ':
          IF HOLD.FOR.VENDOR THEN
             PRINT "**HOLD**  " 'L#10 ':
          END ELSE
             PRINT OCONV(REQD.DATE,'D2/') 'L#10 ':
          END
          PRINT SHIP.BR "R#5"
          PRINT

          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

          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)
          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>,'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>,'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: *
          OE.ORDER.TOTAL OID,GEN,QSIGN,ORDER.TOTAL,SUB.TOTAL,FREIGHT,HANDLING,TAX.AMT,FET.AMT
          TAX.AMT += FET.AMT
          FREIGHT  = OCONV(FREIGHT,'MR2')
          HANDLING = OCONV(HANDLING,'MR2')
          TAX.AMT  = OCONV(TAX.AMT,'MR2')
          RETURN
*-------------------------------------------------------------------------*
FOOTER:  *
          *IF PSTYLE.OVRD#'' THEN
          *STYLE.ID = PSTYLE.OVRD
          *END ELSE
          *STYLE.ID = LED(77)<1,GEN,1>
          *END
          TFTR = SPACE(79)
          TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<1>)+1,LEN(FTR.MSG<1>)] = FTR.MSG<1>
          TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = RUNNING.TOTAL FTR.FMT

          IF STYLE.ID='MFBLIND' OR STYLE.ID='BLIND' THEN
          PRINT
          END ELSE
          PRINT NORM.BOLD:TFTR
          END

          IF DOC.TYPE = 'R' THEN
             REC.MSG = 'Date Received : ':OCONV(LED(9)<1,GEN>,'D4/')
          END ELSE
             REC.MSG =''
          END

          TFTR = REC.MSG '' "L#79"
          TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<2>)+1,LEN(FTR.MSG<2>)] = FTR.MSG<2>
          TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = (FREIGHT + HANDLING) FTR.FMT
          IF STYLE.ID='MFBLIND' OR STYLE.ID='BLIND' THEN
          PRINT REC.MSG
          END ELSE
          PRINT TFTR
          END



          RUNNING.TOTAL += (FREIGHT + HANDLING)
          TFTR = '' "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
          IF STYLE.ID='MFBLIND' OR STYLE.ID='BLIND' THEN
          PRINT
          END ELSE
          PRINT TFTR
          END

          RUNNING.TOTAL += TAX.AMT

          PRINT
          TFTR = SPACE(79)
          TFTR[79-WIDTH.INSERT<COL.CT>-LEN(FTR.MSG<4>)+1,LEN(FTR.MSG<4>)] = FTR.MSG<4>
          TFTR[79-WIDTH.INSERT<COL.CT>+1,WIDTH.INSERT<COL.CT>] = RUNNING.TOTAL FTR.FMT
          IF STYLE.ID='MFBLIND' OR STYLE.ID='BLIND' THEN
          PRINT
          END ELSE
          PRINT TFTR
          END


          PRINT CHAR(27):"*p2920Y"

          PRINT ELPI:SMALL: 'Advise before entering order if it does not meet your minimum charge.'
          PRINT 'Above pricing will be used for payment unless notified within 48 hours of order placement.':SLPI:NORM

          RETURN
*-------------------------------------------------------------------------*
FFEED:    *
          IF REPRINT THEN
             PRINT CHAR(27):"*p3050Y"
             PRINT SPACE(57):SUP.SMALL:'** Reprint ** Reprint ** Reprint **':NORM:
          END
                    *** Print barcode.
          PRINT CHAR(27):"*p1750x*p3175Y":
          UT.PRINT.BARCODE ERR.CODE,'CODE128',150,25,7,ORD.ID

          PRINT CHAR(12):

          RETURN
*-------------------------------------------------------------------------*
PRINT.TOTALS: *
          IF TAX.AMT THEN
             TOTAL.COMMENT = 'Sales tax'
             TOTAL.AMT     = TAX.AMT
             GOSUB PRINT.TOTAL
             RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
          END
          IF FREIGHT THEN
             TOTAL.COMMENT = 'Freight'
             TOTAL.AMT     = FREIGHT
             GOSUB PRINT.TOTAL
             RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
          END
          IF HANDLING THEN
             TOTAL.COMMENT = 'Handling'
             TOTAL.AMT     = HANDLING
             GOSUB PRINT.TOTAL
             RUNNING.TOTAL = RUNNING.TOTAL + TOTAL.AMT
          END

          GOSUB PRINT.TOTAL.LINE
          IF ORD.STAT='B' OR (ORD.STAT='Y' AND DOC.TYPE='B') THEN
             TOTAL.COMMENT = 'Bid Total'
          END ELSE
             TOTAL.COMMENT = 'PO Amount'
          END
          TOTAL.AMT     = RUNNING.TOTAL
          GOSUB PRINT.TOTAL

          RETURN
*-------------------------------------------------------------------------*
PRINT.TOTAL: *
          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
          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)

          BEGIN CASE
          CASE NUM(PN)
             TOT.QS = (SUM(LD(5)<1,GEN>) + SUM(LD(6)<1,GEN>)) * QSIGN
             IF TOT.QS # 0 THEN
                GOSUB PRT.PN
             END
          CASE PN = 'C'
             OE.DESC.GET DESC,ALT.DESC,"POE Printing"
             GOSUB PRT.XDESC
          CASE PN = 'S'
             IF NOT(DIR.SHIP) THEN
                GOSUB PRT.SUBT
             END
          END CASE

          RETURN
*-------------------------------------------------------------------------*
PRT.PN:   *
          MATREAD PRD FROM PRDFILE,PN ELSE RETURN
          GET.ALL.PRD BR,PN,QSIGN,GROUP
          OE.DESC.GET DESC,ALT.DESC,"POE Printing"

          * If there is anything in PRD(80) we need to print the Hazardous
          * information.  PRD(80) is multivalued so converting VM to '' to
          * correctly determine if anything exists in this record.
          HAZMAT.INFO = PRD(80)
          CONVERT VM TO '' IN HAZMAT.INFO
          ** Only print Hazmat form is this is a return or the routine is
          ** is called for manifest printing.
          IF HAZMAT.INFO AND ((DOC.TYPE = 'O' OR DOC.TYPE = 'R') OR (MNFST.PRT=YES)) THEN
             PRINT.HAZ = YES
          END

          IF DIR.SHIP THEN
             OE.CUS.PN.CMT.GET LED(1)<1,INIT.GEN>,LED(5)<1,INIT.GEN>,CUSS(66),PN,CMT
             IF CMT<1> THEN DESC<1,-1> = 'Your # ':CMT<1>
             IF CMT<2> THEN DESC<1,-1> = 'Your Location : ':CMT<2>
             IF TRIM(NCMT) # "" THEN
                LOCATE NCMT IN DESC<1> SETTING NPOS THEN
                   DESC = DELETE(DESC,1,NPOS)
                END
             END
          END



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

          FOR LOC = 1 TO LOC.CT
             SHP.TYP.LOC = SHP.TYP.LOCS<1,1,LOC>
             LOCA = FIELD(SHP.TYP.LOC,'~',2)
             IF LOCA = 'WHSE' THEN PRINT.PICK = YES
             QS    = TOT.QS
             QOPEN = TOT.QS
*LOT
             IF LOT.FLAG THEN
                QS    = 1
                QOPEN = 1
                IF LD(91)<1,GEN> THEN HOLD.FOR.VENDOR = YES
             END
* Temp fix to get rid of double line printing
             IF QS = 0 THEN GOTO NO.PTR
             IF PRD(15) = '' THEN UMTBL = PLNE(3) ELSE UMTBL = PRD(15)
             IQ.TO.ALPHA UMTBL,PRD(7),LD(23),QS,Q1,U1,Q2,U2,QS.ALPHA
             PRT.STR = TRIM(QS.ALPHA)        "R#10"
             PRT.STR := PN                   "R#10"
             PRT.STR := ' ':DESC<1,1>        "L#35"
*LOT
             IF LOT.FLAG THEN
                FORMS.GET.LOT.PRC "PO",LDID,GEN,'',UNT.PRC
                PRT.STR := UNT.PRC "R3#10"
                PRT.STR := UNT.PRC "R2#12"
                COL.TOTAL<1,COL.CT> += UNT.PRC
             END ELSE
                OE.GET.PSTYLE OID,GNS,COL.START,COL.FRMTS,COL.BASIS,COL.EXTDS,COL.CT,QS,PRT.STR,COL.TOTAL,SUB.TOTAL
             END

             BLINE += 1
             BOD<BLINE> = PRT.STR
             GOSUB PRT.XDESC

NO.PTR:   NEXT LOC
*LOT
          IF LOT.FLAG THEN
             OE.LOT.PRINT.SETUP OID,GEN,'P','O',BLINE,SSPC,BOD,,'',LDID
          END

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

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

          BIN.LOC  = FIELD(LOCA, "^", 1)
*   IF ECLIPSE.ID$ = 'GARYD' OR USER.ID = 'CLARKO' THEN
          IF ORD.STAT = 'R' OR ORD.STAT = 'O' THEN
             IF BIN.LOC = '' THEN
                READ PD.BR FROM PRDDFILE, PN:"*":BR THEN
                   CSTAT 'PD.BR<8,1> = ':PD.BR<8,1>
                   IF FIELD(PD.BR<8,1>, '~', 2) # '' THEN
                      BIN.LOC = FIELD(PD.BR<8,1>, '~', 2)
                   END
                END
             END
             IF BIN.LOC # '' THEN
                PRT.STR  = SPACE(SSPC):' ' 'R#20':'LOC: ':BIN.LOC 'L#15'
                BLINE += 1
                BOD<BLINE> = PRT.STR
             END
          END
*   END

          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
             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
*-------------------------------------------------------------------------*
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

          *** For Johnstone Sites we will be displaying the store number
          *** along with the PO Number, and if there is a PSO number
          *** set in the Internal PO Notes, we will display that as well.
          *** We'll therefore be using a bigger box for the PO Number, and
          *** need to adjust the shading accordingly...
          IF JOHNSTONE.SITE$ THEN
             FORMS.PRINT.SHADE PERC,1600,190,2.6,HGHT,REST ;* PO Dt/Number
             FORMS.PRINT.SHADE PERC,2170,340,0.7,HGHT,REST ;* Page Number
          END ELSE
             FORMS.PRINT.SHADE PERC,1621,190,2.5,HGHT,REST ;* PO Dt/Number
             FORMS.PRINT.SHADE PERC,2101,340,0.9,HGHT,REST ;* Page Number
          END

          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
          PRINT CHAR(27):"9":
          PRINT CHAR(27):"*p0X":
          PRINT CHAR(27):"*p0Y":
          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
*-------------------------------------------------------------------------*
!TSMITH~05/13/14~15:52

