          SUBROUTINE (RENTAL.PERIOD)
** Version# 0.0003[29] - 02/27/2017 - 04:13pm - TSMITH - eclipse
*** V0.0003 Change - Custom Coding . - 02/27/2017 - TSMITH - eclipse
*** V0.0002 Change - Custom Coding CUSTOM - 01/18/2017 - TSMITH - eclipse
** Copied from CBP DICT.GET.RENTAL Version# 0.0001[38] - 09/15/2016 - 11:52am - TSMITH - eclipse
*** V0.0001 Change - Custom Coding 1-3 - 09/15/2016 - TSMITH - eclipse
*-------------------------------------------------------------------------*
INIT:
SCREEN

OID =  OID.DATA$<1>
GEN = 1
LEDREC = ''
UT.OPEN.FILE "LEDGER.GPS",LEDGPSFILE,ERR.MSG
ODATE = ''
IDATE = ''
IF ERR.MSG THEN
PRINT @(2,2):ERR.MSG

END

READV CHK.OUT.DATE FROM LEDGPSFILE,OID,25 ELSE CHK.OUT.DATE = ""
READV CHK.OUT.TIME FROM LEDGPSFILE,OID,26 ELSE CHK.OUT.TIME = ""
READV CHK.IN.DATE FROM LEDGPSFILE,OID,27 ELSE CHK.IN.DATE = ""
READV CHK.IN.TIME FROM LEDGPSFILE,OID,28 ELSE CHK.IN.TIME = ""
READV HALF_DAY FROM LEDGPSFILE,OID,29 ELSE HALF_DAY = 0
READV INC.WKD FROM LEDGPSFILE,OID,24 ELSE INC.WKD = 0

PRINT @(19,2):OCONV(CHK.OUT.DATE,'D4/')
PRINT @(19,3):OCONV(CHK.IN.DATE,'D4/')
PRINT @(47,2):OCONV(CHK.OUT.TIME,'MTH')
PRINT @(47,3):OCONV(CHK.IN.TIME,'MTH')

IF HALF_DAY = 1 THEN
PRINT @(19,4):'Y' END ELSE
PRINT @(19,4):'N'
END
IF INC.WKD = 1 THEN
PRINT @(58,4):'Y' END ELSE
PRINT @(58,4):'N'
END


GOSUB DAYS
PRINT @(19,5):RENTAL.PERIOD
GOSUB HOTKEYS
*-------------------------------------------------------------------------*
IN.CHK.OUT.DATE: INP ODATE,19,2,10,'D4/',,,CHK.OUT.DATE

IF CHANGED THEN
WRITEV ODATE ON LEDGPSFILE,OID,25
GOSUB DAYS

END



IF QUIT THEN GOTO FINISH
IF F12 THEN GOTO FINISH
ON MOVE+1 GOTO IN.CHK.OUT.DATE,IN.CHK.OUT.TIME,IN.HALF.DAY,IN.CHK.OUT.TIME,IN.CHK.IN.DATE,IN.CHK.OUT.TIME,IN.CHK.OUT.TIME
*-------------------------------------------------------------------------*
IN.CHK.OUT.TIME: INP OTIME,47,2,10,'MTH',,,CHK.OUT.TIME

IF CHANGED THEN
WRITEV OTIME ON LEDGPSFILE,OID,26
GOSUB DAYS

END

IF QUIT THEN GOTO FINISH
IF F12 THEN GOTO FINISH
ON MOVE+1 GOTO IN.CHK.OUT.TIME,IN.CHK.OUT.DATE,IN.INC.WKD,IN.CHK.OUT.DATE,IN.CHK.IN.TIME,IN.CHK.IN.DATE,IN.CHK.IN.DATE
*-------------------------------------------------------------------------*
IN.CHK.IN.DATE: INP IDATE,19,3,10,'D4/',,,

IF CHANGED THEN
WRITEV IDATE ON LEDGPSFILE,OID,27
GOSUB DAYS
GOSUB REFRESH.SCREEN

END


