          SUBROUTINE (PASSER)
** Version# 18.0001[1] - 10/28/2014 - 02:29pm - TSMITH - eclipse

*** Subroutine : RENTAL.FUTURE.LEDGER
*-------------------------------------------------------------------------*
*** This routine work similarly to the Future Ledger screen for regular
*** products and orders. This screen will display any rental agreements
*** that the given product is on including check-out and check-in times.
*** Included at the top is also a summary of the selected product.
*-------------------------------------------------------------------------*
*** Parameters:
*** NONE
*-------------------------------------------------------------------------*
*** Globals:
*** PRD  - Product
*** PRDD - Prod Dynam
*** LED  - Ledger (Rentals)
*-------------------------------------------------------------------------*
          SCREEN
          PRINT @(23,6):TIME.ZONE$ "L#3"
          PRINT @(38,6):TIME.ZONE$ "L#3"

          MATBUILD SPRD  FROM PRD
          MATBUILD SPRDD FROM PRDD.BR

         * UT.SEC3 23,AUTH.OK,,YES
          AUTH.OK = YES
          IF AUTH.OK # YES THEN GOTO FINISH

          VSCROLL.DEFINE 1,1,7,70,10,'RENTAL.LEDGER'
          VSCROLL.SET 1

          PN      = PASSER<1>
          BR      = PASSER<2>
          ID.BASE = 28

          IF PN = "" THEN
IN.PN:       INP PN,2,1,35,'TPRODUCT;X;1;1',V_"S:VERF.PRD.ID"
             IF QUIT THEN GOTO FINISH
             IF PN = '' THEN PRINT BELL:; GOTO IN.PN
             ON MOVE+1 GOTO IN.PN, IN.PN, IN.PN, IN.PN
          END
          IF BR = "" THEN
IN.BR:       INP.BR 41,0,4,BR,,,NO,NO
             IF QUIT THEN GOTO FINISH
             ON MOVE+1 GOTO IN.BR, IN.BR, IN.BR, IN.BR
          END

          IF NOT(BR) THEN GOTO IN.BR

          MATREAD PRD  FROM PRDFILE,PN      ELSE MAT PRD  = ''
          PRDD.BR.GET BR,PN

          GOSUB SORT.DATE
          GOSUB BUILD.SUMMARY
REDISP:   GOSUB DISPLAY

          IF BLANK THEN
             MENU.CLEAR
             MENU.LOAD ,,,,''
             MENU.LOAD ,,,,''
             MENU.LOAD 26,18,13,8,'B'
             PRINT BELL:
MESS.INP:    MESS 2,7,'No items found. Re-select or press <Esc> to exit...'
IN$$6:       INP A,0,0,0
             IF QUIT THEN GOTO FINISH
             GOTO MESS.INP
          END

          MENU.CLEAR
          MENU.LOAD  2,18,10,1,'V'
          MENU.LOAD 15,18, 8,1,'L'
          MENU.LOAD 26,18,13,8,'B'
          MENU.LOAD 42,18,14,1,'H'

          LINE = 1; COL = 1
          QUIT = 0; F12 = 0; MOVE = 0; LASTKEY = 0
*-------------------------------------------------------------------------*
MOVENEXT: PARSEMOVE COL,LINE,1,LN.CT,10,YES,NO

IN$$1:    INPV A,0,LINE,0
          IF QUIT THEN GOTO FINISH

          GOTO MOVENEXT
