          SUBROUTINE (PASSER)
** Version# 27 - 04/09/2003 - 07:10pm - ANNEM - develop

*** Subroutine-  POE.DVR.PRINT.RECVR
*-------------------------------------------------------------------------*
*** This is the driver that prints the Purchase Order Reciever Report.
*-------------------------------------------------------------------------*
*** PASSER - Not used.
*-------------------------------------------------------------------------*
*** Common Variables Used: MOVE, OPTION, LED
*-------------------------------------------------------------------------*
*** Open screen and view menu options
         SCREEN



START:    GOSUB INIT
          GOSUB LOAD.HK

*-------------------------------------------------------------------------*
*** Input item to view (po number, vendor number, xfer number, etc)
IN.ID:    INP ID,26,3,15,'MCU'
          IF QUIT THEN GOTO FINISH

          BEGIN CASE
          CASE ID[1,1] = '#'
             PON = FIELD(ID,'#',2)
             DICT.SOUNDA SPON, PON
             INDEX.IDS.GET 'LEDGER','&INDEX&.TID',SPON,OID.LIST
             IDS = ''
             SELECT OID.LIST
             LOOP
                READNEXT OID ELSE EXIT
                IF OID[1,1] # 'P' THEN CONTINUE
                MATREAD LED FROM LEDFILE,OID ELSE PRINT BELL:; GOTO IN.ID
                GN.CT = DCOUNT(LED(12),VM)

                FOR J = 1 TO GN.CT
                   ADD.OK = NO
                   IF INDEX(OCONV(LED(13)<1,J>,'MCU'),OCONV(PON,'MCU'),1) THEN
                      ADD.OK = YES
                   END ELSE
                      IF INDEX(OCONV(LED(65)<1,J>,"MCU"),PON,1) THEN
                         ADD.OK = YES
                      END
                   END

                   IF ADD.OK THEN
                      IF LED(8)<1,J> THEN
                         IDS<1,-1> = OID:'.':LED(8)<1,J>"R%3"
                      END ELSE
                         IDS = INSERT(IDS,1,1;OID:'.':LED(12)<1,J>"R%4")
                      END
                   END
                NEXT J
             REPEAT
             IF IDS = '' THEN
                PRINT BELL:;GOTO IN.ID
             END
          CASE NOT(NUM(ID[4,3])) OR LEN(ID) < OID.LGTH$
             VERF.VEN.SF 21,3,15,ID
             IF ID = '' THEN GOTO IN.ID
             CN    = ID
             MATREAD CUS FROM CUSFILE,CN ELSE MAT CUS = ''

             IF CUS(7)<1,5> THEN
                PT.CN = CN
             END ELSE
                PT.CN = CUS(11)
             END

             READV IDS FROM ENTDFILE,PT.CN,1 ELSE IDS = ''
             IF PT.CN # CN THEN
                ID.CT = DCOUNT(IDS,VM)

                FOR J = ID.CT TO 1 STEP -1
                   ID    = IDS<1,J>
                   READ WRK FROM LEDFILE,FIELD(ID,'.',1) ELSE WRK = ''
                   LOCATE FIELD(ID,'.',2)+0 IN WRK<12> SETTING GN ELSE GN=1
                   IF WRK<5,GN>#CN THEN
                      IDS = DELETE(IDS,1,J)
                   END
                NEXT J
             END
          CASE OTHERWISE
             IDS  = ''
             OID  = FIELD(ID,'.',1)
             INVN = FIELD(ID,'.',2)
             MATREAD LED FROM LEDFILE,OID ELSE PRINT BELL:; GOTO IN.ID

             IF NUM(INVN) AND INVN#'' THEN
                LOCATE INVN+0 IN LED(8)<1> SETTING GEN THEN GOTO GOT.GEN
             END

             GN.CT = DCOUNT(LED(12),VM)

             FOR J = 1 TO GN.CT
                IF LED(8)<1,J> THEN
                   IDS<1,-1> = OID:'.':LED(8)<1,J>"R%3"
                END ELSE
                   IDS = INSERT(IDS,1,1;OID:'.':LED(12)<1,J>"R%4")
                END
             NEXT J
          END CASE

          IF IDS = '' THEN GOTO IN.ID

          IF DCOUNT(IDS,VM) = 1 THEN
             ORN = IDS
          END ELSE
             MENU.TABLE ORN,1,5,1,8,78,'CALL SEL.CONV.PO',1,IDS,'蚈rder#屯屯屯屯Br#虴xp Date蚏eq Date屯屯蚉O #屯屯屯屯屯屯屯Ship to屯屯屯屯屯'
          END

          IF ORN = '' THEN GOTO IN.ID

          OID = FIELD(ORN,'.',1)
          GID = FIELD(ORN,'.',2)

          MATREAD LED FROM LEDFILE,OID            ELSE GOTO IN.ID

          IF LEN(GID) = 3 THEN
             LOCATE GID+0 IN LED(8)<1>  SETTING GEN ELSE GOTO IN.ID
          END ELSE
             LOCATE GID+0 IN LED(12)<1> SETTING GEN ELSE GOTO IN.ID
          END

