233 lines
5.0 KiB
Plaintext
Executable File
233 lines
5.0 KiB
Plaintext
Executable File
*---------------------------*
|
|
* CLOCK.CALC
|
|
* BY D.BELL
|
|
* 3/22/91
|
|
*
|
|
* THIS SUBROUTINE CALCULATES HOURS WORKED BY PASSING AN ARRAY CALLED
|
|
* ZRAY.
|
|
* ZRAY<2>=TIMES
|
|
* ZRAY<3>=PROJECTS
|
|
*---------------------------*
|
|
CS=@(-1) ; CR=@(-3) ; CL=@(-4) ; RV=@(-13) ; ERV=@(-14)
|
|
VM=CHAR(253) ; SVM=CHAR(252) ; AM=CHAR(254) ; BEEP=CHAR(7)
|
|
PF1='<' ; PF2='P' ; PF3='/'
|
|
PROMPT ""
|
|
HR.TOT=0
|
|
TOT.HOURS=0
|
|
ARAY=''
|
|
WCT=0
|
|
*
|
|
OPEN 'CLOCKFILE' TO CLOCKFILE ELSE ABORT
|
|
OPEN 'DEPT' TO DEPT.FILE ELSE ABORT
|
|
OPEN 'USER' TO USER.FILE ELSE ABORT
|
|
OPEN 'CLOCKFILE.WORK' TO WFILE THEN
|
|
CLEARFILE WFILE
|
|
END ELSE
|
|
EXECUTE \CREATE-FILE CLOCKFILE.WORK 1 11\
|
|
OPEN 'CLOCKFILE.WORK' TO WFILE ELSE ABORT
|
|
END
|
|
GOSUB 2000
|
|
SELECT CLOCKFILE
|
|
LOOP
|
|
READNEXT ID ELSE ID='EOF'
|
|
UNTIL ID='EOF' DO
|
|
DATE=OCONV(ID,"G1|1")
|
|
USER=OCONV(ID,"G0|1")
|
|
LOCATE(DATE,QRAY,1;NDX;'AR') THEN
|
|
IF QRAY<2,NDX> THEN
|
|
GOSUB 500
|
|
END
|
|
END ELSE
|
|
IF NDX > 1 THEN NDX=NDX-1
|
|
IF QRAY<2,NDX> THEN
|
|
IF DATE >= QRAY<1,NDX> AND DATE <= QRAY<1,NDX>+13 THEN
|
|
GOSUB 500
|
|
END
|
|
END
|
|
END
|
|
REPEAT
|
|
STOP
|
|
500 *
|
|
READ ARAY FROM CLOCKFILE,ID THEN
|
|
GOSUB 1000
|
|
END
|
|
RETURN
|
|
1000 *
|
|
ACT=DCOUNT(ARAY<1>,VM)
|
|
FOR A=1 TO ACT
|
|
TIME=ARAY<1,A>
|
|
PRJCT=ARAY<2,A>
|
|
IF REM(A,2) THEN
|
|
IF PRJCT='OFF' THEN
|
|
CRT @(0,22):BEEP:"The TIMECARD is in an ambiguous state - Unable to process!":
|
|
RQM
|
|
TOT.HOURS=0
|
|
ONTIME='UNKNOWN'
|
|
END ELSE
|
|
OPRJCT=PRJCT
|
|
ONTIME=TIME
|
|
END
|
|
END ELSE
|
|
IF PRJCT # 'OFF' THEN
|
|
CRT @(0,22):BEEP:"The TIMECARD is in an ambiguous state - Unable to process!":
|
|
RQM
|
|
TOT.HOURS=0
|
|
OFFTIME='UNKNOWN'
|
|
END ELSE
|
|
OFFTIME=TIME
|
|
END
|
|
IF OFFTIME='UNKNOWN' OR ONTIME='UNKNOWN' THEN
|
|
HOURS='?'
|
|
END ELSE
|
|
IF ONTIME > OFFTIME THEN
|
|
OFFTIME=OFFTIME+86400
|
|
END
|
|
HOURS=OFFTIME-ONTIME
|
|
END
|
|
READV DEPARTMENT FROM USER.FILE,USER,5 ELSE DEPARTMENT='999'
|
|
WREC=DATE
|
|
WREC<2>=USER
|
|
WREC<3>=OPRJCT
|
|
WREC<4>=ONTIME
|
|
WREC<5>=OFFTIME
|
|
WREC<6>=HOURS
|
|
IF DEPARTMENT=DEPT OR DEPT='ALL' THEN
|
|
WCT=WCT+1
|
|
WKEY=DEPARTMENT:'|':WCT
|
|
CRT @(0,22):WKEY
|
|
WRITE WREC ON WFILE,WKEY
|
|
END
|
|
END
|
|
NEXT A
|
|
RETURN
|
|
*
|
|
2000 *
|
|
CRT CS
|
|
CRT @(0,0):"CLOCK.EXP"
|
|
CRT @(0,22):CL:"Enter the DEPARTMENT to build analysis for or 'ALL' :":
|
|
INPUT DEPT
|
|
IF DEPT='/' THEN STOP
|
|
IF DEPT='ALL' THEN
|
|
DEPT.DESC='ALL'
|
|
END ELSE
|
|
READ DEPT.DESC FROM DEPT.FILE,DEPT ELSE
|
|
CRT @(0,22):BEEP:"INVALID DEPARTMENT CODE - TRY AGAIN OR '/' TO ESCAPE"
|
|
RQM
|
|
GO 2000
|
|
END
|
|
END
|
|
CRT @(0,2):"This process will build an analysis workfile for the '":DEPT.DESC:"'"
|
|
CRT @(0,3):"department and for the specified payroll periods."
|
|
CRT @(0,5):"Select the periods to rebuild from those found below."
|
|
COL=0
|
|
POS=5
|
|
MAXCOL=70
|
|
MAXPOS=20
|
|
QRAY=''
|
|
GOSUB 2200
|
|
QCT=DCOUNT(QRAY<1>,VM)
|
|
FOR Q=1 TO QCT
|
|
IF POS>=MAXPOS THEN COL=COL+20;POS=5
|
|
POS=POS+1
|
|
CRT @(COL,POS):" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" "
|
|
NEXT Q
|
|
CRT @(0,22):"Enter T(tag all), SPACE(toggle selection)":
|
|
COL=0; POS=5
|
|
FOR Q=1 TO QCT
|
|
IF POS>=MAXPOS THEN COL=COL+10;POS=5
|
|
POS=POS+1
|
|
CRT @(COL,POS):RV:" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" "
|
|
CRT @(COL,POS):
|
|
INPUT ANS,1:
|
|
CRT ERV
|
|
BEGIN CASE
|
|
CASE ANS=' '
|
|
IF QRAY<2,Q> THEN
|
|
CRT @(COL,POS):" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" "
|
|
QRAY<2,Q>=0
|
|
END ELSE
|
|
CRT @(COL,POS):RV:" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" ":ERV
|
|
QRAY<2,Q>=1
|
|
END
|
|
CASE ANS='T'
|
|
COL=0;POS=5
|
|
FOR Q=1 TO QCT
|
|
IF POS>=MAXPOS THEN COL=COL+10;POS=5
|
|
POS=POS+1
|
|
QRAY<2,Q>=1
|
|
CRT @(COL,POS):RV:" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" ":ERV
|
|
NEXT Q
|
|
CASE ANS='/'
|
|
STOP
|
|
CASE 1
|
|
IF QRAY<2,Q>=0 THEN
|
|
CRT @(COL,POS):" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" "
|
|
END ELSE
|
|
CRT @(COL,POS):RV:" ":OCONV(QRAY<1,Q>,'D2/'):"-":OCONV(QRAY<1,Q>+13,'D2/'):" ":ERV
|
|
END
|
|
END CASE
|
|
NEXT Q
|
|
CRT @(0,22):CL:BEEP:"IS THIS CORRECT (Y/N)":
|
|
INPUT ANS
|
|
IF ANS='/' THEN STOP
|
|
IF ANS='Y' ELSE GO 2000
|
|
FOR Q=1 TO QCT
|
|
IF QRAY<2,Q> THEN
|
|
CRT @(0,1):CR
|
|
CRT @(23,12):RV:"PLEASE WAIT!!!":ERV
|
|
END
|
|
NEXT Q
|
|
GOSUB 2300 ;* CLEAR EXISTING WORKFILE RECORDS FOR THIS DEPT/PERIOD(S)
|
|
RETURN
|
|
2200 * CALC DATES
|
|
EDATE=0; SDATE=0
|
|
PRDAYS=14; PRDATE=ICONV('12/23/90','D')
|
|
TODAY="1/1/":OCONV(DATE(),'D2Y')
|
|
TODAY=ICONV(TODAY,'D')
|
|
TODAY=TODAY-14
|
|
LOOP
|
|
TODAY=TODAY+14
|
|
SDATE=TODAY-PRDATE
|
|
IF SDATE <= PRDAYS THEN
|
|
EDATE=PRDATE
|
|
END ELSE
|
|
EDATE=PRDATE+(INT(SDATE/PRDAYS)*PRDAYS)
|
|
END
|
|
SDATE=EDATE+PRDAYS
|
|
ODATE=EDATE
|
|
QRAY=INSERT(QRAY,1,-1;ODATE)
|
|
QRAY=INSERT(QRAY,2,-1;'0')
|
|
UNTIL SDATE > DATE() DO REPEAT
|
|
RETURN
|
|
2300 *
|
|
SELECT WFILE
|
|
LOOP
|
|
READNEXT ID ELSE ID='EOF'
|
|
UNTIL ID='EOF' DO
|
|
READ WREC FROM WFILE,ID ELSE WREC=''
|
|
DATE=WREC<1>
|
|
DEPARTMENT=OCONV(ID,'G0|1')
|
|
IF DEPARTMENT=DEPT OR DEPT='ALL' ELSE
|
|
CRT @(10,20):"SKIPPED RECORD ":ID:CL
|
|
GO 2399
|
|
END
|
|
LOCATE(DATE,QRAY,1;NDX;'AR') THEN
|
|
IF QRAY<2,NDX> THEN
|
|
GOSUB 2500
|
|
END
|
|
END ELSE
|
|
IF NDX > 1 THEN NDX=NDX-1
|
|
IF QRAY<2,NDX> THEN
|
|
IF DATE >= QRAY<1,NDX> AND DATE <= QRAY<1,NDX>+13 THEN
|
|
GOSUB 2500
|
|
END
|
|
END
|
|
END
|
|
2399 *
|
|
REPEAT
|
|
RETURN
|
|
2500 *
|
|
CRT @(0,22):CL:"DELETING WORKFILE RECORD ":ID
|
|
*DELETE WFILE,ID
|
|
RETURN
|