IF QUIT THEN GOTO FINISH
IF F12 THEN GOTO FINISH
ON MOVE+1 GOTO IN.CHK.IN.DATE,IN.CHK.IN.TIME,IN.CHK.OUT.DATE,IN.CHK.IN.TIME,IN.HALF.DAY,IN.CHK.IN.TIME,IN.CHK.IN.TIME
*-------------------------------------------------------------------------*
IN.CHK.IN.TIME: INP ITIME,47,3,10,'MTH',,,CHK.IN.TIME

IF CHANGED THEN
WRITEV ITIME ON LEDGPSFILE,OID,28
GOSUB DAYS
GOSUB REFRESH.SCREEN

END


IF QUIT THEN GOTO FINISH
IF F12 THEN GOTO FINISH
ON MOVE+1 GOTO IN.CHK.IN.TIME,IN.CHK.IN.DATE,IN.CHK.OUT.TIME,IN.CHK.OUT.DATE,IN.INC.WKD,IN.HALF.DAY,IN.HALF.DAY
*-------------------------------------------------------------------------*
IN.HALF.DAY: INP HALF.DAY,19,4,1,'YN'

IF CHANGED THEN
WRITEV HALF.DAY ON LEDGPSFILE,OID,29
GOSUB REFRESH.SCREEN
END

IF QUIT THEN GOTO FINISH
IF F12 THEN GOTO FINISH
ON MOVE+1 GOTO IN.HALF.DAY,IN.INC.WKD,IN.CHK.IN.DATE,IN.INC.WKD,IN.CHK.OUT.DATE,IN.INC.WKD,IN.INC.WKD
*-------------------------------------------------------------------------*
IN.INC.WKD: INP INC.WKD,58,4,1,'YN'

IF CHANGED THEN
WRITEV INC.WKD ON LEDGPSFILE,OID,24
GOSUB REFRESH.SCREEN
END

IF QUIT THEN GOTO FINISH
IF F12 THEN GOTO FINISH
ON MOVE+1 GOTO IN.INC.WKD,IN.HALF.DAY,IN.CHK.IN.TIME,IN.HALF.DAY,IN.CHK.OUT.TIME,IN.CHK.OUT.DATE,IN.CHK.OUT.DATE
*-------------------------------------------------------------------------*
DAYS:
RENTAL.PERIOD = CHK.IN.DATE - CHK.OUT.DATE


COUNTER=-1

K = CHK.OUT.DATE
PERIOD.CT = CHK.IN.DATE

FOR K = CHK.OUT.DATE TO PERIOD.CT
RENT.DAY = OCONV(OCONV(K,'DWA'),'MCU')
IF INC.WKD # '1' THEN
IF RENT.DAY = 'SATURDAY' OR RENT.DAY = 'SUNDAY' THEN GOTO SKIP.ENTRY
END

COUNTER +=1



*-------------------------------------------------------------------------*
SKIP.ENTRY: NEXT K
IF COUNTER < 0 THEN COUNTER = 0
RENTAL.PERIOD = COUNTER

IF CHK.OUT.DATE # "" THEN
IF CHK.OUT.DATE = CHK.IN.DATE THEN
RENTAL.PERIOD = 1
END
END
RETURN
*-------------------------------------------------------------------------*
HOTKEYS:
             MENU.LOAD  2,7,4,1,'C'    ;* Open orders
RETURN
*-------------------------------------------------------------------------*
SUBS: ON OPTION GOTO CLEARSCREEN

*-------------------------------------------------------------------------*
CLEARSCREEN:
ODATE = ''
IDATE = ''
OTIME = ''
ITIME = ''
HALF_DAY = ''
INC.WKD = ''
WRITEV INC.WKD ON LEDGPSFILE,OID,24
WRITEV ODATE ON LEDGPSFILE,OID,25
WRITEV OTIME ON LEDGPSFILE,OID,26
WRITEV IDATE ON LEDGPSFILE,OID,27
WRITEV ITIME ON LEDGPSFILE,OID,28
WRITEV HALF_DAY ON LEDGPSFILE,OID,29
CLEAR.SCREEN

RETURN
*-------------------------------------------------------------------------*
REFRESH.SCREEN: CLEAR.SCREEN
GOTO INIT


FILEIT:
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE

!TSMITH~02/27/17~16:13