GOT.GEN:  ORN = OID
          *** Get the default settings for the current branch and display
          *** them
          GOSUB GET.DFLTS
          GOSUB DISPLAY
*-------------------------------------------------------------------------*
*** Input order status to view
IN.STYLE: INP SHP.STATS,26,4,10,'MCU'
          IF QUIT THEN GOTO START
          ON MOVE+1 GOTO IN.STYLE,IN.STYLE,IN.ID,IN.STYLE
*-------------------------------------------------------------------------*
*** Input product status to view
IN.OPTS:  INP PRT.OPTS,26,5,20,V_'D:,All,Nonstock Only,Stock Only'
          IF QUIT THEN GOTO START
          ON MOVE+1 GOTO IN.OPTS,IN.OPTS,IN.STYLE,IN.OPTS
*-------------------------------------------------------------------------*
*** Input commited orders to view
IN.COMTD: INP CMTD,26,6,20,V_'D:,All,Order Quantity'
          IF QUIT THEN GOTO START
          ON MOVE+1 GOTO IN.COMTD,IN.COMTD,IN.OPTS,IN.COMTD
*-------------------------------------------------------------------------*
*** Input tag qtys to view
IN.TAGS:  INP TAGS,26,7,20,V_'D:,Only This Order,All Orders'
          IF QUIT THEN GOTO START
          ON MOVE+1 GOTO IN.TAGS,IN.TAGS,IN.COMTD,IN.TAGS
*-------------------------------------------------------------------------*
*** Choice of viewing default (primary) location or multiple locs
IN.LSTATS:INP TLSTATS,26,8,20,V_SRT.LOCSTAT

          IF QUIT THEN GOTO START

          IF CHANGED THEN
             LSTATS = TLSTATS
             PRINT @(26,8) :LSTATS  "L#10"
          END

          ON MOVE+1 GOTO IN.LSTATS,IN.LSTATS,IN.TAGS,IN.LSTATS,IN.LSTATS,IN.LSTATS
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO PRTIT,VIEW,VIEW,ADDL.LOCS,SAVEIT
*-------------------------------------------------------------------------*
*** If additional locs selected, change primary default to multi
ADDL.LOCS: *
IN$$1:    INP.MULTI LSTATS,20,,SRT.LOCSTAT,,'Location Statuses'

          PLSTATS = LSTATS

          IF DCOUNT(LSTATS,VM) > 1 THEN
             PLSTATS = '*Multi*'
             PRINT @(26,8) :PLSTATS     "L#10"
          END ELSE
             PRINT @(26,8) :PLSTATS     "L#10"
          END

          RETURN