*-------------------------------------------------------------------------*
DISPLAY:  PRINT @(2,1):PRD(1)<1,1>    "L#35"
          PRINT @(2,2):PRD(1)<1,2>    "L#35"
          PRINT @(2,3):PRD(1)<1,3>    "L#35"
          PRINT @(41,0):BR            "R#4"

          PRINT @(52,1):SUM.TOTAL     "R#7"
          PRINT @(52,2):SUM.IN.STOCK  "R#7"
          PRINT @(52,3):SUM.RENTED    "R#7"
          PRINT @(52,4):SUM.OTHER     "R#7"
          PRINT @(52,5):SUM.COMMITTED "R#7"

          LINE = 1
          VSCROLL.MOVE LINE
          LN.CT = 0
          MORE.DATA = (IDS#'')
          IF NOT(MORE.DATA) THEN BLANK = YES; ELSE BLANK = NO
          LOOP UNTIL NOT(MORE.DATA)

          REMOVE ID  FROM IDS  SETTING MORE.DATA

          DT.OUT  = FIELD(ID,'.',1)
          TM.OUT  = FIELD(ID,'.',2)
          DT.IN   = FIELD(ID,'.',3)
          TM.IN   = FIELD(ID,'.',4)
          ROID    = FIELD(ID,'.',5)
          READV CN FROM RLEDFILE,ROID,5 ELSE CN = ROID
          GOSUB DISP.LN
          REPEAT

          VCLR LINE
          LN.CT = LINE - 1

          RETURN
*-------------------------------------------------------------------------*
DISP.LN:  *
          CHK.OUT = OCONV(DT.OUT,'D2/'):' ':OCONV(TM.OUT,'MTH')"L#6"
          CHK.IN  = OCONV(DT.IN,'D2/'):' ':OCONV(TM.IN,'MTH')"L#6"
          READV NAME FROM CUSFILE,CN,1 ELSE NAME = CN
          VPRINT  0,LINE,ROID                    "L#10"
          VPRINT 11,LINE,CHK.OUT                 "L#15"
          VPRINT 27,LINE,CHK.IN                  "L#15"
          VPRINT 43,LINE,NAME                    "L#30"
          LINE = LINE+1

          RETURN
*-------------------------------------------------------------------------*
SUBS:    ON OPTION GOTO VIEW.ORD, VIEW.LOCS, CHNG.BR, HIST.LEDGER
*-------------------------------------------------------------------------*
VIEW.ORD: *
          ROID = FIELD(IDS<LINE>,'.',5)
          VIEW.ONLY = YES
          RENTAL.OE.COMMON ROID,1,VIEW.ONLY
          RETURN
*-------------------------------------------------------------------------*
VIEW.LOCS:*
          RENTAL.PROD.LOC.MAINT PN:AM:BR
          VSCROLL.SET 1
          RETURN
*-------------------------------------------------------------------------*
CHNG.BR:  INP.BR 41,0,4,BR
          GOSUB SORT.DATE
          GOSUB BUILD.SUMMARY
          RETURN TO REDISP
*-------------------------------------------------------------------------*
HIST.LEDGER: *
          VIEW.NO = 1:VM:'R'
          INV.HISTORY.LEDGER PN,DATE(),BR,,VIEW.NO
          RETURN
*-------------------------------------------------------------------------*
SORT.DATE: *

          IDS       = ''
          SIDS      = ''
          IDS.TMP   = PRDD.BR(ID.BASE)
          MORE.DATA = (IDS.TMP#'')

          LOOP UNTIL NOT(MORE.DATA)
          REMOVE ID  FROM IDS.TMP SETTING MORE.DATA
          IF ID = "" THEN CONTINUE

          SID = FIELD(ID,'.',1) "R%7":'~':FIELD(ID,'.',1)"R%7"
          LOCATE SID IN SIDS BY 'AL' SETTING POS ELSE NULL

          SIDS = INSERT(SIDS,POS;SID)
          IDS  = INSERT(IDS,POS;ID)
          REPEAT

          RETURN
*-------------------------------------------------------------------------*
BUILD.SUMMARY: *
          SUM.IN.STOCK  = 0
          SUM.OTHER     = 0
          SUM.RENTED    = 0
          SUM.COMMITTED = DCOUNT(IDS,AM)
          SUM.TOTAL     = DCOUNT(PRDD.BR(26),VM)
          FOR XX = 1 TO SUM.TOTAL
             IF PRDD.BR(26)<1,XX> = "1" THEN
                SUM.IN.STOCK += 1
             END ELSE
                LOC = PRDD.BR(27)<1,XX>
                IF (NUM(LOC[2,7]) AND LOC[1,1] = "R") THEN
                   SUM.RENTED += 1
                END ELSE
                   SUM.OTHER += 1
                END
             END
          NEXT XX

          RETURN
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          MATPARSE PRD     FROM SPRD
          MATPARSE PRDD.BR FROM SPRDD
          RETURN
!TSMITH~10/28/14~14:29