*-------------------------------------------------------------------------*
PRTIT:    *** If print option is selected then print it...
          IF OID = '' OR TLSTATS = '' THEN
             GOSUB CK.REQ.FLDS
             BEGIN CASE
             CASE INID.FLAG    = YES
                RETURN TO IN.ID
             CASE INLSTAT.FLAG = YES
                RETURN TO IN.LSTATS
             END CASE
          END

          *** Check to see if the Purchase Order has been canceled
          *** and prompt for verification...
          IF LED(6)<1,GEN> = 'X' THEN
             MSG     = "You are about to reprint a Purchase Order"
             MSG<-1> = "that has been canceled. Continue Y/N?"
             ANS     = ''
IN$$4:       INP.PROMPT ANS,MSG,'YN',1
             IF NOT(ANS) THEN RETURN TO START
          END

          IF UPCASE(SHP.STATS) = 'ALL' THEN
             SHIP.STATS = ''
          END ELSE
             SHIP.STATS = SHP.STATS
          END

          IF TRIM(UPCASE(TAGS)) = 'ALL ORDERS' THEN
             TAGS = YES
          END ELSE
             TAGS = NO
          END

          IF TRIM(UPCASE(CMTD)) = 'ALL' THEN CMTD = NO ELSE CMTD = YES

          POE.PRINT.RECVR OID,GEN,,SHIP.STATS,PRT.OPTS,TAGS,CMTD,LSTATS

          RETURN TO START
*-------------------------------------------------------------------------*
VIEW:     *** View or Edit option. View or edit is determined by the
          *** view only which is set when the user selects the view hotkey.
          IF OID = '' OR TLSTATS = '' THEN
             GOSUB CK.REQ.FLDS

             BEGIN CASE
             CASE INID.FLAG    = YES
                RETURN TO IN.ID
             CASE INLSTAT.FLAG = YES
                RETURN TO IN.LSTATS
             END CASE
          END

          MODE      = OID[1,1]
          INIT.VIEW = 1
          INIT.OID  = OID
          INIT.GEN  = GEN
          VIEW.ONLY = (OPTION=2)       ; * set when the view hotkey is used
          *** Preserves common that is currently active in order to allow
          *** the edit option.
          VIEW.EDIT.LED INIT.OID,INIT.GEN,VIEW.ONLY,INIT.VIEW

          RETURN
*-------------------------------------------------------------------------*
SAVEIT:   *** Saves the current screen settings to the control.branch file
          *** under the current PO's shipping Branch.

          *** Confirm the save... Also let's the User know that it is
          *** actually doing something.
          SV.CONF = ''
          O.PROMPT = 'Save Branch ':LED(2)<1,GEN,2>:' Defaults (Y/N) : '
IN$$3:    INP.PROMPT SV.CONF,O.PROMPT,'YN',1,'D:,':'Yes,No'
          IF NOT(SV.CONF) THEN RETURN

          DFLTS = ''

          IF UPCASE(SHP.STATS) = 'ALL' THEN
             DFLTS<1> = ''
          END ELSE
             DFLTS<1> = SHP.STATS
          END

          DFLTS<2> = PRT.OPTS

          IF TRIM(UPCASE(CMTD))='ALL' THEN DFLTS<3>=NO ELSE DFLTS<3>=YES

          IF TRIM(UPCASE(TAGS)) = 'ALL ORDERS' THEN
             DFLTS<4> = YES
          END ELSE
             DFLTS<4> = NO
          END

          DFLTS<5> = LSTATS

          WRITE DFLTS ON CTRBFILE,'PO.RECVR.DFLTS~':LED(2)<1,GEN,2> ELSE
             NULL
          END

          RETURN
*-------------------------------------------------------------------------*
INIT:     *** Initializes all required variables..
          OID          = ''
          SRT.LOCSTAT  = 'D:,Primary,Secondary,Floating,Remnant,*Blank*'
          REQ.FLDS     = ''
          INID.FLAG    = NO
          INLSTAT.FLAG = NO
          LSTATS       = ''; TLSTATS = ''

          RETURN
*-------------------------------------------------------------------------*
LOAD.HK:  *** Loads the hotkeys for the screen.
          CLEAR.SCREEN
          MENU.LOAD 2,10,5,1,'P'        ; * print
          MENU.LOAD 10,10,4,1,'V'       ; * view
          MENU.LOAD 17,10,4,1,'E'       ; * edit
          MENU.LOAD 24,10,14,1,'A'      ; * additional location statuses

          RETURN
*-------------------------------------------------------------------------*
DISPLAY:  *** Displays all the required info on the screen.

          IF LED(8)<1,GEN>#'' THEN ORN := ".":LED(8)<1,GEN> "R%3"
          PRINT @(26,3):ORN          "L#14"     ;* Order Number
          PRINT @(42,3):OCONV(LED(9)<1,GEN>,'D2/') ;* Date

          PRINT @(26,4):SHP.STATS    "L#25"     ;* Order Status
          PRINT @(26,5):PRT.OPTS     "L#25"     ;* Product Status
          PRINT @(26,6):CMTD         "L#25"     ;* Show Commitments
          PRINT @(26,7):TAGS         "L#25"     ;* Show Tag Quantities
          PRINT @(26,8):TLSTATS      "L#25"     ;* Location Statuses

          RETURN
*-------------------------------------------------------------------------*
GET.DFLTS: *** Get's the default settings from the appropriate branch
          *** control record for this order.

          READ DFLTS FROM CTRBFILE,'PO.RECVR.DFLTS~':LED(2)<1,GEN,2> THEN
             SHP.STATS    = DFLTS<1>
             IF SHP.STATS = '' THEN SHP.STATS = 'ALL'
             PRT.OPTS     = DFLTS<2>
             CMTD         = DFLTS<3>
             IF CMTD THEN CMTD = 'Order Quantity' ELSE CMTD = 'All'
             TAGS         = DFLTS<4>
             IF TAGS THEN TAGS = 'All Orders' ELSE TAGS = 'Only This Order'
             LSTATS       = DFLTS<5>
             IF DCOUNT(LSTATS,VM) > 1 THEN
                TLSTATS   = '*Multi*'
             END ELSE
                TLSTATS   = DFLTS<5>
             END
          END ELSE
             TAGS         = 'Only This Order'
             CMTD         = 'All'
             PRT.OPTS     = 'All'
             SHP.STATS    = 'All'
             LSTATS       = 'Primary'
             TLSTATS      = 'Primary'
          END

          *** As the settings for this are used whenever a purchase order
          *** is received, we restrict access to who can use this hotkey.
          CHECK.KEY 'PO.RECVR.SET.DFLTS',ENTRY.OK
          IF ENTRY.OK THEN
             MENU.LOAD 41,10,10,1,'S'   ;* Save Defaults
          END ELSE
             MENU.LOAD
          END

          RETURN
*-------------------------------------------------------------------------*
CK.REQ.FLDS: ***

*** Check for all blank required fields and generate error message
          IF OID     = '' THEN REQ.FLDS<-1> = 'Vendor/PO#/Xfer#/Rel#'
          IF TLSTATS = '' THEN REQ.FLDS<-1> = 'Location Status'

          IF REQ.FLDS # '' THEN
             ERR.MESS 8,3,BELL:'Missing Required Field(s):   ':AM:REQ.FLDS
IN$$2:       INPNO A,,,0
             BEGIN CASE
             CASE REQ.FLDS<1> = 'Vendor/PO#/Xfer#/Rel#'
                REQ.FLDS     = ''
                INID.FLAG    = YES
             CASE REQ.FLDS<1> = 'Location Status'
                REQ.FLDS     = ''
                INLSTAT.FLAG = YES
             END CASE
          END

          RETURN
*-------------------------------------------------------------------------*
*** Close window
FINISH:   WINDOW.CLOSE
          RETURN
!ANNEM~04/09/03~19:10
